Path: utzoo!mnetor!uunet!husc6!rutgers!ames!ucbcad!zen!ucbvax!dewey.soe.berkeley.edu!oster
From: oster@dewey.soe.berkeley.edu (David Phillip Oster)
Newsgroups: comp.sys.mac
Subject: Re: image rotation
Message-ID: <22158@ucbvax.BERKELEY.EDU>
Date: 14 Dec 87 03:42:27 GMT
References: <600@analog.UUCP> <76000070@uiucdcsp>
Sender: usenet@ucbvax.BERKELEY.EDU
Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster)
Organization: School of Education, UC-Berkeley
Lines: 36

In article <76000070@uiucdcsp> gillies@uiucdcsp.cs.uiuc.edu writes:

>I think your analysis of the parallel bitblt algorithm is fallacious.
> [much deleted, check it, it is interesting]
You're posting shows the blind preference for elegance that I was critiquing
in my article. Think it through:

1.) Here is the analysis again:

The recursive version for rotating an NxN bitmap does O(log N) BitBlts
to rotate a bitmap by 90 degrees. (It does three BitBlts to interchange
quarters, then must recursively interchange those quarters all the way down.
Each recursive step takes another three BitBlts.)

In addition, the recursive algorithm
only works directly for squares that are a power of 2 on edge. (To
handle other sizes, you usually copy into an offscreen bitmap that is
large enough, rotate it, and copy the result back.)

The 8x8 transpose version does O(1) bitblt to rotate a bitmap by 90 degrees.
In addition, it works directly for any rectangle that has edges that are
a multiple of 8.


2.) by experiment.
I have actually coded up and run both versions. For a 256 by 256 bitmap,
the 8x8 transpose method was about 10 times faster than the recursive
CopyBits method. (And, I didn't even optimize the transpose method.)

The recursive method is elegant, but _slow_. The point of my article is that
the elegant algorithms you learn to appreciate in an algorithms class 
sometimes really _are_ worse than using brute force in the real world.

--- David Phillip Oster            --A Sun 3/60 makes a poor Macintosh II.
Arpa: oster@dewey.soe.berkeley.edu --A Macintosh II makes a poor Sun 3/60.
Uucp: {uwvax,decvax,ihnp4}!ucbvax!oster%dewey.soe.berkeley.edu