From c57451e76e10091e708d58dea98c389459e7ed5e Mon Sep 17 00:00:00 2001 From: ikkyu Date: Thu, 21 Aug 2025 13:49:49 +0700 Subject: [PATCH] remove invalid using statement when init _lazyImage --- .../UnitTests/AnyBitmapFunctionality.cs | 20 ++++++++++--------- .../IronSoftware.Drawing.Common/AnyBitmap.cs | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/IronSoftware.Drawing/IronSoftware.Drawing.Common.Tests/UnitTests/AnyBitmapFunctionality.cs b/IronSoftware.Drawing/IronSoftware.Drawing.Common.Tests/UnitTests/AnyBitmapFunctionality.cs index 76a6671..dc79885 100644 --- a/IronSoftware.Drawing/IronSoftware.Drawing.Common.Tests/UnitTests/AnyBitmapFunctionality.cs +++ b/IronSoftware.Drawing/IronSoftware.Drawing.Common.Tests/UnitTests/AnyBitmapFunctionality.cs @@ -192,7 +192,7 @@ public void CastBitmap_to_AnyBitmap() bitmap.Save("expected.bmp"); anyBitmap.SaveAs("result.bmp"); - + anyBitmap.GetPixel(0, 0); //should not throw error AssertImageAreEqual("expected.bmp", "result.bmp", true); } @@ -217,7 +217,7 @@ public void CastImage_to_AnyBitmap() bitmap.Save("expected.bmp"); anyBitmap.SaveAs("result.bmp"); - + anyBitmap.GetPixel(0, 0); //should not throw error AssertImageAreEqual("expected.bmp", "result.bmp", true); } @@ -397,7 +397,7 @@ public void CastSKBitmap_to_AnyBitmap() SaveSkiaBitmap(skBitmap, "expected.png"); anyBitmap.SaveAs("result.png"); - + anyBitmap.GetPixel(0, 0); //should not throw error AssertImageAreEqual("expected.png", "result.png", true); } @@ -430,7 +430,7 @@ public void CastSKImage_to_AnyBitmap() SaveSkiaImage(skImage, "expected.png"); anyBitmap.SaveAs("result.png"); - + anyBitmap.GetPixel(0, 0); //should not throw error AssertImageAreEqual("expected.png", "result.png", true); } @@ -463,7 +463,7 @@ public void CastSixLabors_to_AnyBitmap() imgSharp.Save("expected.bmp"); anyBitmap.SaveAs("result.bmp"); - + anyBitmap.GetPixel(0, 0); //should not throw error AssertImageAreEqual("expected.bmp", "result.bmp", true); } @@ -524,7 +524,7 @@ public void CastBitmap_to_AnyBitmap_using_FromBitmap() bitmap.Save("expected.png"); anyBitmap.SaveAs("result.png"); - + anyBitmap.GetPixel(0, 0); //should not throw error AssertImageAreEqual("expected.png", "result.png", true); } @@ -755,6 +755,7 @@ public void Should_Resize_Image(string fileName, int width, int height) var resizeAnyBitmap = new AnyBitmap(anyBitmap, width, height); _ = resizeAnyBitmap.Width.Should().Be(width); _ = resizeAnyBitmap.Height.Should().Be(height); + resizeAnyBitmap.GetPixel(0, 0); //should not throw error } [FactWithAutomaticDisplayName] @@ -936,7 +937,7 @@ public void CastMaui_to_AnyBitmap() SaveMauiImages(image, "expected.bmp"); anyBitmap.SaveAs("result.bmp"); - + anyBitmap.GetPixel(0, 0); //should not throw error AssertImageAreEqual("expected.bmp", "result.bmp", true); } @@ -948,7 +949,7 @@ public void CastMaui_from_AnyBitmap() anyBitmap.SaveAs("expected.bmp"); SaveMauiImages(image, "result.bmp"); - + anyBitmap.GetPixel(0, 0); //should not throw error AssertImageAreEqual("expected.bmp", "result.bmp", true); } #endif @@ -972,6 +973,7 @@ public void Create_New_Image_Instance() blankBitmap.Width.Should().Be(8); blankBitmap.Height.Should().Be(8); + blankBitmap.GetPixel(0, 0); //should not throw error } [FactWithAutomaticDisplayName] @@ -1070,7 +1072,7 @@ public void CastAnyBitmap_from_SixLabors() image.Save("expected.bmp"); anyBitmap.SaveAs("result.bmp"); - + anyBitmap.GetPixel(0, 0); //should not throw error AssertLargeImageAreEqual("expected.bmp", "result.bmp", true); } #endif diff --git a/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs b/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs index 9bb1b3c..7855539 100644 --- a/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs +++ b/IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs @@ -3236,7 +3236,7 @@ private void LoadAndResizeImage(AnyBitmap original, int width, int height) _lazyImage = new Lazy>(() => { - using var image = Image.Load(Binary); + var image = Image.Load(Binary); image.Mutate(img => img.Resize(width, height)); //update Binary