]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - image_png.c
Made Q1 face loading faster by using a faster lightmap packing algorithm.
[xonotic/darkplaces.git] / 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;
 }