@@ -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
@@ -388,6 +388,22 @@ public void Clone_AnyBitmap()
388388 AssertImageAreEqual ( "expected.png" , "result.png" , true ) ;
389389 }
390390
391+ [ FactWithAutomaticDisplayName ]
392+ public void Clone_Crop_AnyBitmap ( )
393+ {
394+ string imagePath = GetRelativeFilePath ( "van-gogh-starry-night-vincent-van-gogh.jpg" ) ;
395+ var anyBitmap = AnyBitmap . FromFile ( imagePath ) ;
396+ AnyBitmap clonedAnyBitmap = anyBitmap . Clone ( new Rectangle ( 100 , 100 , 100 , 100 ) ) ;
397+
398+ clonedAnyBitmap . Width . Should ( ) . Be ( 100 ) ;
399+ clonedAnyBitmap . Height . Should ( ) . Be ( 100 ) ;
400+
401+ var recheckClonedAnyBitmap = AnyBitmap . FromBytes ( clonedAnyBitmap . GetBytes ( ) ) ;
402+
403+ recheckClonedAnyBitmap . Width . Should ( ) . Be ( 100 ) ;
404+ recheckClonedAnyBitmap . Width . Should ( ) . Be ( 100 ) ;
405+ }
406+
391407 [ FactWithAutomaticDisplayName ]
392408 public void CastSKBitmap_to_AnyBitmap ( )
393409 {
@@ -397,7 +413,7 @@ public void CastSKBitmap_to_AnyBitmap()
397413
398414 SaveSkiaBitmap ( skBitmap , "expected.png" ) ;
399415 anyBitmap . SaveAs ( "result.png" ) ;
400-
416+ anyBitmap . GetPixel ( 0 , 0 ) ; //should not throw error
401417 AssertImageAreEqual ( "expected.png" , "result.png" , true ) ;
402418 }
403419
@@ -430,7 +446,7 @@ public void CastSKImage_to_AnyBitmap()
430446
431447 SaveSkiaImage ( skImage , "expected.png" ) ;
432448 anyBitmap . SaveAs ( "result.png" ) ;
433-
449+ anyBitmap . GetPixel ( 0 , 0 ) ; //should not throw error
434450 AssertImageAreEqual ( "expected.png" , "result.png" , true ) ;
435451 }
436452
@@ -463,7 +479,7 @@ public void CastSixLabors_to_AnyBitmap()
463479
464480 imgSharp . Save ( "expected.bmp" ) ;
465481 anyBitmap . SaveAs ( "result.bmp" ) ;
466-
482+ anyBitmap . GetPixel ( 0 , 0 ) ; //should not throw error
467483 AssertImageAreEqual ( "expected.bmp" , "result.bmp" , true ) ;
468484 }
469485
@@ -524,7 +540,7 @@ public void CastBitmap_to_AnyBitmap_using_FromBitmap()
524540
525541 bitmap . Save ( "expected.png" ) ;
526542 anyBitmap . SaveAs ( "result.png" ) ;
527-
543+ anyBitmap . GetPixel ( 0 , 0 ) ; //should not throw error
528544 AssertImageAreEqual ( "expected.png" , "result.png" , true ) ;
529545 }
530546
@@ -755,6 +771,7 @@ public void Should_Resize_Image(string fileName, int width, int height)
755771 var resizeAnyBitmap = new AnyBitmap ( anyBitmap , width , height ) ;
756772 _ = resizeAnyBitmap . Width . Should ( ) . Be ( width ) ;
757773 _ = resizeAnyBitmap . Height . Should ( ) . Be ( height ) ;
774+ resizeAnyBitmap . GetPixel ( 0 , 0 ) ; //should not throw error
758775 }
759776
760777 [ FactWithAutomaticDisplayName ]
@@ -936,7 +953,7 @@ public void CastMaui_to_AnyBitmap()
936953
937954 SaveMauiImages ( image , "expected.bmp" ) ;
938955 anyBitmap . SaveAs ( "result.bmp" ) ;
939-
956+ anyBitmap . GetPixel ( 0 , 0 ) ; //should not throw error
940957 AssertImageAreEqual ( "expected.bmp" , "result.bmp" , true ) ;
941958 }
942959
@@ -948,7 +965,7 @@ public void CastMaui_from_AnyBitmap()
948965
949966 anyBitmap . SaveAs ( "expected.bmp" ) ;
950967 SaveMauiImages ( image , "result.bmp" ) ;
951-
968+ anyBitmap . GetPixel ( 0 , 0 ) ; //should not throw error
952969 AssertImageAreEqual ( "expected.bmp" , "result.bmp" , true ) ;
953970 }
954971#endif
@@ -972,6 +989,7 @@ public void Create_New_Image_Instance()
972989
973990 blankBitmap . Width . Should ( ) . Be ( 8 ) ;
974991 blankBitmap . Height . Should ( ) . Be ( 8 ) ;
992+ blankBitmap . GetPixel ( 0 , 0 ) ; //should not throw error
975993 }
976994
977995 [ FactWithAutomaticDisplayName ]
@@ -1070,7 +1088,7 @@ public void CastAnyBitmap_from_SixLabors()
10701088
10711089 image . Save ( "expected.bmp" ) ;
10721090 anyBitmap . SaveAs ( "result.bmp" ) ;
1073-
1091+ anyBitmap . GetPixel ( 0 , 0 ) ; //should not throw error
10741092 AssertLargeImageAreEqual ( "expected.bmp" , "result.bmp" , true ) ;
10751093 }
10761094#endif
0 commit comments