extern int image_width;
extern int image_height;
-unsigned char *PNG_LoadImage (const unsigned char *raw, int filesize, int matchwidth, int matchheight)
+unsigned char *PNG_LoadImage_BGRA (const unsigned char *raw, int filesize)
{
+ unsigned int c;
unsigned int y;
void *png, *pnginfo;
unsigned char *imagedata = NULL;
}
#endif
- if ((matchwidth && my_png.Width != (unsigned long)matchwidth) || (matchheight && my_png.Height != (unsigned long)matchheight))
- {
- qpng_destroy_read_struct(&png, &pnginfo, 0);
- return NULL;
- }
if (my_png.ColorType == PNG_COLOR_TYPE_PALETTE)
qpng_set_palette_to_rgb(png);
if (my_png.ColorType == PNG_COLOR_TYPE_GRAY || my_png.ColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
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;
}