Hi everybody ^^

I'm quite a newbie in loading image file, so I've try to improve myself by loading the TGA image structure (You can found it at http://en.wikipedia.org/wiki/Truevision_TGA , I'm quite believe in the information there)

My problem is after loading and draw it onto the screen using OpenGL ES, it's seem the image lost some stuff of... color chanel... I don't know how to describe this exactly but would you like to see my work compared to esUtil's feature and give me some advices ?

As you can see... The beautiful image is the result I want (converted from TGA to png), and the "green sky" lies with the ground up is my... creation >"<...

TextureLoader.cpp

esUtil_TGA.c

Hi everybody ^^

I'm quite a newbie in loading image file, so I've try to improve myself by loading the TGA image structure (You can found it at http://en.wikipedia.org/wiki/Truevision_TGA, I'm quite believe in the information there)

My problem is after loading and draw it onto the screen using OpenGL ES, it's seem the image lost some stuff of... color chanel... I don't know how to describe this exactly but would you like to see my work compared to esUtil's feature and give me some advices ?

As you can see... The beautiful image is the result I want (converted from TGA to png), and the "green sky" lies with the ground up is my... creation >"<...

[ATTACH]22495[/ATTACH]

[ATTACH]22496[/ATTACH]

[ATTACH]22497[/ATTACH]

[ATTACH]22498[/ATTACH]

Try reading in binary mode by adding a "b". I'm guessing that's your problem.. the other two possibilities are that you're out of alignment when reading your bytes (i.e. if you didn't get the last byte of the header). Or that XOR thing isn't working--which seems a weird thing, but I don't have time to examine it closely. Let me know.. I'll bbl.

file = fopen(tgaName, "rb");

I've get last byte of the header but it 's seem... losing color chanel in other way :))
But... Amazing thing happened when I add two last bytes of the header to the front of my raw data : it worked !
Thank you for your advice, though I still want to know why we must add these bytes to our image data... All we have to do is just get all bytes in the "data" block of the TGA, don't we ?

I've get last byte of the header but it 's seem... losing color chanel in other way :))
But... Amazing thing happened when I add two last bytes of the header to the front of my raw data : it worked !
Thank you for your advice, though I still want to know why we must add these bytes to our image data... All we have to do is just get all bytes in the "data" block of the TGA, don't we ?

I *may* see the problem.

for (int i = 17 + skipSize; i < 17 + skipSize + datasize; i ++)

In order to skip the header portion, you would ignore 0 through 17. Meaning you would start at 18. Plus your skipsize. So if I'm right, when you added the last two bytes of the header to the front of your raw data, your first pixel is garbage since that's still part of the color map--you just didn't notice it because it alligned the rest of your raw data and the rest of the picture worked.