Skip to content

Commit

Permalink
Avoid scale correction if missing resolution info
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Jan 20, 2025
1 parent 32f5637 commit b7d08db
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Bonsai.NuGet.Design/DrawingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ static class DrawingHelper
{
public static SizeF GetImageSize(this Graphics graphics, Image image)
{
return new(
width: image.Width * graphics.DpiX / image.HorizontalResolution,
height: image.Height * graphics.DpiY / image.VerticalResolution);
if (image.HorizontalResolution > 0)
return new(
width: image.Width * graphics.DpiX / image.HorizontalResolution,
height: image.Height * graphics.DpiY / image.VerticalResolution);
else
return new(image.Width, image.Height);
}

public static Bitmap Resize(this Image image, Size newSize)
Expand Down

0 comments on commit b7d08db

Please sign in to comment.