Bitmap rotation

I remember bitmap rotation as a sort of holy grail of home computer graphics, even during Amiga days. It's possible that someone finally did figure out how to do it with the help of the blitter, but it would still be heavily dependent on optimized machine code and blitter programming.

Today's computers have a bit more processing power, and with the surprisingly high speed I managed to get from my fractal applets, I wanted to see what I could do in terms of bitmap rotation.

I found an excellent little article describing a straightforward algorithm by Karl Lager (see attachment) which I coded in Java, changing to integer (or really, fixed-point) arithmetic and moving all but one multiplication out of the inner loop. I put it all in a subclass of ImageIcon, since I expected to use it only for very small images.

Turned out it worked extremely well, even for very large full-colour bitmaps. You can check out the examples in the sidebar menu (or the list below).

You can find an example application on my Artifactory server, and a Maven artifact for the RotatableImageIcon is available there too.

Note that with today's optimizing compilers, changing multiplications into shifts like I did may not actually be the optimal way of coding. Often, the compiler will know better than you.

A fast algorithm for rotating bitmaps - Karl Lager3.67 KB