Check for the sRGB color primaries rather than the transfer function

This commit is contained in:
Sam Lantinga
2026-07-28 12:28:57 -07:00
parent 412a7c5db6
commit 1457503bd2

View File

@@ -2834,7 +2834,7 @@ bool SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g
if (bytes_per_pixel <= sizeof(pixel) &&
!SDL_ISPIXELFORMAT_FOURCC(surface->format) &&
SDL_COLORSPACETRANSFER(surface->colorspace) == SDL_TRANSFER_CHARACTERISTICS_SRGB) {
SDL_COLORSPACEPRIMARIES(surface->colorspace) == SDL_COLOR_PRIMARIES_BT709) {
/* Fill the appropriate number of least-significant bytes of pixel,
* leaving the most-significant bytes set to zero */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
@@ -2913,7 +2913,7 @@ bool SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, flo
if (SDL_BYTESPERPIXEL(surface->format) <= sizeof(Uint32) &&
!SDL_ISPIXELFORMAT_FOURCC(surface->format) &&
SDL_COLORSPACETRANSFER(surface->colorspace) == SDL_TRANSFER_CHARACTERISTICS_SRGB) {
SDL_COLORSPACEPRIMARIES(surface->colorspace) == SDL_COLOR_PRIMARIES_BT709) {
Uint8 r8, g8, b8, a8;
if (SDL_ReadSurfacePixel(surface, x, y, &r8, &g8, &b8, &a8)) {