-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BGR bitmap swapped red and blue channels #4918
Comments
Which template? DesktopGL? I'll have to test that. |
Jep |
The Icon BMP in the DesktopGL template is a 32bit BMP, ARGB coded. It's not a standard 24bit BMP. It has to be like this for the icon to be loaded with transparency. |
Yes, it is 32 bit, but I left out the alpha channel. I'm pretty sure it's ABGR though, checking the values in the debugger shows higher values in the third channel than the first, also opening in a text editor shows BGR somewhere at the start. |
Verified to be BGRA. |
Thanks! That means this is a bug in FreeImage right? |
I don't know, this kind of BMP doesn't look to be super standard, maybe the header of this file are not correct/standard. We'll have to test with more 32bit BMP (both "X8R8G8B8" and "A8R8G8B8"). I would be surprised that FreeImage doesn't support the full spec. |
The thumbnail in VS displays the correct image though, as do Windows Photos and Microsoft Paint |
If I remember the code correctly, the channels are swapped always for 32bits bitmaps. |
FreeImage gives us enough info to determine if we need to swap the
channels. I'll do a PR this weekend.
|
I have just run a little test on the mentioned bmp and compared its raw data with the one of the logos in the test assets. |
I'm thinking that FreeImage reads the file header as |
That would make sense, v4/v5 are Microsoft only, I believe. It could be a design choice. Maybe we only have to check v4/v5 headers and manually sort the channels. |
@KonajuGames - Did this get fixed? |
I'll check tonight.
|
I've now confirmed that FreeImage does not support higher than BITMAPINFOHEADER. What's worse is that you can request the bitmap info header, and FreeImage has modified the biSize parameter to 0x28, replacing the 0x7c that is in the file, and it actively ignores the channel masks that are in the file. This makes it impossible to use FreeImage for this case. My approach now will be to fix the conflict in #6008, then use StbSharp to load BMP, PNG, JPG and GIF in the content pipeline as well as |
Wouldn't it be better to use something that is being actively developed and maintained, like ImageSharp, for the Content Pipeline? |
No... at least not today. Enter a new issue if we want to discuss something for the future. |
I took a look at ImageSharp code. It does not support anything beyond BITMAPINFOHEADER either, same as FreeType. StbSharp does support V5. |
I've got StbSharp in the |
FreeImage fails to import BMP V4 or V5 files. StbSharp does import them correctly, so .bmp files are imported using StbSharp. DDS is still imported using a specific loader, and the remainder are still loaded with FreeImage for now. StbSharp does not support 1-bit BMP files, and since these files haven't really been seen since the early 90's I don't think it is a great loss to remove that support. Fixes MonoGame#4918
PR #6218 has been submitted to fix this. |
FreeImage fails to import BMP V4 or V5 files. StbSharp does import them correctly, so .bmp files are imported using StbSharp. DDS is still imported using a specific loader, and the remainder are still loaded with FreeImage for now. StbSharp does not support 1-bit BMP files, and since these files haven't really been seen since the early 90's I don't think it is a great loss to remove that support. Fixes #4918
FreeImage fails to import BMP V4 or V5 files. StbSharp does import them correctly, so .bmp files are imported using StbSharp. DDS is still imported using a specific loader, and the remainder are still loaded with FreeImage for now. StbSharp does not support 1-bit BMP files, and since these files haven't really been seen since the early 90's I don't think it is a great loss to remove that support. Fixes MonoGame#4918
I wanted to set up a little sandbox project to mess around in, and tried to load and draw the Icon bitmap that comes with the template. The result is this
Opening in a text editor, I see BGR in front so I guess that's the format it's in, but it's interpreted by MG as RGB. I set the textureformat in the pipeline tool to color, since that only seems to say something about compression, it doesn't imply RGBA, right? After debugging a bit I found out FreeImage gets the channel masks as
Now that's wrong right? Shouldn't this figure out the right masks based on the header? @KonajuGames
The text was updated successfully, but these errors were encountered: