changeset 3557:7184580ab756

Added support for SDL_PIXELFORMAT_RGB24 and SDL_PIXELFORMAT_BGR24 to SDL_PixelFormatEnumToMasks()
author Sam Lantinga <slouken@libsdl.org>
date Mon, 14 Dec 2009 06:35:27 +0000
parents 9c2e92de786a
children 5f038ec1a1af
files src/video/SDL_pixels.c
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/SDL_pixels.c	Mon Dec 14 04:19:00 2009 +0000
+++ b/src/video/SDL_pixels.c	Mon Dec 14 06:35:27 2009 +0000
@@ -53,6 +53,32 @@
     }
     *Rmask = *Gmask = *Bmask = *Amask = 0;
 
+    if (format == SDL_PIXELFORMAT_RGB24) {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+        *Rmask = 0x00FF0000;
+        *Gmask = 0x0000FF00;
+        *Bmask = 0x000000FF;
+#else
+        *Rmask = 0x000000FF;
+        *Gmask = 0x0000FF00;
+        *Bmask = 0x00FF0000;
+#endif
+        return SDL_TRUE;
+    }
+
+    if (format == SDL_PIXELFORMAT_BGR24) {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+        *Rmask = 0x000000FF;
+        *Gmask = 0x0000FF00;
+        *Bmask = 0x00FF0000;
+#else
+        *Rmask = 0x00FF0000;
+        *Gmask = 0x0000FF00;
+        *Bmask = 0x000000FF;
+#endif
+        return SDL_TRUE;
+    }
+
     if (SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED8 &&
         SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED16 &&
         SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED32) {