示例#1
0
        internal void UpdateOverlays()
        {
            //When updating overlays, the actual output resolution may be different from the desired resolution if stretching of overlays isn't allowed.
            if (_borderInfo != null)
            {
                var border = ImageLoader.LoadBitmapFromFile(_borderInfo.Info.File);
                TokenControl.SetDimensions(border.Width, border.Height);
            }
            else if (_overlayInfo != null)
            {
                var overlay = ImageLoader.LoadBitmapFromFile(_overlayInfo.Info.File);
                TokenControl.SetDimensions(overlay.Width, overlay.Height);
            }

            if (_borderInfo != null)
            {
                //Border
                var borderImage = ImageLoader.LoadBitmapFromFile(_borderInfo.Info.File, TokenControl.ImageResolutionWidth, TokenControl.ImageResolutionHeight);
                BitmapHelper.AddFilter(borderImage, _borderTintColor, _borderBlendFilter);

                TokenControl.SetBorderImage(borderImage);
                TokenControl.BorderImage.Height = TokenControl.ImageResolutionHeight;
                TokenControl.BorderImage.Width  = TokenControl.ImageResolutionWidth;
            }

            if (_overlayInfo != null)
            {
                //Overlay
                var overlayImage = ImageLoader.LoadBitmapFromFile(_overlayInfo.Info.File, TokenControl.ImageResolutionWidth, TokenControl.ImageResolutionHeight);
                BitmapHelper.AddFilter(overlayImage, _overlayTintColor, _overlayBlendFilter);
                if (!string.IsNullOrWhiteSpace(_overlayInfo.Info.Mask))
                {
                    BitmapHelper.ApplyMaskToImage(overlayImage, ImageLoader.LoadBitmapFromFile(_overlayInfo.Info.Mask, TokenControl.ImageResolutionWidth, TokenControl.ImageResolutionHeight));
                }

                TokenControl.SetOverlayImage(overlayImage);
                TokenControl.OverlayImage.Height = TokenControl.ImageResolutionHeight;
                TokenControl.OverlayImage.Width  = TokenControl.ImageResolutionWidth;
            }

            if (SettingsManager.AutoUpdatePreview)
            {
                RenderUsingDispatcher();
            }
        }
示例#2
0
        private Bitmap RenderImage()
        {
            Bitmap bitmap = TokenControl.RenderVisual(TokenControl.ZoomControl);

            //Apply the special filter.
            BitmapHelper.AddFilter(bitmap, _vm.SpecialFilterColor, _specialFilter);

            // Modify the rendered image.
            if (_overlayInfo != null)
            {
                var overlay = ImageLoader.LoadBitmapFromFile(_overlayInfo.Info.File, TokenControl.ImageResolutionWidth, TokenControl.ImageResolutionHeight);
                BitmapHelper.AddFilter(overlay, _overlayTintColor, _overlayBlendFilter);
                if (!string.IsNullOrWhiteSpace(_overlayInfo.Info.Mask))
                {
                    BitmapHelper.ApplyMaskToImage(overlay, ImageLoader.LoadBitmapFromFile(_overlayInfo.Info.Mask, TokenControl.ImageResolutionWidth, TokenControl.ImageResolutionHeight));
                }
                BitmapHelper.AddLayerToImage(bitmap, overlay);
            }

            if (_borderInfo != null)
            {
                if (!string.IsNullOrWhiteSpace(_borderInfo.Info.Mask))
                {
                    BitmapHelper.ApplyMaskToImage(bitmap, ImageLoader.LoadBitmapFromFile(_borderInfo.Info.Mask, TokenControl.ImageResolutionWidth, TokenControl.ImageResolutionHeight));
                }
                var border = ImageLoader.LoadBitmapFromFile(_borderInfo.Info.File, TokenControl.ImageResolutionWidth, TokenControl.ImageResolutionHeight);
                BitmapHelper.AddFilter(border, _borderTintColor, _borderBlendFilter);
                BitmapHelper.AddLayerToImage(bitmap, border);  //Draw the border
            }

            if (TokenControl.ZoomControl_Text.Visibility == Visibility.Visible)
            {
                Bitmap text = TokenControl.RenderVisual(TokenControl.ZoomControl_Text);
                BitmapHelper.AddLayerToImage(bitmap, text);
            }

            if (_vm.Autocrop)
            {
                bitmap = BitmapHelper.Autocrop(bitmap);
            }

            //Since we just spent time rendering the image, we might as well update the preview even if the user didn't ask for that specifically.
            _preWindow?.SetImage(bitmap);
            return(bitmap);
        }