Path: utzoo!mnetor!uunet!husc6!bbn!uwmcsd1!ig!jade!ucbvax!hplabs!analog!kim
From: kim@analog.UUCP (Kim Helliwell)
Newsgroups: comp.sys.mac
Subject: image rotation
Message-ID: <600@analog.UUCP>
Date: 11 Dec 87 01:22:41 GMT
Organization: Analog Design Tools, Menlo Park, CA
Lines: 36
Keywords: CopyBits rotation bitmap MacTutor blitter



I am interested in any information anyone may have on algorithms for
rotating bitmaps by +/- 90 degrees.

I am aware of two-- the obvious brute-force method of grabbing a pixel
and swapping indices (with an appropriate translation) before stuffing
it into another bitmap, and the parallel blitter version which was
described in an issue of MacTutor a couple of years ago.

I have been thinking about the relative speeds of these two, and I have
come up with the following analysis of the relative speeds:

	the brute force method obviously goes as n*n, where n is the
	number of pixels on a side of the bitmap.

	the blitter version actually goes as n*n*log(n), because the
	log(n) steps required and the n*n memory read/writes required
	by the blitting operation.

The log() means log base two, of course.  What this tells me is that the
blitter version is only a win if you have a hardware blitter (with 
lots of parallism, for example, and DMA).  For use with CopyBits, it
appears to be a lab curiosity.  Or is there something I am missing?

In any case, I have tried both methods, and neither of them are anywhere
close to as fast as MacPaint.  I am interested in speeding things up, and
want to know if anyone knows how to do things faster?  I admit that I haven't
done much to optimize things to date.  Would doing the thing in straight
assembly code be the only thing I need to do to speed it up? (I am writing
it in C at present).  Or is there something really clever that Paint does?

Any leads or help will be appreciated.

Kim Helliwell
hplabs!analog!kim