bkaradzic / bimg

Image library.
BSD 2-Clause "Simplified" License
327 stars 268 forks source link

Fix bug where loading uncompressed sRGB KTX files would swap B/R #42

Closed rogual closed 4 years ago

rogual commented 4 years ago

KTX_SRGB8_ALPHA8 files would load in as BGRA. Fix by matching on both format and base format.

Caused by these two formats having the same m_internalFormatSrgb but different m_fmt:

{ KTX_BGRA,                                     KTX_SRGB8_ALPHA8,                               KTX_BGRA,                                     KTX_UNSIGNED_BYTE,                }, // BGRA8
{ KTX_RGBA8,                                    KTX_SRGB8_ALPHA8,                               KTX_RGBA,                                     KTX_UNSIGNED_BYTE,                }, // RGBA8
rogual commented 4 years ago

TBH I'm a little skeptical that KTX_SRGB8_ALPHA8 even belongs in that KTX_BGRA row, so a simpler fix might just be to change KTX_SRGB8_ALPHA8 to KTX_ZERO there. But I don't know enough to be sure.