diff --git a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs index 029aade4e..aa1e1b171 100644 --- a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs +++ b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs @@ -74,7 +74,7 @@ namespace ExternalCommand { Image icon = null; if (File.Exists(config.commandlines[presetCommand])) { try { - icon = GetExeIcon(config.commandlines[presetCommand]); + icon = GetExeIcon(config.commandlines[presetCommand], 0); } catch{}; } iconCache.Add(presetCommand, icon); diff --git a/GreenshotPlugin/Core/ImageHelper.cs b/GreenshotPlugin/Core/ImageHelper.cs index 5ea34b639..09ea3cda1 100644 --- a/GreenshotPlugin/Core/ImageHelper.cs +++ b/GreenshotPlugin/Core/ImageHelper.cs @@ -890,6 +890,15 @@ namespace GreenshotPlugin.Core { public static Bitmap Clone(Image sourceBitmap) { return CloneArea(sourceBitmap, Rectangle.Empty, PixelFormat.DontCare); } + /// + /// Wrapper for just cloning & TargetFormat which calls the CloneArea + /// + /// Image to clone + /// Target Format, use PixelFormat.DontCare if you want the original (or a default if the source PixelFormat is not supported) + /// Bitmap with clone image data + public static Bitmap Clone(Image sourceBitmap, PixelFormat targetFormat) { + return CloneArea(sourceBitmap, Rectangle.Empty, targetFormat); + } /// /// Clone an image, taking some rules into account: diff --git a/GreenshotPlugin/Core/WindowsHelper.cs b/GreenshotPlugin/Core/WindowsHelper.cs index a7aa760ee..4d94bdaad 100644 --- a/GreenshotPlugin/Core/WindowsHelper.cs +++ b/GreenshotPlugin/Core/WindowsHelper.cs @@ -876,11 +876,15 @@ namespace GreenshotPlugin.Core { // Remove corners if (!Image.IsAlphaPixelFormat(capturedBitmap.PixelFormat)) { LOG.Debug("Changing pixelformat to Alpha for the RemoveCorners"); - Bitmap tmpBitmap = capturedBitmap.Clone(new Rectangle(Point.Empty, capturedBitmap.Size), PixelFormat.Format32bppArgb); + Bitmap tmpBitmap = ImageHelper.Clone(capturedBitmap, PixelFormat.Format32bppArgb); capturedBitmap.Dispose(); capturedBitmap = tmpBitmap; } - RemoveCorners(capturedBitmap, redMask, windowCaptureMode, conf.DWMBackgroundColor); + Color cornerColor = Color.Transparent; + if (!Image.IsAlphaPixelFormat(capturedBitmap.PixelFormat)) { + cornerColor = Color.FromArgb(255, conf.DWMBackgroundColor.R, conf.DWMBackgroundColor.G, conf.DWMBackgroundColor.B); + } + RemoveCorners(capturedBitmap, redMask, cornerColor); } } } finally { @@ -912,12 +916,8 @@ namespace GreenshotPlugin.Core { /// /// The bitmap taken which would normally be returned to the editor etc. /// The bitmap taken with a red background - /// The capturemode so we can take transparency into accound - /// The background color - private void RemoveCorners(Bitmap normalBitmap, Bitmap redBitmap, WindowCaptureMode captureMode, Color destinationColor) { - if (captureMode == WindowCaptureMode.AeroTransparent) { - destinationColor = Color.Transparent; - } + /// The background color + private void RemoveCorners(Bitmap normalBitmap, Bitmap redBitmap, Color cornerColor) { using (BitmapBuffer redBuffer = new BitmapBuffer(redBitmap, false)) { redBuffer.Lock(); using (BitmapBuffer normalBuffer = new BitmapBuffer(normalBitmap, false)) { @@ -929,28 +929,28 @@ namespace GreenshotPlugin.Core { int cornerY = y; Color currentPixel = redBuffer.GetColorAt(cornerX, cornerY); if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) { - normalBuffer.SetColorAt(cornerX, cornerY, destinationColor); + normalBuffer.SetColorAt(cornerX, cornerY, cornerColor); } // top right cornerX = normalBitmap.Width - x; cornerY = y; currentPixel = redBuffer.GetColorAt(cornerX, cornerY); if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) { - normalBuffer.SetColorAt(cornerX, cornerY, destinationColor); + normalBuffer.SetColorAt(cornerX, cornerY, cornerColor); } // bottom right cornerX = normalBitmap.Width - x; cornerY = normalBitmap.Height - y; currentPixel = redBuffer.GetColorAt(cornerX, cornerY); if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) { - normalBuffer.SetColorAt(cornerX, cornerY, destinationColor); + normalBuffer.SetColorAt(cornerX, cornerY, cornerColor); } // bottom left cornerX = x; cornerY = normalBitmap.Height - y; currentPixel = redBuffer.GetColorAt(cornerX, cornerY); if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) { - normalBuffer.SetColorAt(cornerX, cornerY, destinationColor); + normalBuffer.SetColorAt(cornerX, cornerY, cornerColor); } } }