Bug loading TGA with 32-bit palette
Posted: 2011-01-20T09:51:38-07:00
I have a TGA file with a 32-bit palette (so 256 colours, but each colour is RGBA) which was hanging during loading (link below). It loads fine in GIMP so I'm fairly confident that the file itself is ok.
http://rapidshare.com/#!download|616l34 ... stem.tga|1
I found a section of code in tga.c which looks wrong, namely in ReadTGAImage it does:
In the 32-bit case it's only reading 3 chars when the image contains 4 chars per colour (I've checked this in a hex editor). I made a local change which splits off the 32 bit case and adds an extra line:
The image now loads succesfully so it looks like a genuine bug. Can anyone confirm this?
http://rapidshare.com/#!download|616l34 ... stem.tga|1
I found a section of code in tga.c which looks wrong, namely in ReadTGAImage it does:
Code: Select all
case 24:
case 32:
{
/*
8 bits each of blue, green and red.
*/
pixel.blue=ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.green=ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.red=ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
break;
}
Code: Select all
pixel.opacity=ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));