I'm writing a tga parser in C++ for fun and now it can read files of imagetypes 2, 3, 10, but I'm stuck at type 1 where they have color map. I don't know how to convert color mapped colors to rgb or rgba. It seems like for an type 1 image (unencoded), if I have a char* color_map
, I should turn it to uint_8*
and if the color_map_entry_depth
is 24 and pixel_depth
is 8 and we have a uint8_t pixel_data[3]
taken from the file buffer, the first pixel color will be
RGB(color_map[pixel_data[2]],color_map[pixel_data[1],color_map[pixel_data[0]])
But it gives me wrong color. Could anybody help?