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
114 stars 18 forks source link

AnyBitmap.FromFile() on a 24bpp file will return a bitmap with the wrong encoding. #66

Open chipego-ironsoftware opened 1 year ago

chipego-ironsoftware commented 1 year ago

Description

When using the AnyBitmap.FromFile() method on a 24bpp file, the returned bitmap has the correct properties BitsPerPixel=24 and Stride=2564 (approximately width * 3). However, upon inspecting the Scan0 data, it appears to contain unexpected alpha data in the pattern of X Y Z 255 X Y Z 255 which is 32bpp with an alpha channel.

To Reproduce

Workaround

public static AnyBitmap BitmapFromFile(string path)
  {
   AnyBitmap img = AnyBitmap.FromFile(path);
   return new AnyBitmap(img, img.Width, img.Height);
  }

Test Image

This is a 24bpp image provided for the purpose of reproduction. TestLutBurnt