As best I understand, both the RGB888
and RGB24
formats put their red components first, followed by green and then blue, and both formats take a total of 24 bits per pixel (because 8+8+8 = 24). Given this information both identifiers appear to describe the exact same format but I can verify that some of my code works with one of the two formats but not the other. What's the difference between the two that makes them incompatible?
Rgb24 is a sRGB format with 24 bits per pixel (BPP). Each color channel (red, green, and blue) is allocated 8 bits per pixel (BPP).
RGB888. In TouchGFX, a color of 24 bpp color depth will have the color format RGB888. This means that 8 bits are used for each of the color components red, green and blue.
An SDL_PixelFormat describes the format of the pixel data stored at the pixels field of an SDL_Surface. Every surface stores an SDL_PixelFormat in the format field. If you wish to do pixel level modifications on a surface, then understanding how SDL stores its color information is essential.
They are different. If you look at SDL2/SDL_pixels.h
you'll find:
SDL_PIXELFORMAT_RGB24 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
24, 3)
SDL_PIXELFORMAT_RGB888 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
SDL_PACKEDLAYOUT_8888, 24, 4)
SDL_PIXELFORMAT_RGBX8888 =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
SDL_PACKEDLAYOUT_8888, 24, 4)
So RGB24 is a tightly packed three byte format (RRGGBB
), while RGB888
is a four byte format with the first byte going ignored (XXRRGGBB
). So the format is just confusingly named and XRGB8888
would be a more appropriate name.
Don't know why they called it RGB888
instead of XRGB8888
, but they leave the leading X
away on other formats as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With