Bunny83 / Utilities

A (hopfully) growing collection of various math, geometry and general utility classes for Unity3d and C#

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with BMPLoader/ReadPalette

hippogamesunity opened this issue · comments

There is a bug with ReadPalette, some indexed BMP files are loaded as empty because ReadPalette sets zero alpha.
I've made a workaround:
//byte a = aReader.ReadByte(); Looks like a bug, BMP doesn't support transparency.
byte a = 255;

Well, note that your solution would break almost all normal BMP formats, especially all windows based formats. The only BMP variant that uses a 3 component palette is the ancient OS/2 format. Since Windows 3.0 all BMP formats upwards use a 4 component palette all times. In most cases the 4th component is simply reserved / ignored but it is present. So yes, it does not (yet) support all formats but your change is just wrong ^^. This would make it only load BMP images that are as old as Windows 2 (that was 1987, windows 3.0 came out in 1990)

Also BMP does support transparency and an alpha channel. However most applications and loaders do not support it. Read the documentation. The second example on Wikipedia actually has opacity.

A BMP file could even contain a PNG or JPEG compressed image, at least the specification allows this. However just as with transparency you rarely will find any software actually supporting those formats. See the possible values for the bV4V4Compression field.