mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 18:57:28 -07:00
This fixes a bug in the resize logic, the colors of the edges were not calculated correctly by GDI. Also added some additional dispose calls.
This commit is contained in:
parent
823d85ecdd
commit
089eec769e
5 changed files with 22 additions and 12 deletions
|
@ -904,10 +904,11 @@ namespace GreenshotPlugin.Core {
|
|||
/// <param name="dest">Image to copy to</param>
|
||||
/// <param name="colorMatrix">ColorMatrix to apply</param>
|
||||
public static void ApplyColorMatrix(Bitmap source, Rectangle sourceRect, Bitmap dest, Rectangle destRect, ColorMatrix colorMatrix) {
|
||||
ImageAttributes imageAttributes = new ImageAttributes();
|
||||
imageAttributes.ClearColorMatrix();
|
||||
imageAttributes.SetColorMatrix(colorMatrix);
|
||||
ApplyImageAttributes(source, sourceRect, dest, destRect, imageAttributes);
|
||||
using (ImageAttributes imageAttributes = new ImageAttributes()) {
|
||||
imageAttributes.ClearColorMatrix();
|
||||
imageAttributes.SetColorMatrix(colorMatrix);
|
||||
ApplyImageAttributes(source, sourceRect, dest, destRect, imageAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1049,7 +1050,9 @@ namespace GreenshotPlugin.Core {
|
|||
//create a blank bitmap the same size as original
|
||||
// If using 8bpp than the following exception comes: A Graphics object cannot be created from an image that has an indexed pixel format.
|
||||
Bitmap newBitmap = CreateEmpty(sourceImage.Width, sourceImage.Height, PixelFormat.Format24bppRgb, Color.Empty, sourceImage.HorizontalResolution, sourceImage.VerticalResolution);
|
||||
ApplyImageAttributes((Bitmap)sourceImage, Rectangle.Empty, newBitmap, Rectangle.Empty, CreateAdjustAttributes(brightness, contrast, gamma));
|
||||
using (ImageAttributes adjustAttributes = CreateAdjustAttributes(brightness, contrast, gamma)) {
|
||||
ApplyImageAttributes((Bitmap)sourceImage, Rectangle.Empty, newBitmap, Rectangle.Empty, adjustAttributes);
|
||||
}
|
||||
return newBitmap;
|
||||
}
|
||||
|
||||
|
@ -1404,7 +1407,10 @@ namespace GreenshotPlugin.Core {
|
|||
|
||||
using (Graphics graphics = Graphics.FromImage(newImage)) {
|
||||
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
graphics.DrawImage(sourceImage, new Rectangle(destX, destY, destWidth, destHeight), new Rectangle(0, 0, sourceImage.Width, sourceImage.Height), GraphicsUnit.Pixel);
|
||||
using (ImageAttributes wrapMode = new ImageAttributes()) {
|
||||
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
||||
graphics.DrawImage(sourceImage, new Rectangle(destX, destY, destWidth, destHeight), 0, 0, sourceImage.Width, sourceImage.Height, GraphicsUnit.Pixel, wrapMode);
|
||||
}
|
||||
}
|
||||
return newImage;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue