pixels: Packed-pixel YUV formats can legit report bits-per-pixel.

This makes the existing SDL_SoftStretch code work with them, at least for
nearest-neighbor scaling; otherwise, it'll mangle the data trying to scale
it as 8bpp data without warning.
This commit is contained in:
Ryan C. Gordon 2023-12-15 11:11:24 -05:00
parent 8e1758260c
commit 3d2d5d18f3
1 changed files with 10 additions and 1 deletions

View File

@ -147,8 +147,17 @@ SDL_bool SDL_GetMasksForPixelFormatEnum(Uint32 format, int *bpp, Uint32 *Rmask,
/* Partial support for SDL_Surface with FOURCC */
if (SDL_ISPIXELFORMAT_FOURCC(format)) {
/* Not a format that uses masks */
*bpp = 0;
*Rmask = *Gmask = *Bmask = *Amask = 0;
// however, some of these are packed formats, and can legit declare bits-per-pixel!
switch (format) {
case SDL_PIXELFORMAT_YUY2:
case SDL_PIXELFORMAT_UYVY:
case SDL_PIXELFORMAT_YVYU:
*bpp = 32;
break;
default:
*bpp = 0; // oh well.
}
return SDL_TRUE;
}
#else