IronSoftware.System.Drawing icon indicating copy to clipboard operation
IronSoftware.System.Drawing copied to clipboard

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

Open chipego-ironsoftware opened this issue 2 years ago • 1 comments

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

  • Use the AnyBitmap.FromFile() method to load a 24bpp file.
  • Inspect the properties of the returned bitmap, specifically BitsPerPixel and Stride.
  • Examine the Scan0 data of the bitmap.

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

chipego-ironsoftware avatar Jun 30 '23 08:06 chipego-ironsoftware

Hello Team, Hello @chipego-ironsoftware @artem-iron

Could you please provide us the current status of this ticket?

Could you also please provide work around without using System Drawing? Thanks in advance.

SanKumSan avatar Nov 07 '25 08:11 SanKumSan