mirror of
https://github.com/cyanfish/naps2.git
synced 2024-08-17 19:20:29 +03:00
Use LogicalPixelFormat to keep 1bpp after rotation
This commit is contained in:
parent
03bd237cd3
commit
a3090e1a07
@ -32,10 +32,8 @@ public class GtkImageTransformer : AbstractImageTransformer<GtkImage>
|
||||
CairoHelper.SetSourcePixbuf(context, image.Pixbuf, 0, 0);
|
||||
context.Paint();
|
||||
var newImage = new GtkImage(ImageContext, new Pixbuf(surface, 0, 0, width, height));
|
||||
// TODO: In Gdi, we convert this back to BW1. Should we do the same?
|
||||
newImage.LogicalPixelFormat = image.LogicalPixelFormat == ImagePixelFormat.BW1
|
||||
? ImagePixelFormat.Gray8
|
||||
: image.LogicalPixelFormat;
|
||||
OptimizePixelFormat(image, ref newImage);
|
||||
newImage.LogicalPixelFormat = image.LogicalPixelFormat;
|
||||
newImage.SetResolution(xres, yres);
|
||||
image.Dispose();
|
||||
return newImage;
|
||||
|
@ -34,6 +34,7 @@ public class MacImageTransformer : AbstractImageTransformer<MacImage>
|
||||
CGRect rect = new CGRect(0, 0, image.Width, image.Height);
|
||||
using var cgImage = image.Rep.AsCGImage(ref rect, null, null);
|
||||
c.DrawImage(rect, cgImage);
|
||||
OptimizePixelFormat(image, ref newImage);
|
||||
image.Dispose();
|
||||
return newImage;
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ public abstract class AbstractImageTransformer<TImage> where TImage : IMemoryIma
|
||||
/// <param name="result">The result that may be replaced.</param>
|
||||
protected void OptimizePixelFormat(TImage original, ref TImage result)
|
||||
{
|
||||
if (original.PixelFormat == ImagePixelFormat.BW1)
|
||||
if (original.UpdateLogicalPixelFormat() == ImagePixelFormat.BW1)
|
||||
{
|
||||
result = PerformTransform(result, new BlackWhiteTransform());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user