Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
We're using the alpha component of the palette entries, let's name it…
… appropriately.
  • Loading branch information
slouken committed Mar 24, 2013
1 parent 5c64387 commit 4d61b3d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/SDL_pixels.h
Expand Up @@ -256,7 +256,7 @@ typedef struct SDL_Color
Uint8 r;
Uint8 g;
Uint8 b;
Uint8 unused;
Uint8 a;
} SDL_Color;
#define SDL_Colour SDL_Color

Expand Down
6 changes: 3 additions & 3 deletions src/video/SDL_bmp.c
Expand Up @@ -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].g, 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 {
for (i = 0; i < (int) biClrUsed; ++i) {
SDL_RWread(src, &palette->colors[i].b, 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].unused, 1, 1);
SDL_RWread(src, &palette->colors[i].a, 1, 1);
}
}
}
Expand Down Expand Up @@ -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].g, 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);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/video/SDL_pixels.c
Expand Up @@ -730,7 +730,7 @@ SDL_DitherColors(SDL_Color * colors, int bpp)
b |= b << 2;
b |= b << 4;
colors[i].b = b;
colors[i].unused = SDL_ALPHA_OPAQUE;
colors[i].a = SDL_ALPHA_OPAQUE;
}
}

Expand Down Expand Up @@ -776,7 +776,7 @@ SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
rd = pal->colors[i].r - r;
gd = pal->colors[i].g - g;
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);
if (distance < smallest) {
pixel = i;
Expand Down Expand Up @@ -859,7 +859,7 @@ SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format,
*r = format->palette->colors[pixel].r;
*g = format->palette->colors[pixel].g;
*b = format->palette->colors[pixel].b;
*a = format->palette->colors[pixel].unused;
*a = format->palette->colors[pixel].a;
} else {
*r = *g = *b = *a = 0;
}
Expand Down Expand Up @@ -895,7 +895,7 @@ Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical)
for (i = 0; i < src->ncolors; ++i) {
map[i] = SDL_FindColor(dst,
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);
}
Expand All @@ -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 G = (Uint8) ((pal->colors[i].g * Gmod) / 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);
}
return (map);
Expand Down
4 changes: 2 additions & 2 deletions src/video/SDL_surface.c
Expand Up @@ -188,11 +188,11 @@ SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key)
surface->map->info.flags |= SDL_COPY_COLORKEY;
surface->map->info.colorkey = key;
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 {
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;
}
Expand Down

0 comments on commit 4d61b3d

Please sign in to comment.