mirror of
https://github.com/simtactics/niotso.git
synced 2025-03-22 10:52:20 +00:00
Fixed BMP->PNG conversion in iff2html; this has been lacking BGR->RGB conversion since I adopted OptiPNG.
This commit is contained in:
parent
dd15e0d42a
commit
2c5957928a
1 changed files with 9 additions and 2 deletions
|
@ -37,6 +37,9 @@ int WritePNG(const char * OutName, const IFFChunk * ChunkData, int ZBuffer,
|
||||||
uint8_t * Data;
|
uint8_t * Data;
|
||||||
} Image;
|
} 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){
|
if(ChunkData){
|
||||||
/* BMP_ or FBMP chunk */
|
/* BMP_ or FBMP chunk */
|
||||||
bmpheader_t BMPHeader;
|
bmpheader_t BMPHeader;
|
||||||
|
@ -54,6 +57,12 @@ int WritePNG(const char * OutName, const IFFChunk * ChunkData, int ZBuffer,
|
||||||
|
|
||||||
Image.Width = BMPHeader.biWidth;
|
Image.Width = BMPHeader.biWidth;
|
||||||
Image.Height = BMPHeader.biHeight;
|
Image.Height = BMPHeader.biHeight;
|
||||||
|
|
||||||
|
for(i=0; i<Image.Width*Image.Height; i++){
|
||||||
|
uint8_t temp = Image.Data[i*3 + 0];
|
||||||
|
Image.Data[i*3 + 0] = Image.Data[i*3 + 2];
|
||||||
|
Image.Data[i*3 + 2] = temp;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
/* SPR# or SPR2 sprite */
|
/* SPR# or SPR2 sprite */
|
||||||
Image.Width = Sprite->Width;
|
Image.Width = Sprite->Width;
|
||||||
|
@ -61,8 +70,6 @@ int WritePNG(const char * OutName, const IFFChunk * ChunkData, int ZBuffer,
|
||||||
Image.Data = (!ZBuffer) ? Sprite->BGRA32Data : Sprite->ZBuffer;
|
Image.Data = (!ZBuffer) ? Sprite->BGRA32Data : Sprite->ZBuffer;
|
||||||
|
|
||||||
if(!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<Image.Width*Image.Height; i++){
|
for(i=0; i<Image.Width*Image.Height; i++){
|
||||||
uint8_t temp = Image.Data[i*4 + 0];
|
uint8_t temp = Image.Data[i*4 + 0];
|
||||||
Image.Data[i*4 + 0] = Image.Data[i*4 + 2];
|
Image.Data[i*4 + 0] = Image.Data[i*4 + 2];
|
||||||
|
|
Loading…
Add table
Reference in a new issue