Navigation Menu

Skip to content

Commit

Permalink
Fixed swizzle of SDL_FillRect() on 24-bit surface (thanks, "nagydavid…
Browse files Browse the repository at this point in the history
…91"!).

Fixes Bugzilla #2986.
  • Loading branch information
icculus committed May 31, 2015
1 parent 1899dfb commit 80614b2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/video/SDL_fillrect.c
Expand Up @@ -196,9 +196,15 @@ SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
static void
SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
{
Uint8 r = (Uint8) ((color >> 16) & 0xFF);
Uint8 g = (Uint8) ((color >> 8) & 0xFF);
Uint8 b = (Uint8) (color & 0xFF);
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
Uint8 b1 = (Uint8) (color & 0xFF);
Uint8 b2 = (Uint8) ((color >> 8) & 0xFF);
Uint8 b3 = (Uint8) ((color >> 16) & 0xFF);
#elif SDL_BYTEORDER == SDL_BIG_ENDIAN
Uint8 b1 = (Uint8) ((color >> 16) & 0xFF);
Uint8 b2 = (Uint8) ((color >> 8) & 0xFF);
Uint8 b3 = (Uint8) (color & 0xFF);
#endif
int n;
Uint8 *p = NULL;

Expand All @@ -207,9 +213,9 @@ SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
p = pixels;

while (n--) {
*p++ = r;
*p++ = g;
*p++ = b;
*p++ = b1;
*p++ = b2;
*p++ = b3;
}
pixels += pitch;
}
Expand Down

0 comments on commit 80614b2

Please sign in to comment.