Ported AC to SDL2
This commit is contained in:
committed by
aurhat
parent
9f537b0876
commit
f86579533a
@@ -204,7 +204,7 @@ SDL_Surface *forcergbasurface(SDL_Surface *os)
|
||||
SDL_Surface *ns = SDL_CreateRGBSurface(SDL_SWSURFACE, os->w, os->h, 32, RGBAMASKS);
|
||||
if(ns)
|
||||
{
|
||||
SDL_SetAlpha(os, 0, 0);
|
||||
SDL_SetSurfaceAlphaMod(os, SDL_ALPHA_OPAQUE);
|
||||
SDL_BlitSurface(os, NULL, ns, NULL);
|
||||
}
|
||||
SDL_FreeSurface(os);
|
||||
@@ -216,7 +216,8 @@ bool checkgrayscale(SDL_Surface *s)
|
||||
// gray scale images have 256 levels, no colorkey, and the palette is a ramp
|
||||
if(s->format->palette)
|
||||
{
|
||||
if(s->format->palette->ncolors != 256 || s->format->colorkey) return false;
|
||||
Uint32 ck = 0;
|
||||
if(s->format->palette->ncolors != 256 || SDL_GetColorKey(s, &ck) == -1) return false;
|
||||
const SDL_Color *colors = s->format->palette->colors;
|
||||
loopi(256) if(colors[i].r != i || colors[i].g != i || colors[i].b != i) return false;
|
||||
}
|
||||
@@ -265,7 +266,12 @@ SDL_Surface *fixsurfaceformat(SDL_Surface *s)
|
||||
switch(s->format->BytesPerPixel)
|
||||
{
|
||||
case 1:
|
||||
if(!checkgrayscale(s)) return s->format->colorkey ? forcergbasurface(s) : forcergbsurface(s);
|
||||
if(!checkgrayscale(s))
|
||||
{
|
||||
Uint32 ck;
|
||||
SDL_GetColorKey(s, &ck);
|
||||
return ck ? forcergbasurface(s) : forcergbsurface(s);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(s->format->Rmask != rgbmasks[0] || s->format->Gmask != rgbmasks[1] || s->format->Bmask != rgbmasks[2])
|
||||
|
||||
Reference in New Issue
Block a user