Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -388,6 +388,22 @@ public void Clone_AnyBitmap()
AssertImageAreEqual("expected.png", "result.png", true);
}

[FactWithAutomaticDisplayName]
public void Clone_Crop_AnyBitmap()
{
string imagePath = GetRelativeFilePath("van-gogh-starry-night-vincent-van-gogh.jpg");
var anyBitmap = AnyBitmap.FromFile(imagePath);
AnyBitmap clonedAnyBitmap = anyBitmap.Clone(new Rectangle(100,100,100,100));

clonedAnyBitmap.Width.Should().Be(100);
clonedAnyBitmap.Height.Should().Be(100);

var recheckClonedAnyBitmap = AnyBitmap.FromBytes(clonedAnyBitmap.GetBytes());

recheckClonedAnyBitmap.Width.Should().Be(100);
recheckClonedAnyBitmap.Width.Should().Be(100);
}

[FactWithAutomaticDisplayName]
public void CastSKBitmap_to_AnyBitmap()
{
Expand All @@ -397,7 +413,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);
}

Expand Down Expand Up @@ -430,7 +446,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);
}

Expand Down Expand Up @@ -463,7 +479,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);
}

Expand Down Expand Up @@ -524,7 +540,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);
}

Expand Down Expand Up @@ -755,6 +771,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]
Expand Down Expand Up @@ -936,7 +953,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);
}

Expand All @@ -948,7 +965,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
Expand All @@ -972,6 +989,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]
Expand Down Expand Up @@ -1070,7 +1088,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
Expand Down
4 changes: 2 additions & 2 deletions IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public AnyBitmap Clone()
public AnyBitmap Clone(Rectangle rectangle)
{
var cloned = GetInternalImages().Select(img => img.Clone(x => x.Crop(rectangle)));
return new AnyBitmap(Binary, cloned);
return new AnyBitmap(cloned);
}

/// <summary>
Expand Down Expand Up @@ -3236,7 +3236,7 @@ private void LoadAndResizeImage(AnyBitmap original, int width, int height)
_lazyImage = new Lazy<IReadOnlyList<Image>>(() =>
{

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

//update Binary
Expand Down
4 changes: 3 additions & 1 deletion NuGet/IronSoftware.Drawing.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ Supports:

For general support and technical inquiries, please email us at: [email protected]</description>
<summary>IronSoftware.System.Drawing is an open-source solution for .NET developers to replace System.Drawing.Common with a universal and flexible library.</summary>
<releaseNotes>- Updates internal dependencies.</releaseNotes>
<releaseNotes>- Optimizes AnyBitmap memory usage.
- Updates Color.FromName to align with System.Drawing.
- Adds support for RebeccaPurple color.</releaseNotes>
<copyright>Copyright © Iron Software 2022-2025</copyright>
<tags>Images, Bitmap, SkiaSharp, SixLabors, BitMiracle, Maui, SVG, TIFF, TIF, GIF, JPEG, PNG, Color, Rectangle, Drawing, C#, VB.NET, ASPX, create, render, generate, standard, netstandard2.0, core, netcore</tags>
<repository type="git" url="https://github.com/iron-software/IronSoftware.Drawing.Common" commit="$commit$" />
Expand Down
Loading