]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
swizzle RGBA to BGRA in png loader
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 29 Nov 2007 06:18:44 +0000 (06:18 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 29 Nov 2007 06:18:44 +0000 (06:18 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7735 d7cf8633-e32d-0410-b094-e92efae38249

image_png.c

index b53aee42ead27d9237509a030d654daef7db4d41..d7ee8595cca680a98736a8ac3047b82be1252667 100644 (file)
@@ -231,6 +231,7 @@ extern int  image_height;
 
 unsigned char *PNG_LoadImage_BGRA (const unsigned char *raw, int filesize)
 {
+       unsigned int c;
        unsigned int    y;
        void *png, *pnginfo;
        unsigned char *imagedata = NULL;
@@ -366,6 +367,14 @@ unsigned char *PNG_LoadImage_BGRA (const unsigned char *raw, int filesize)
                imagedata = NULL;
        }
 
+       // swizzle RGBA to BGRA
+       for (y = 0;y < (unsigned int)(image_width*image_height*4);y += 4)
+       {
+               c = imagedata[y+0];
+               imagedata[y+0] = imagedata[y+2];
+               imagedata[y+2] = c;
+       }
+
        return imagedata;
 }