From 82705b616521076f7e8fb0406f9c28159627a76f Mon Sep 17 00:00:00 2001 From: RKrom Date: Mon, 17 Nov 2014 22:23:37 +0100 Subject: [PATCH] BUG-1686: Fix for weird shadow effect, this was actually a bug in the background drawing routine. --- Greenshot/Drawing/Surface.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs index fe8dd1cce..f22d12a4b 100644 --- a/Greenshot/Drawing/Surface.cs +++ b/Greenshot/Drawing/Surface.cs @@ -1235,32 +1235,33 @@ namespace Greenshot.Drawing { //graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; //graphics.CompositingQuality = CompositingQuality.HighQuality; //graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; + DrawBackground(graphics, clipRectangle); graphics.DrawImage(Image, clipRectangle, clipRectangle, GraphicsUnit.Pixel); graphics.SetClip(targetGraphics); _elements.Draw(graphics, _buffer, RenderMode.EDIT, clipRectangle); } targetGraphics.DrawImage(_buffer, clipRectangle, clipRectangle, GraphicsUnit.Pixel); } else { + DrawBackground(targetGraphics, clipRectangle); targetGraphics.DrawImage(Image, clipRectangle, clipRectangle, GraphicsUnit.Pixel); _elements.Draw(targetGraphics, null, RenderMode.EDIT, clipRectangle); } } + + private void DrawBackground(Graphics targetGraphics, Rectangle clipRectangle) { + // check if we need to draw the checkerboard + if (Image.IsAlphaPixelFormat(Image.PixelFormat) && _transparencyBackgroundBrush != null) { + targetGraphics.FillRectangle(_transparencyBackgroundBrush, clipRectangle); + } else { + targetGraphics.Clear(BackColor); + } + } /// /// Draw a checkboard when capturing with transparency /// /// PaintEventArgs protected override void OnPaintBackground(PaintEventArgs e) { - // check if we need to draw the checkerboard - if (Image.IsAlphaPixelFormat(Image.PixelFormat) && _transparencyBackgroundBrush != null) { - Graphics targetGraphics = e.Graphics; - Rectangle clipRectangle = e.ClipRectangle; - targetGraphics.FillRectangle(_transparencyBackgroundBrush, clipRectangle); - } else { - Graphics targetGraphics = e.Graphics; - targetGraphics.Clear(BackColor); - //base.OnPaintBackground(e); - } } ///