iron-software / IronSoftware.System.Drawing

An open-source System.Drawing.Common replacement for .NET 5 and above on all platforms. Bringing together System.Drawing, Maui, and ImageSharp's Bitmap, Image, Font, and Shape types via an agnostic free NuGet package.
Other
120 stars 19 forks source link

Improved Handling of Tiff Image Frames #58

Closed mee-ironsoftware closed 1 year ago

mee-ironsoftware commented 1 year ago

Description

Fixing in OpenTiffToImageSharp method in AnyBitmap.cs.

This PR enhances the way Tiff images are processed, particularly in handling the dimensions of each frame in a multi-frame Tiff image.

Previously, it was possible for frames to have zero width or height, which could lead to issues during processing. This PR addresses these issues in the following ways:

  1. Non-Zero Dimensions for First Frame: The first frame of a Tiff image is now ensured to have non-zero dimensions. If the first frame has either width or height equal to zero, an exception is thrown. This validation is critical as the first frame sets the reference for other frames in the image.

  2. Inheriting Dimensions for Subsequent Frames: For frames other than the first one, if their dimensions are zero, they will now inherit the dimensions of the first frame. This helps in maintaining consistency across frames and avoids potential issues during further processing.

By implementing these improvements, the robustness of Tiff image processing is significantly enhanced, and edge cases involving zero dimensions are effectively handled.

Fixes #45

Type of change

Please select the relevant option by placing an 'x' inside the brackets, like this: [x].

How Has This Been Tested?

Try to load tiff image which has problem.

Checklist:

Please run through the checklist as much as possible and mark the items completed by placing an 'x' inside the brackets, like this: [x].