koszeggy / KGySoft.Drawing

KGy SOFT Drawing is a library for advanced image, icon and graphics handling.
https://kgysoft.net/drawing
Other
58 stars 8 forks source link

ImageExtensions.GetBitsPerPixel() return value always be 32 #2

Closed IYinxf closed 4 years ago

IYinxf commented 4 years ago

Image image = Image.FromFile(fileName); image.GetBitsPerPixel(); Even if the PixelFormat of file information is Format8bppIndexed, the return here is still 32. It is necessary for me to judge it. What should I do?

koszeggy commented 4 years ago

Sorry, somehow I missed this issue up to now.

As GetBitsPerPixel extracts the BPP value directly from PixelFormat (see ToBitsPerPixel) the result for Format8bppIndexed is guaranteed to be 8.

Do you still have the issue? A sample image might help; otherwise, I only can imagine the following gotchas:

You can load your image by Imaging Tools to see how the decoders used by System.Drawing treat the image. If you see Format8bppIndexed there, then GetBitsPerPixel/ToBitsPerPixel extensions must return 8.