Jump to content
  • Advertisement

Archived

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

gimp

Flipping my image in a vector<>

This topic is 6452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!