Skip to content

Commit

Permalink
Force masks to zero if creating an 8-bit surface.
Browse files Browse the repository at this point in the history
Otherwise, SDL2 doesn't do what we want here.
  • Loading branch information
icculus committed Mar 1, 2019
1 parent 683b141 commit 46fdbf7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/SDL12_compat.c
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 46fdbf7

Please sign in to comment.