rotate a frame buffer

I'm using an Embedded Artists development board for a ARM 9 processor (LPC3250).  The development board includes a simple 320 x 240 screen. I need to rotate everything on the screen 180 degrees.  Contacting the vendor there's no support in their driver for rotating, so it's left up to the user.

During setup of the display, you setup a frame buffer where 2 bytes is used to describe each pixel. The API has basic capability like write a line, box, text, etc.  The provided driver updates the screen by dereferencing the desired pixel address in the frame buffer and setting it equal to a 16 bit color. (this is the lpc swim library if that means much to someone)

*(framebuffer + offset) = pen_color;

Any suggestions on how to rotate the what is being displayed before ever writing it to the frame buffer?

I have plenty of memory and can create a second intermediate frame buffer if needed.
Who is Participating?
Infinity08Connect With a Mentor Commented:
Rotating over 180 degrees would mean that you place the pixel color for position (x, y) at (framebuffer + (319 - x) + ((239 - y) * 320)) instead of (framebuffer + x + (y * 320)) for every position (x, y) between (0, 0) and (319, 239).

So, it's just a matter of calculating the offset differently.

The use of an intermediate frame buffer, as you suggest, will greatly help with that.
JohnSantaFeAuthor Commented:
That was exactly it. Thanks for the pointer.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.