mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-22 23:35:39 +00:00
Validate that pixel formats have the correct attributes
Also added a test to save and load as BMP format to make sure pixel transformations are working correctly. Fixes https://github.com/libsdl-org/SDL/issues/11483
This commit is contained in:
@@ -664,17 +664,8 @@ bool SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio)
|
||||
SDL_BITSPERPIXEL(surface->format));
|
||||
goto done;
|
||||
}
|
||||
} else if ((SDL_BITSPERPIXEL(surface->format) == 24) && !save32bit &&
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
(surface->fmt->Rmask == 0x00FF0000) &&
|
||||
(surface->fmt->Gmask == 0x0000FF00) &&
|
||||
(surface->fmt->Bmask == 0x000000FF)
|
||||
#else
|
||||
(surface->fmt->Rmask == 0x000000FF) &&
|
||||
(surface->fmt->Gmask == 0x0000FF00) &&
|
||||
(surface->fmt->Bmask == 0x00FF0000)
|
||||
#endif
|
||||
) {
|
||||
} else if ((surface->format == SDL_PIXELFORMAT_BGR24 && !save32bit) ||
|
||||
(surface->format == SDL_PIXELFORMAT_BGRA32 && save32bit)) {
|
||||
intermediate_surface = surface;
|
||||
} else {
|
||||
SDL_PixelFormat pixel_format;
|
||||
|
||||
@@ -2597,6 +2597,7 @@ bool SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a)
|
||||
goto done;
|
||||
}
|
||||
SDL_SetSurfaceColorspace(tmp, surface->colorspace);
|
||||
SDL_SetSurfaceBlendMode(tmp, SDL_BLENDMODE_NONE);
|
||||
|
||||
float *pixels = (float *)tmp->pixels;
|
||||
pixels[0] = r;
|
||||
|
||||
Reference in New Issue
Block a user