mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-15 19:05:32 +00:00
Support returning <8bpp surfaces in SDL_LoadBMP_RW
This commit is contained in:
committed by
Sam Lantinga
parent
773ec1cfcb
commit
05e7dcf8f8
@@ -72,7 +72,12 @@ init_color_cursor(const char *file)
|
||||
SDL_Surface *surface = SDL_LoadBMP(file);
|
||||
if (surface) {
|
||||
if (surface->format->palette) {
|
||||
SDL_SetSurfaceColorKey(surface, 1, *(Uint8 *)surface->pixels);
|
||||
const Uint8 bpp = surface->format->BitsPerPixel;
|
||||
const Uint8 mask = (1 << bpp) - 1;
|
||||
if (SDL_PIXELORDER(surface->format->format) == SDL_BITMAPORDER_4321)
|
||||
SDL_SetSurfaceColorKey(surface, 1, (*(Uint8 *)surface->pixels) & mask);
|
||||
else
|
||||
SDL_SetSurfaceColorKey(surface, 1, ((*(Uint8 *)surface->pixels) >> (8 - bpp)) & mask);
|
||||
} else {
|
||||
switch (surface->format->BitsPerPixel) {
|
||||
case 15:
|
||||
|
||||
Reference in New Issue
Block a user