From 2c5957928a2bd5d9a72a50e8bc887925c27dab5f Mon Sep 17 00:00:00 2001 From: Fatbag Date: Sat, 16 Jun 2012 14:00:13 -0500 Subject: [PATCH] Fixed BMP->PNG conversion in iff2html; this has been lacking BGR->RGB conversion since I adopted OptiPNG. --- Tools/iff2html/image.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Tools/iff2html/image.c b/Tools/iff2html/image.c index 12e4d58..fc0ef30 100644 --- a/Tools/iff2html/image.c +++ b/Tools/iff2html/image.c @@ -37,6 +37,9 @@ int WritePNG(const char * OutName, const IFFChunk * ChunkData, int ZBuffer, uint8_t * Data; } Image; + /* We must swap from BGR to RGB; this cannot be done with libpng when you use + ** opng_reduce_image due to the state that it leaves png_ptr in */ + if(ChunkData){ /* BMP_ or FBMP chunk */ bmpheader_t BMPHeader; @@ -54,6 +57,12 @@ int WritePNG(const char * OutName, const IFFChunk * ChunkData, int ZBuffer, Image.Width = BMPHeader.biWidth; Image.Height = BMPHeader.biHeight; + + for(i=0; iWidth; @@ -61,8 +70,6 @@ int WritePNG(const char * OutName, const IFFChunk * ChunkData, int ZBuffer, Image.Data = (!ZBuffer) ? Sprite->BGRA32Data : Sprite->ZBuffer; if(!ZBuffer){ - /* Swap from BGR to RGB; this cannot be done with libpng when you use opng_reduce_image - ** due to the state that it leaves png_ptr in */ for(i=0; i