mirror of https://github.com/libsdl-org/SDL
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:
parent
8e1758260c
commit
3d2d5d18f3
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue