mirror of
https://github.com/greenshot/greenshot
synced 2025-07-14 00:53:51 -07:00
Fixed Transparency issues: always using transparent when the captured image is transparent, if not use the DWMBackgroundColor. (and fixed a compile error due to forgotten commit)
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1671 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
d3cb2d3e41
commit
096c33656c
3 changed files with 22 additions and 13 deletions
|
@ -74,7 +74,7 @@ namespace ExternalCommand {
|
||||||
Image icon = null;
|
Image icon = null;
|
||||||
if (File.Exists(config.commandlines[presetCommand])) {
|
if (File.Exists(config.commandlines[presetCommand])) {
|
||||||
try {
|
try {
|
||||||
icon = GetExeIcon(config.commandlines[presetCommand]);
|
icon = GetExeIcon(config.commandlines[presetCommand], 0);
|
||||||
} catch{};
|
} catch{};
|
||||||
}
|
}
|
||||||
iconCache.Add(presetCommand, icon);
|
iconCache.Add(presetCommand, icon);
|
||||||
|
|
|
@ -890,6 +890,15 @@ namespace GreenshotPlugin.Core {
|
||||||
public static Bitmap Clone(Image sourceBitmap) {
|
public static Bitmap Clone(Image sourceBitmap) {
|
||||||
return CloneArea(sourceBitmap, Rectangle.Empty, PixelFormat.DontCare);
|
return CloneArea(sourceBitmap, Rectangle.Empty, PixelFormat.DontCare);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper for just cloning & TargetFormat which calls the CloneArea
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceBitmap">Image to clone</param>
|
||||||
|
/// <param name="targetFormat">Target Format, use PixelFormat.DontCare if you want the original (or a default if the source PixelFormat is not supported)</param>
|
||||||
|
/// <returns>Bitmap with clone image data</returns>
|
||||||
|
public static Bitmap Clone(Image sourceBitmap, PixelFormat targetFormat) {
|
||||||
|
return CloneArea(sourceBitmap, Rectangle.Empty, targetFormat);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clone an image, taking some rules into account:
|
/// Clone an image, taking some rules into account:
|
||||||
|
|
|
@ -876,11 +876,15 @@ namespace GreenshotPlugin.Core {
|
||||||
// Remove corners
|
// Remove corners
|
||||||
if (!Image.IsAlphaPixelFormat(capturedBitmap.PixelFormat)) {
|
if (!Image.IsAlphaPixelFormat(capturedBitmap.PixelFormat)) {
|
||||||
LOG.Debug("Changing pixelformat to Alpha for the RemoveCorners");
|
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.Dispose();
|
||||||
capturedBitmap = tmpBitmap;
|
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 {
|
} finally {
|
||||||
|
@ -912,12 +916,8 @@ namespace GreenshotPlugin.Core {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="normalBitmap">The bitmap taken which would normally be returned to the editor etc.</param>
|
/// <param name="normalBitmap">The bitmap taken which would normally be returned to the editor etc.</param>
|
||||||
/// <param name="redBitmap">The bitmap taken with a red background</param>
|
/// <param name="redBitmap">The bitmap taken with a red background</param>
|
||||||
/// <param name="captureMode">The capturemode so we can take transparency into accound</param>
|
/// <param name="cornerColor">The background color</param>
|
||||||
/// <param name="destinationColor">The background color</param>
|
private void RemoveCorners(Bitmap normalBitmap, Bitmap redBitmap, Color cornerColor) {
|
||||||
private void RemoveCorners(Bitmap normalBitmap, Bitmap redBitmap, WindowCaptureMode captureMode, Color destinationColor) {
|
|
||||||
if (captureMode == WindowCaptureMode.AeroTransparent) {
|
|
||||||
destinationColor = Color.Transparent;
|
|
||||||
}
|
|
||||||
using (BitmapBuffer redBuffer = new BitmapBuffer(redBitmap, false)) {
|
using (BitmapBuffer redBuffer = new BitmapBuffer(redBitmap, false)) {
|
||||||
redBuffer.Lock();
|
redBuffer.Lock();
|
||||||
using (BitmapBuffer normalBuffer = new BitmapBuffer(normalBitmap, false)) {
|
using (BitmapBuffer normalBuffer = new BitmapBuffer(normalBitmap, false)) {
|
||||||
|
@ -929,28 +929,28 @@ namespace GreenshotPlugin.Core {
|
||||||
int cornerY = y;
|
int cornerY = y;
|
||||||
Color currentPixel = redBuffer.GetColorAt(cornerX, cornerY);
|
Color currentPixel = redBuffer.GetColorAt(cornerX, cornerY);
|
||||||
if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) {
|
if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) {
|
||||||
normalBuffer.SetColorAt(cornerX, cornerY, destinationColor);
|
normalBuffer.SetColorAt(cornerX, cornerY, cornerColor);
|
||||||
}
|
}
|
||||||
// top right
|
// top right
|
||||||
cornerX = normalBitmap.Width - x;
|
cornerX = normalBitmap.Width - x;
|
||||||
cornerY = y;
|
cornerY = y;
|
||||||
currentPixel = redBuffer.GetColorAt(cornerX, cornerY);
|
currentPixel = redBuffer.GetColorAt(cornerX, cornerY);
|
||||||
if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) {
|
if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) {
|
||||||
normalBuffer.SetColorAt(cornerX, cornerY, destinationColor);
|
normalBuffer.SetColorAt(cornerX, cornerY, cornerColor);
|
||||||
}
|
}
|
||||||
// bottom right
|
// bottom right
|
||||||
cornerX = normalBitmap.Width - x;
|
cornerX = normalBitmap.Width - x;
|
||||||
cornerY = normalBitmap.Height - y;
|
cornerY = normalBitmap.Height - y;
|
||||||
currentPixel = redBuffer.GetColorAt(cornerX, cornerY);
|
currentPixel = redBuffer.GetColorAt(cornerX, cornerY);
|
||||||
if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) {
|
if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) {
|
||||||
normalBuffer.SetColorAt(cornerX, cornerY, destinationColor);
|
normalBuffer.SetColorAt(cornerX, cornerY, cornerColor);
|
||||||
}
|
}
|
||||||
// bottom left
|
// bottom left
|
||||||
cornerX = x;
|
cornerX = x;
|
||||||
cornerY = normalBitmap.Height - y;
|
cornerY = normalBitmap.Height - y;
|
||||||
currentPixel = redBuffer.GetColorAt(cornerX, cornerY);
|
currentPixel = redBuffer.GetColorAt(cornerX, cornerY);
|
||||||
if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) {
|
if (currentPixel.R > 0 && currentPixel.G == 0 && currentPixel.B == 0) {
|
||||||
normalBuffer.SetColorAt(cornerX, cornerY, destinationColor);
|
normalBuffer.SetColorAt(cornerX, cornerY, cornerColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue