Commit 79a929ff authored by Sam Lantinga's avatar Sam Lantinga

Again, map the color with the alpha channel filled in.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403260
parent 3446f888
...@@ -25,8 +25,6 @@ static void ...@@ -25,8 +25,6 @@ static void
FillBackground(SDL_Surface * screen) FillBackground(SDL_Surface * screen)
{ {
Uint8 *buffer; Uint8 *buffer;
Uint16 *buffer16;
Uint16 color;
Uint8 gradient; Uint8 gradient;
int i, k; int i, k;
...@@ -37,24 +35,45 @@ FillBackground(SDL_Surface * screen) ...@@ -37,24 +35,45 @@ FillBackground(SDL_Surface * screen)
quit(2); quit(2);
} }
buffer = (Uint8 *) screen->pixels; buffer = (Uint8 *) screen->pixels;
if (screen->format->BytesPerPixel != 2) { switch (screen->format->BytesPerPixel) {
for (i = 0; i < screen->h; ++i) { case 1:
memset(buffer, (i * 255) / screen->h, case 3:
screen->w * screen->format->BytesPerPixel); for (i = 0; i < screen->h; ++i) {
buffer += screen->pitch; memset(buffer, (i * 255) / screen->h,
} screen->w * screen->format->BytesPerPixel);
} else { buffer += screen->pitch;
for (i = 0; i < screen->h; ++i) {
gradient = ((i * 255) / screen->h);
color =
(Uint16) SDL_MapRGB(screen->format, gradient, gradient,
gradient);
buffer16 = (Uint16 *) buffer;
for (k = 0; k < screen->w; k++) {
*(buffer16 + k) = color;
} }
buffer += screen->pitch; break;
} case 2:
for (i = 0; i < screen->h; ++i) {
Uint16 *buffer16;
Uint16 color;
gradient = ((i * 255) / screen->h);
color = (Uint16) SDL_MapRGB(screen->format,
gradient, gradient, gradient);
buffer16 = (Uint16 *) buffer;
for (k = 0; k < screen->w; k++) {
*buffer16++ = color;
}
buffer += screen->pitch;
}
break;
case 4:
for (i = 0; i < screen->h; ++i) {
Uint32 *buffer32;
Uint32 color;
gradient = ((i * 255) / screen->h);
color = SDL_MapRGB(screen->format,
gradient, gradient, gradient);
buffer32 = (Uint32 *) buffer;
for (k = 0; k < screen->w; k++) {
*buffer32++ = color;
}
buffer += screen->pitch;
}
break;
} }
SDL_UnlockSurface(screen); SDL_UnlockSurface(screen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment