FAST anti-aliased general image rotation!


There is an article in Graphics Gems 1 which gives an algorithm for applying a rotation-only transformation matrix to an image, using an algorithm that is not only the fastest possible, but also provides anti-aliasing in a natural efficient manner that leverages the algorithm.

The article is in Graphics Gems I, here’s the bibliographical entry:
Paeth, Alan W., A Fast Algorithm for General Raster Rotation, Graphics Gems, p. 179-195.

If you want to read the original article for free, has the entire book available for preview. It starts on page 179: … 0122861663

Unfortunately, the source code is missing, but if you can implement a simple function to apply a fractional shear to a single row or column of pixels, you can make this work.

If the Juce GraphicsSoftwareRenderer is not already using this technique for applying rotation-only transforms to images, it will get a very nice performance boost from using it!

This is particularly handy for those people who want to have animated rotating objects in their interface.


Nice!!! this is great stuff.

Vinn - man, you’re a machine.


Well hey…I didn’t develop the algorithm…LOL…its just back in 1992 when I started my first computer job (working on Canvas at Deneba Systems) I read all the Graphics Gems and I did a lot of work with pixel processing.

But thanks :slight_smile:


In case it’s the Mac’s spinning progress indicator that you have in mind, or similar stuff, that would be a lot simpler to implement with a series of 8-12 small images rather than true image rotation computed in real time. For synth knobs and other skinned UI elements, I would also rather use prerendered images (if at all necessary).

It would however be cool to render the images once and then cache them during runtime :wink: Makes for a very easily skinnable application.


If you need some code:

It’s a good idea, but it’s the kind of code I’m reluctant to use since there are many corner cases that cause a lot of “if angle is < this and > that”, on top of the function, so many codepaths to tests etc.
Anyway, I’m almost sure this kind of optimization is actually implemented in OpenGL software rendering (and probably in GPU based rendering), so you can have it for free, provided you use OpenGL as the rendering primitive.


I was thinking more along the lines of user-content. For example, an album thumbnail that “spins” up to full screen size when touched.