Jump to content
  • Advertisement


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


Rotating a buffer

This topic is 6268 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

Hi, I know this may sound a bit silly (there is a better way of doing it, I just don''t understand it enough to trust it but my program loads an 480x640 image into a UCHAR buffer, and I want to display it on the screen (which is 640x480). If I use memcpy to just copy the data from one buffer to the active surface, the result (naturally) is a really screwed-up image. How would I go about "rotating" the data in the buffer 90-degrees clockwise?

Share this post

Link to post
Share on other sites
To clarify things a bit:-

My source image is 480x640.
It is stored in a 307,200 byte buffer.
My destination image (the screen) is 640x480.
It is stored in buffer of the same size as the stored image (when it is locked).
I wish to move the pixels around in the buffer like thus:-
(0, 0) -> (639, 0)
(479, 0) -> (639, 479)
(479, 639) -> (0, 479)
(0, 639) -> (0, 0)

In terms of byte values:-

0 -> 639
479 -> 307199
307199 -> 306560
306720 -> 0

Is there a simple alogrithm with which this can be done?
Failing that, is there a way to read in data from a file "vertically" (this would eliminate the need for me to transform it in memory)?

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!