We're using the alpha component of the palette entries, let's name it appropriately.

This commit is contained in:
Sam Lantinga 2013-03-24 09:56:45 -07:00
parent 8f9ae94235
commit e09b99c523
4 changed files with 11 additions and 11 deletions

View file

@ -256,7 +256,7 @@ typedef struct SDL_Color
Uint8 r; Uint8 r;
Uint8 g; Uint8 g;
Uint8 b; Uint8 b;
Uint8 unused; Uint8 a;
} SDL_Color; } SDL_Color;
#define SDL_Colour SDL_Color #define SDL_Colour SDL_Color

View file

@ -252,14 +252,14 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
SDL_RWread(src, &palette->colors[i].b, 1, 1); SDL_RWread(src, &palette->colors[i].b, 1, 1);
SDL_RWread(src, &palette->colors[i].g, 1, 1); SDL_RWread(src, &palette->colors[i].g, 1, 1);
SDL_RWread(src, &palette->colors[i].r, 1, 1); SDL_RWread(src, &palette->colors[i].r, 1, 1);
palette->colors[i].unused = SDL_ALPHA_OPAQUE; palette->colors[i].a = SDL_ALPHA_OPAQUE;
} }
} else { } else {
for (i = 0; i < (int) biClrUsed; ++i) { for (i = 0; i < (int) biClrUsed; ++i) {
SDL_RWread(src, &palette->colors[i].b, 1, 1); SDL_RWread(src, &palette->colors[i].b, 1, 1);
SDL_RWread(src, &palette->colors[i].g, 1, 1); SDL_RWread(src, &palette->colors[i].g, 1, 1);
SDL_RWread(src, &palette->colors[i].r, 1, 1); SDL_RWread(src, &palette->colors[i].r, 1, 1);
SDL_RWread(src, &palette->colors[i].unused, 1, 1); SDL_RWread(src, &palette->colors[i].a, 1, 1);
} }
} }
} }
@ -510,7 +510,7 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst)
SDL_RWwrite(dst, &colors[i].b, 1, 1); SDL_RWwrite(dst, &colors[i].b, 1, 1);
SDL_RWwrite(dst, &colors[i].g, 1, 1); SDL_RWwrite(dst, &colors[i].g, 1, 1);
SDL_RWwrite(dst, &colors[i].r, 1, 1); SDL_RWwrite(dst, &colors[i].r, 1, 1);
SDL_RWwrite(dst, &colors[i].unused, 1, 1); SDL_RWwrite(dst, &colors[i].a, 1, 1);
} }
} }

View file

@ -730,7 +730,7 @@ SDL_DitherColors(SDL_Color * colors, int bpp)
b |= b << 2; b |= b << 2;
b |= b << 4; b |= b << 4;
colors[i].b = b; colors[i].b = b;
colors[i].unused = SDL_ALPHA_OPAQUE; colors[i].a = SDL_ALPHA_OPAQUE;
} }
} }
@ -776,7 +776,7 @@ SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
rd = pal->colors[i].r - r; rd = pal->colors[i].r - r;
gd = pal->colors[i].g - g; gd = pal->colors[i].g - g;
bd = pal->colors[i].b - b; bd = pal->colors[i].b - b;
ad = pal->colors[i].unused - a; ad = pal->colors[i].a - a;
distance = (rd * rd) + (gd * gd) + (bd * bd) + (ad * ad); distance = (rd * rd) + (gd * gd) + (bd * bd) + (ad * ad);
if (distance < smallest) { if (distance < smallest) {
pixel = i; pixel = i;
@ -859,7 +859,7 @@ SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format,
*r = format->palette->colors[pixel].r; *r = format->palette->colors[pixel].r;
*g = format->palette->colors[pixel].g; *g = format->palette->colors[pixel].g;
*b = format->palette->colors[pixel].b; *b = format->palette->colors[pixel].b;
*a = format->palette->colors[pixel].unused; *a = format->palette->colors[pixel].a;
} else { } else {
*r = *g = *b = *a = 0; *r = *g = *b = *a = 0;
} }
@ -895,7 +895,7 @@ Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical)
for (i = 0; i < src->ncolors; ++i) { for (i = 0; i < src->ncolors; ++i) {
map[i] = SDL_FindColor(dst, map[i] = SDL_FindColor(dst,
src->colors[i].r, src->colors[i].g, src->colors[i].r, src->colors[i].g,
src->colors[i].b, src->colors[i].unused); src->colors[i].b, src->colors[i].a);
} }
return (map); return (map);
} }
@ -922,7 +922,7 @@ Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod,
Uint8 R = (Uint8) ((pal->colors[i].r * Rmod) / 255); Uint8 R = (Uint8) ((pal->colors[i].r * Rmod) / 255);
Uint8 G = (Uint8) ((pal->colors[i].g * Gmod) / 255); Uint8 G = (Uint8) ((pal->colors[i].g * Gmod) / 255);
Uint8 B = (Uint8) ((pal->colors[i].b * Bmod) / 255); Uint8 B = (Uint8) ((pal->colors[i].b * Bmod) / 255);
Uint8 A = (Uint8) ((pal->colors[i].unused * Amod) / 255); Uint8 A = (Uint8) ((pal->colors[i].a * Amod) / 255);
ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, R, G, B, A); ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, R, G, B, A);
} }
return (map); return (map);

View file

@ -188,11 +188,11 @@ SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key)
surface->map->info.flags |= SDL_COPY_COLORKEY; surface->map->info.flags |= SDL_COPY_COLORKEY;
surface->map->info.colorkey = key; surface->map->info.colorkey = key;
if (surface->format->palette) { if (surface->format->palette) {
surface->format->palette->colors[surface->map->info.colorkey].unused = SDL_ALPHA_TRANSPARENT; surface->format->palette->colors[surface->map->info.colorkey].a = SDL_ALPHA_TRANSPARENT;
} }
} else { } else {
if (surface->format->palette) { if (surface->format->palette) {
surface->format->palette->colors[surface->map->info.colorkey].unused = SDL_ALPHA_OPAQUE; surface->format->palette->colors[surface->map->info.colorkey].a = SDL_ALPHA_OPAQUE;
} }
surface->map->info.flags &= ~SDL_COPY_COLORKEY; surface->map->info.flags &= ~SDL_COPY_COLORKEY;
} }