From 46fdbf7c1d3fc64befe9bcfeaeb16ca014dcc26f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 1 Mar 2019 10:51:25 -0500 Subject: [PATCH] Force masks to zero if creating an 8-bit surface. Otherwise, SDL2 doesn't do what we want here. --- src/SDL12_compat.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c index 728b4b1cc..bd000eba3 100644 --- a/src/SDL12_compat.c +++ b/src/SDL12_compat.c @@ -2114,6 +2114,9 @@ Surface20to12(SDL_Surface *surface20) DECLSPEC SDL12_Surface * SDLCALL SDL_CreateRGBSurface(Uint32 sdl12flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { + if (depth == 8) { + Rmask = Gmask = Bmask = Amask = 0; // force a paletted surface. + } SDL_Surface *surface20 = SDL20_CreateRGBSurface(0, width, height, depth, Rmask, Gmask, Bmask, Amask); SDL12_Surface *surface12 = Surface20to12(surface20); if (!surface12) { @@ -2128,6 +2131,9 @@ SDL_CreateRGBSurface(Uint32 sdl12flags, int width, int height, int depth, Uint32 DECLSPEC SDL12_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { + if (depth == 8) { + Rmask = Gmask = Bmask = Amask = 0; // force a paletted surface. + } SDL_Surface *surface20 = SDL20_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask); SDL12_Surface *surface12 = Surface20to12(surface20); if (!surface12) {