Added support for SDL_PIXELFORMAT_RGB24 and SDL_PIXELFORMAT_BGR24 to SDL_PixelFormatEnumToMasks()
authorSam Lantinga <slouken@libsdl.org>
Mon, 14 Dec 2009 06:35:27 +0000
changeset 3557 7184580ab756
parent 3556 9c2e92de786a
child 3558 5f038ec1a1af
Added support for SDL_PIXELFORMAT_RGB24 and SDL_PIXELFORMAT_BGR24 to SDL_PixelFormatEnumToMasks()
src/video/SDL_pixels.c
--- 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) {