| Summary: | RGBA PNG images are loaded as ABGR | ||
|---|---|---|---|
| Product: | SDL_image | Reporter: | Mike Parker <aldacron> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | unspecified | ||
| Hardware: | x86_64 | ||
| OS: | Windows 7 | ||
| Attachments: |
Tri-colored image that demonstrates the color inversion.
Another image that demonstrates the color inversion. |
||
Created attachment 1337 [details]
Another image that demonstrates the color inversion.
SDL's pixel formats are packed pixels which are endian dependent, while OpenGL's pixel formats are (usually) byte arrays, which are not endian dependent.
The SDL 2D renderer uses SDL_PIXELFORMAT_ARGB8888 with this code:
case SDL_PIXELFORMAT_ARGB8888:
*internalFormat = GL_RGBA8;
*format = GL_BGRA;
*type = GL_UNSIGNED_INT_8_8_8_8_REV;
break;
You just need to account for the OpenGL formats you plan to use when you're loading your data.
|
Created attachment 1336 [details] Tri-colored image that demonstrates the color inversion. When loading 32-bit RGBA images, the pixel format is set to SDL_PIXELFORMAT_ABGR8888. Converting the image to SDL_PIXELFORMAT_RGBA8888 and then passing it to OpenGL with both the internal storage and texture format set to GL_RGBA results in the texture being displayed with the colors inverted. However, if the ABGR8888 image is passed as is with no conversion, again with both internal storage and texture format set to GL_RGBA, then the colors display correctly. In short, SDL_PIXELFORMAT_RGBA8888 is backwards compared to GL_RGBA, but SDL_PIXELFORMAT_ABGR8888 is not. Compiling as 32-bit on 64-bit Windows 7.