We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4938

Summary: Suggestion: rename SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XBGR8888
Product: SDL Reporter: Ellie <etc0de>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2 CC: kajema2739
Version: 2.0.10   
Hardware: All   
OS: All   

Description Ellie 2020-01-12 22:42:35 UTC
I just tripped over this: stb_image when requesting 3 channels with 8-bit actually returns them as 3 bytes per pixel with no alignment, so basically 4 pixels are 12 bytes with no padding (0...2, 3...5, 6...8, and 9...11). This I would have naively expected to be called RGB888 or BGR888, since there is no "dead" unused byte as I would expect for something called e.g. RGBX8888.

However, SDL2's SDL_PIXELFORMAT_BGR888 uses 4 bytes, same as SDL_PIXELFORMAT_BGRX8888, even though the latter appears to be a longer storage format - which it isn't, internally. It's just swapped, in byte order X, B, G, R (instead of BGRX). So why isn't the macro name also swapped, as "XBGR888" instead of just "BGR888"?

I find the formats therefore named inconsistently, and unless there is a reason for this I suggest these changes:

1. deprecate SDL_PIXELFORMAT_BGR888 in favor of a new SDL_PIXELFORMAT_XBGR8888

and

2. deprecate SDL_PIXELFORMAT_RGB888 in favor of a new SDL_PIXELFORMAT_XRGB8888
Comment 1 bugmenot_0 2020-06-10 11:12:43 UTC
I agree with this and have run into the same issue in the past.

The same problem affects the RGB555 format which really is XRGB1555.
Other formats, too probably.
Comment 2 Sam Lantinga 2020-06-12 17:31:43 UTC
Good suggestion, thanks!
https://hg.libsdl.org/SDL/rev/2aa5945a2336