Flipping my image in a vector<>

Started by
1 comment, last by gimp 23 years, 3 months ago
I load my images(bmp,tga etc) in to STL vectors. I just realised however that my entire image is inverted. Can anyone think of the ''best'' way to flip it? My current idea is to : Create a temp vector equal to a row''s length(image width). Copy row one in to that Copy row 600 in to one Restore temp to row 600. (Repeat until we meet in the middle) Is that about right? Or is there a more STL''ish and nicer way of doing this...
Chris Brodie
Advertisement
ok, i dont know about STL vectors, but i have an idea for you. why you dont load directly the first line of the file into the last vector, rather than load it into the first vector, and then flip them...

cyberg
cyberg- cyberg_coder@hotmail.com- http://members.xoom.com/cybergsoft
Yeah. Essentially, you are looking at it the wrong way. If your images are being loaded in upside down or from back to front, you should just alter the loading routine so it loads them the right way up. This will just be the case of changing a couple of loops.

But the actual answer to your question, in case you ever have a more legitimate need to use it, is this:

reverse(vector.begin(), vector.end());

(you may need to #include <algorithm>.)

Edited by - Kylotan on January 19, 2001 7:44:32 PM

This topic is closed to new replies.

Advertisement