Skip to content

Commit 1bdc471

Browse files
authored
Merge pull request #142 from iron-software/hotfix-LoadAndResizeImage-image-disposed
hotfix LoadAndResizeImage crashed
2 parents c7a029f + c57451e commit 1bdc471

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

IronSoftware.Drawing/IronSoftware.Drawing.Common.Tests/UnitTests/AnyBitmapFunctionality.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public void CastBitmap_to_AnyBitmap()
192192

193193
bitmap.Save("expected.bmp");
194194
anyBitmap.SaveAs("result.bmp");
195-
195+
anyBitmap.GetPixel(0, 0); //should not throw error
196196
AssertImageAreEqual("expected.bmp", "result.bmp", true);
197197
}
198198

@@ -217,7 +217,7 @@ public void CastImage_to_AnyBitmap()
217217

218218
bitmap.Save("expected.bmp");
219219
anyBitmap.SaveAs("result.bmp");
220-
220+
anyBitmap.GetPixel(0, 0); //should not throw error
221221
AssertImageAreEqual("expected.bmp", "result.bmp", true);
222222
}
223223

@@ -397,7 +397,7 @@ public void CastSKBitmap_to_AnyBitmap()
397397

398398
SaveSkiaBitmap(skBitmap, "expected.png");
399399
anyBitmap.SaveAs("result.png");
400-
400+
anyBitmap.GetPixel(0, 0); //should not throw error
401401
AssertImageAreEqual("expected.png", "result.png", true);
402402
}
403403

@@ -430,7 +430,7 @@ public void CastSKImage_to_AnyBitmap()
430430

431431
SaveSkiaImage(skImage, "expected.png");
432432
anyBitmap.SaveAs("result.png");
433-
433+
anyBitmap.GetPixel(0, 0); //should not throw error
434434
AssertImageAreEqual("expected.png", "result.png", true);
435435
}
436436

@@ -463,7 +463,7 @@ public void CastSixLabors_to_AnyBitmap()
463463

464464
imgSharp.Save("expected.bmp");
465465
anyBitmap.SaveAs("result.bmp");
466-
466+
anyBitmap.GetPixel(0, 0); //should not throw error
467467
AssertImageAreEqual("expected.bmp", "result.bmp", true);
468468
}
469469

@@ -524,7 +524,7 @@ public void CastBitmap_to_AnyBitmap_using_FromBitmap()
524524

525525
bitmap.Save("expected.png");
526526
anyBitmap.SaveAs("result.png");
527-
527+
anyBitmap.GetPixel(0, 0); //should not throw error
528528
AssertImageAreEqual("expected.png", "result.png", true);
529529
}
530530

@@ -755,6 +755,7 @@ public void Should_Resize_Image(string fileName, int width, int height)
755755
var resizeAnyBitmap = new AnyBitmap(anyBitmap, width, height);
756756
_ = resizeAnyBitmap.Width.Should().Be(width);
757757
_ = resizeAnyBitmap.Height.Should().Be(height);
758+
resizeAnyBitmap.GetPixel(0, 0); //should not throw error
758759
}
759760

760761
[FactWithAutomaticDisplayName]
@@ -936,7 +937,7 @@ public void CastMaui_to_AnyBitmap()
936937

937938
SaveMauiImages(image, "expected.bmp");
938939
anyBitmap.SaveAs("result.bmp");
939-
940+
anyBitmap.GetPixel(0, 0); //should not throw error
940941
AssertImageAreEqual("expected.bmp", "result.bmp", true);
941942
}
942943

@@ -948,7 +949,7 @@ public void CastMaui_from_AnyBitmap()
948949

949950
anyBitmap.SaveAs("expected.bmp");
950951
SaveMauiImages(image, "result.bmp");
951-
952+
anyBitmap.GetPixel(0, 0); //should not throw error
952953
AssertImageAreEqual("expected.bmp", "result.bmp", true);
953954
}
954955
#endif
@@ -972,6 +973,7 @@ public void Create_New_Image_Instance()
972973

973974
blankBitmap.Width.Should().Be(8);
974975
blankBitmap.Height.Should().Be(8);
976+
blankBitmap.GetPixel(0, 0); //should not throw error
975977
}
976978

977979
[FactWithAutomaticDisplayName]
@@ -1070,7 +1072,7 @@ public void CastAnyBitmap_from_SixLabors()
10701072

10711073
image.Save("expected.bmp");
10721074
anyBitmap.SaveAs("result.bmp");
1073-
1075+
anyBitmap.GetPixel(0, 0); //should not throw error
10741076
AssertLargeImageAreEqual("expected.bmp", "result.bmp", true);
10751077
}
10761078
#endif

IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3236,7 +3236,7 @@ private void LoadAndResizeImage(AnyBitmap original, int width, int height)
32363236
_lazyImage = new Lazy<IReadOnlyList<Image>>(() =>
32373237
{
32383238

3239-
using var image = Image.Load<Rgba32>(Binary);
3239+
var image = Image.Load<Rgba32>(Binary);
32403240
image.Mutate(img => img.Resize(width, height));
32413241

32423242
//update Binary

0 commit comments

Comments
 (0)