Skip to content
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

RGBA PNG images are loaded as ABGR #72

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

RGBA PNG images are loaded as ABGR #72

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Labels
invalid This doesn't seem right

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: unspecified
Reported for operating system, platform: Windows 7, x86_64

Comments on the original bug report:

On 2013-09-23 09:34:52 +0000, Mike Parker wrote:

Created attachment 1336
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.

On 2013-09-23 09:35:15 +0000, Mike Parker wrote:

Created attachment 1337
Another image that demonstrates the color inversion.

On 2013-10-18 07:55:13 +0000, Sam Lantinga wrote:

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.

@SDLBugzilla SDLBugzilla added bug invalid This doesn't seem right labels Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant