Skip to content
Permalink
Browse files

Fixed bug 2923 - Add SDL_PIXELFORMAT_RGBA32 for byte-wise 32bit RGBA …

…data

Daniel Gibson

Ok, I followed the simple approach of just making SDL_PIXELFORMAT_RGBA32 an alias of SDL_PIXELFORMAT_RGBA8888/SDL_PIXELFORMAT_ABGR8888, depending on endianess. And I did the same for SDL_PIXELFORMAT_ARGB32, .._BGRA, .._ABGR.

SDL_GetPixelFormatName() will of course return SDL_PIXELFORMAT_RGBA8888 (or SDL_PIXELFORMAT_ABGR8888) instead of SDL_PIXELFORMAT_RGBA32, but as long as that's mentioned in the docs it shouldn't be a problem.
  • Loading branch information
slouken committed Oct 12, 2016
1 parent 8a0704d commit 36e40d30fc93eef6f0bdf167ae9f522485595bc2
Showing with 17 additions and 22 deletions.
  1. +14 −0 include/SDL_pixels.h
  2. +1 −8 src/render/software/SDL_rotate.c
  3. +1 −7 src/video/SDL_bmp.c
  4. +1 −7 src/video/cocoa/SDL_cocoavideo.m
@@ -29,6 +29,7 @@
#define _SDL_pixels_h

#include "SDL_stdinc.h"
#include "SDL_endian.h"

#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
@@ -260,6 +261,19 @@ enum
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
SDL_PACKEDLAYOUT_2101010, 32, 4),

/* Aliases for RGBA array of color formats for the current platform */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888, /**< endianess-specific alias for byte-wise 32bit RGBA data */
SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888,
#else
SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888,
SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888,
#endif

SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */
SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */
@@ -444,14 +444,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
*/
rz_src = src;
} else {
Uint32 format = SDL_MasksToPixelFormatEnum(32,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
#else
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
#endif
);
rz_src = SDL_ConvertSurfaceFormat(src, format, src->flags);
rz_src = SDL_ConvertSurfaceFormat(src, SDL_PIXELFORMAT_ARGB32, src->flags);
if (rz_src == NULL) {
return NULL;
}
@@ -533,13 +533,7 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst)
/* If the surface has a colorkey or alpha channel we'll save a
32-bit BMP with alpha channel, otherwise save a 24-bit BMP. */
if (save32bit) {
SDL_InitFormat(&format,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
SDL_PIXELFORMAT_ARGB8888
#else
SDL_PIXELFORMAT_BGRA8888
#endif
);
SDL_InitFormat(&format, SDL_PIXELFORMAT_BGRA32);
} else {
SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24);
}
@@ -176,13 +176,7 @@
int i;
NSImage *img;

converted = SDL_ConvertSurfaceFormat(surface,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
SDL_PIXELFORMAT_RGBA8888,
#else
SDL_PIXELFORMAT_ABGR8888,
#endif
0);
converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_RGBA32, 0);
if (!converted) {
return nil;
}

0 comments on commit 36e40d3

Please sign in to comment.