Rotating

Rotating: Rotating is a little tricky. Basically you have to reverse the height and the width, but getting the pixels in the proper order can be a little bit of a brain twister. It's easiest to use embedded for loops: one which counts from 0 to the height and the other which counts from 0 to the width. Then you simply make your assignments like this:
   hold[x*h+y]=pixel[y*w+x];

Where x is the width counter and y is the height counter.

Flipping an Image
Flipping and Rotating Using Built in Method