Fixed swizzle of SDL_FillRect() on 24-bit surface (thanks, "nagydavid91"!).

Fixes Bugzilla #2986.
Ryan C. Gordon 2015-05-31 11:38:10 -04:00
parent 1899dfb041
commit 80614b27e4
1 changed files with 12 additions and 6 deletions

View File

@ -196,9 +196,15 @@ SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
static void static void
SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h) SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
{ {
Uint8 r = (Uint8) ((color >> 16) & 0xFF); #if SDL_BYTEORDER == SDL_LIL_ENDIAN
Uint8 g = (Uint8) ((color >> 8) & 0xFF); Uint8 b1 = (Uint8) (color & 0xFF);
Uint8 b = (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; int n;
Uint8 *p = NULL; Uint8 *p = NULL;
@ -207,9 +213,9 @@ SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
p = pixels; p = pixels;
while (n--) { while (n--) {
*p++ = r; *p++ = b1;
*p++ = g; *p++ = b2;
*p++ = b; *p++ = b3;
} }
pixels += pitch; pixels += pitch;
} }