mirror of https://github.com/encounter/SDL.git
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.
This commit is contained in:
parent
8a0704d15f
commit
36e40d30fc
|
@ -29,6 +29,7 @@
|
||||||
#define _SDL_pixels_h
|
#define _SDL_pixels_h
|
||||||
|
|
||||||
#include "SDL_stdinc.h"
|
#include "SDL_stdinc.h"
|
||||||
|
#include "SDL_endian.h"
|
||||||
|
|
||||||
#include "begin_code.h"
|
#include "begin_code.h"
|
||||||
/* Set up for C function definitions, even when using C++ */
|
/* 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_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
|
||||||
SDL_PACKEDLAYOUT_2101010, 32, 4),
|
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_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */
|
||||||
SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
|
SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
|
||||||
SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */
|
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;
|
rz_src = src;
|
||||||
} else {
|
} else {
|
||||||
Uint32 format = SDL_MasksToPixelFormatEnum(32,
|
rz_src = SDL_ConvertSurfaceFormat(src, SDL_PIXELFORMAT_ARGB32, src->flags);
|
||||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
|
||||||
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
|
|
||||||
#else
|
|
||||||
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
rz_src = SDL_ConvertSurfaceFormat(src, format, src->flags);
|
|
||||||
if (rz_src == NULL) {
|
if (rz_src == NULL) {
|
||||||
return 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
|
/* 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. */
|
32-bit BMP with alpha channel, otherwise save a 24-bit BMP. */
|
||||||
if (save32bit) {
|
if (save32bit) {
|
||||||
SDL_InitFormat(&format,
|
SDL_InitFormat(&format, SDL_PIXELFORMAT_BGRA32);
|
||||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
|
||||||
SDL_PIXELFORMAT_ARGB8888
|
|
||||||
#else
|
|
||||||
SDL_PIXELFORMAT_BGRA8888
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24);
|
SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24);
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,13 +176,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
|
||||||
int i;
|
int i;
|
||||||
NSImage *img;
|
NSImage *img;
|
||||||
|
|
||||||
converted = SDL_ConvertSurfaceFormat(surface,
|
converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_RGBA32, 0);
|
||||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
|
||||||
SDL_PIXELFORMAT_RGBA8888,
|
|
||||||
#else
|
|
||||||
SDL_PIXELFORMAT_ABGR8888,
|
|
||||||
#endif
|
|
||||||
0);
|
|
||||||
if (!converted) {
|
if (!converted) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue