jsummers / bmpsuite

A set of Windows BMP image files, for testing purposes
https://entropymine.com/jason/bmpsuite/
GNU General Public License v3.0
56 stars 16 forks source link

Missing standard 32bppBGRA BMP #13

Closed rysavyjan closed 4 years ago

rysavyjan commented 4 years ago

I noticed Paint.NET cannot properly open transparent samples such as q\rgba32.bmp: paintnet_rgba32

Paint.NET is using standard Windows Imaging Component (WIC) for BMP loading and saving. WIC is used by GDI+, WPF, .NET. The problem with mentioned q\rgba32.bmp is in channels order. I created a modified version of this image with BGRA order:

    defaultbmp(glctx, c);
    c->filename = "q/rgba32win.bmp";
    c->headersize = 124;
    c->bpp = 32;
    c->compression = BI_BITFIELDS;
    c->bf[I_R] = 0x00ff0000; c->nbits[I_R] = 8; c->bf_shift[I_R] = 16;
    c->bf[I_G] = 0x0000ff00; c->nbits[I_G] = 8; c->bf_shift[I_G] = 8;
    c->bf[I_B] = 0x000000ff; c->nbits[I_B] = 8; c->bf_shift[I_B] = 0;
    c->bf[I_A] = 0xff000000; c->nbits[I_A] = 8; c->bf_shift[I_A] = 24;
    c->pal_entries = 0;
    set_calculated_fields(c);
    if (!make_bmp_file(c)) goto done;

It works fine with Paint.NET and all applications based on WIC.

paintnet_rgba32win

Note that GIMP is also saving 32bpp alpha transparent BMP with BGRA channels order.

Would you accept pull request with this image?

rysavyjan commented 4 years ago

Small update after some tests. To enable WIC saving alpha transparent BMP, WIC2 (Windows 7 Platform Update and later) must be used and EnableV5Header32bppBGRA option enabled in BMP encoder:

https://docs.microsoft.com/en-us/windows/win32/wic/bmp-format-overview#enablev5header32bppbgra

https://github.com/Munemori/Windows_Classic_Sample/blob/96f883e4c900948e39660ec14a200a5164a3c7b7/Samples/DirectXTextureConverter/Cpp/DirectXTexWIC.cpp#L651

jsummers commented 4 years ago

Thanks. I agree, there should be such a file. I'll update the project soon.