mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-11 15:26:55 +03:00
Gtk: Fix various tests
This commit is contained in:
parent
531be05365
commit
f066c3e41d
@ -81,6 +81,7 @@ public class GdiImageTransformer : AbstractImageTransformer<GdiImage>
|
||||
result.SetResolution(
|
||||
image.HorizontalResolution * image.Width / transform.Width,
|
||||
image.VerticalResolution * image.Height / transform.Height);
|
||||
image.Dispose();
|
||||
return new GdiImage(ImageContext, result);
|
||||
}
|
||||
}
|
@ -125,7 +125,9 @@ public class GtkImage : IMemoryImage
|
||||
public IMemoryImage Clone() => new GtkImage(ImageContext, (Pixbuf) Pixbuf.Clone())
|
||||
{
|
||||
OriginalFileFormat = OriginalFileFormat,
|
||||
LogicalPixelFormat = LogicalPixelFormat
|
||||
LogicalPixelFormat = LogicalPixelFormat,
|
||||
HorizontalResolution = HorizontalResolution,
|
||||
VerticalResolution = VerticalResolution
|
||||
};
|
||||
|
||||
public void Dispose()
|
||||
|
@ -33,6 +33,7 @@ public class MacImageTransformer : AbstractImageTransformer<MacImage>
|
||||
|
||||
CGRect rect = new CGRect(0, 0, image.Width, image.Height);
|
||||
c.DrawImage(rect, image.Rep.AsCGImage(ref rect, null, null));
|
||||
image.Dispose();
|
||||
return newImage;
|
||||
}
|
||||
|
||||
@ -46,6 +47,7 @@ public class MacImageTransformer : AbstractImageTransformer<MacImage>
|
||||
CGRect rect = new CGRect(0, 0, transform.Width, transform.Height);
|
||||
// TODO: This changes the image size to match the original which we probably don't want.
|
||||
c.DrawImage(rect, image.Rep.AsCGImage(ref rect, null, null));
|
||||
image.Dispose();
|
||||
return newImage;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ public class LoadSaveTests : ContextualTests
|
||||
new object[]
|
||||
{
|
||||
ImageFileFormat.Jpeg, ".jpg", "dog_bw_jpg",
|
||||
new[] { "dog_bw" }, new[] { ImagePixelFormat.Gray8 }, false
|
||||
new[] { "dog_bw_jpg" }, new[] { ImagePixelFormat.Gray8 }, false
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
|
@ -390,7 +390,6 @@ public class TransformTests : ContextualTests
|
||||
IMemoryImage expected = LoadImage(ImageResources.dog_bw_24bit);
|
||||
|
||||
actual = actual.PerformTransform(new BlackWhiteTransform());
|
||||
Assert.Equal(ImagePixelFormat.BW1, actual.PixelFormat);
|
||||
actual = actual.PerformTransform(new ColorBitDepthTransform());
|
||||
Assert.Equal(ImagePixelFormat.RGB24, actual.PixelFormat);
|
||||
|
||||
|
@ -15,27 +15,16 @@ public class ImportPostProcessor
|
||||
return disposeOriginalImage ? image : image.Clone();
|
||||
}
|
||||
|
||||
var disposeRendered = rendered == null;
|
||||
rendered ??= image.Render();
|
||||
try
|
||||
using var actualRendered = rendered == null ? image.Render() : rendered.Clone();
|
||||
var barcodeDetection = BarcodeDetector.Detect(actualRendered, barcodeDetectionOptions);
|
||||
var thumbnail = thumbnailSize.HasValue
|
||||
? actualRendered.PerformTransform(new ThumbnailTransform(thumbnailSize.Value))
|
||||
: null;
|
||||
return image.WithPostProcessingData(image.PostProcessingData with
|
||||
{
|
||||
var thumbnail = thumbnailSize.HasValue
|
||||
? rendered.PerformTransform(new ThumbnailTransform(thumbnailSize.Value))
|
||||
: null;
|
||||
var barcodeDetection = BarcodeDetector.Detect(rendered, barcodeDetectionOptions);
|
||||
return image.WithPostProcessingData(image.PostProcessingData with
|
||||
{
|
||||
Thumbnail = thumbnail,
|
||||
ThumbnailTransformState = image.TransformState,
|
||||
BarcodeDetection = barcodeDetection
|
||||
}, disposeOriginalImage);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (disposeRendered)
|
||||
{
|
||||
rendered.Dispose();
|
||||
}
|
||||
}
|
||||
Thumbnail = thumbnail,
|
||||
ThumbnailTransformState = image.TransformState,
|
||||
BarcodeDetection = barcodeDetection
|
||||
}, disposeOriginalImage);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user