Support for 24 bpp pixel formats has been added.
authorMike Gorchak <lestat@i.com.ua>
Wed, 10 Jun 2009 05:51:44 +0000
changeset 3182 9f82979eaaf0
parent 3181 030899df1af5
child 3183 d1436442215f
Support for 24 bpp pixel formats has been added.
src/video/SDL_pixels.c
--- a/src/video/SDL_pixels.c	Tue Jun 09 19:39:23 2009 +0000
+++ b/src/video/SDL_pixels.c	Wed Jun 10 05:51:44 2009 +0000
@@ -39,7 +39,7 @@
     Uint32 masks[4];
 
     /* Initialize the values here */
-    if (SDL_BITSPERPIXEL(format) == 24) {
+    if (SDL_BYTESPERPIXEL(format) == 3) {
         *bpp = SDL_BYTESPERPIXEL(format) * 8;
     } else {
         *bpp = SDL_BITSPERPIXEL(format);
@@ -203,6 +203,17 @@
             return SDL_PIXELFORMAT_RGB565;
         }
         break;
+    case 24:
+        switch (Rmask) {
+        case 0x00FF0000:
+            return SDL_PIXELFORMAT_RGB888;
+        case 0x000000FF:
+            return SDL_PIXELFORMAT_BGR888;
+        case 0x00000000:
+            /* FIXME: At this point we can't distinguish */
+            /* if this format is RGB24 or BGR24          */
+            return SDL_PIXELFORMAT_RGB24;
+        }
     case 32:
         switch (Rmask) {
         case 0xFF000000: