#### Archived

This topic is now archived and is closed to further replies.

# How to inverse the origin of a TGA file (flip it upside down)?

## Recommended Posts

Viscous-Flow    122
Hello, I have tried to flip a TGA upside down, but I can''t get it to work. I essentially do something like this:
  unsigned char t; for (int z = 0, y = tgaImageSize-1; z < tgaImageSize; z++, y--) { t = tgaImageData[y]; tgaImageData[y] = tgaImageData[z]; tgaImageData[z] = t; } 
It just displays the texture as it looked before I did this. Any help would be greatly appreciated!

##### Share on other sites
Null and Void    1088
From my engine:
 ` void rRawInfo::FlipVert(void) { rByte *Buffer; unsigned int a, b, c, d; b = Width*BytesPP; c = Height/2; Buffer = (rByte *) malloc(b); for(a=0; a

It''s not super-optimized, but it works for me. I don''t load too many targas or bitmaps anyway, I use my own image format that has them up right by default.

[Resist Windows XP''s Invasive Production Activation Technology!]

##### Share on other sites
Viscous-Flow    122
Thanks Again!

##### Share on other sites
Null and Void    1088
Wow, never realized how much code from the C-version of my engine was still in the new version, heh. I'll have to replace that malloc with new now . 3 posts in one thread before a response, heh...

[EDIT: I guess you did respond in time ]

[Resist Windows XP's Invasive Production Activation Technology!]

Edited by - Null and Void on October 18, 2001 8:52:44 PM