News for hackers. Stuff that matters.
Re:Rotating Images by anonymous on Saturday August 17, 2013 @11:40AM (#6229365)
Wouldn't the 3 shears method take a preposterous¹ amount of memory if you rotate by something like 180 degrees? The first shear will take a w.h image and output a w.h.h one!

Why not simply use Bresenham's line drawing algorithm to "draw" a reverse-rotated rectangle over your image, but rather than drawing, you'd read pixels and write them to the destination image. You'll need to only rotate the corners of the image once and everything else is simple integer math.

¹ preposterous for the kind of device where doing it any other way is too slow

Edit: replaced stars with dots for multiplication because stars make italic text

Re:Rotating Images by pwg on Saturday August 17, 2013 @12:00PM (#6229419)
> Wouldn't the 3 shears method take a preposterous¹ amount of memory if you rotate by something like 180 degrees? The first shear will take a w.h image and output a w.h.h one!

If implemented as a three pass algorithm, yes.

If implemented as a one pass algorithm, no.

Re:Rotating Images by CamperBob2 on Saturday August 17, 2013 @09:25PM (#6231177)
Why not simply use Bresenham's line drawing algorithm to "draw" a reverse-rotated rectangle over your image, but rather than drawing, you'd read pixels and write them to the destination image. You'll need to only rotate the corners of the image once and everything else is simple integer math.

Trivia: this is how Wing Commander worked. Nobody was concerned about filtering or gamma correction in those days, needless to say!

Bresenham point-sampling is an example of a 'forward transform', where you look at each pixel in the source image and decide where it goes in the destination image. You can also use conventional texture mapping to rotate an image, which is a case of an 'inverse transform' where you traverse each pixel in the destination image and figure out what texel(s) contribute to it.

Inverse transforms are much simpler -- Bresenham sampling has some ugly complexities, especially if you want to scale the image as well as rotate it -- but they aren't as efficient if the image has a lot of transparency.

Re:Rotating Images by marshray on Sunday August 18, 2013 @04:38AM (#6232117)
Clearly there are better ways to rotate by 180 degrees!

If you need to rotate by 179, first rotate by 180, then by -1.