Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!agate!shelby!helens!relgyro!mike From: mike@relgyro.stanford.edu (Mike Macgirvin) Newsgroups: comp.graphics Subject: Re: Wanted: Bitmap rotation algorithm Message-ID: <230@helens.Stanford.EDU> Date: 12 Jun 89 17:06:27 GMT References: <8.UUL1.2#261@persoft.UUCP> Sender: news@helens.STANFORD.EDU Reply-To: mike@relgyro.STANFORD.EDU (Mike Macgirvin) Organization: Stanford Relativity Gyro Experiment (GP-B) Lines: 41 In article <8.UUL1.2#261@persoft.UUCP> ericf@persoft.UUCP (Eric R. Feigenson) writes: >I am look for any and all algorithms relating to rotating a bitmap an >aribtrary amount. Efficiency and accuracy (minimal distortion) are, >of course, important considerations. An English or pseudo-code #include #define radians(angle) ((angle) / 5.729578E+01) #define HEIGHT some_integer_number #define WIDTH some_integer_number unsigned char image[WIDTH][HEIGHT]; rotate(angle) double angle; /* rotate image 'angle' degrees */ { int color; int xx,yy; for(y = 0;y < HEIGHT; y ++) for(x = 0;x < WIDTH; x ++) { color = image[xx][yy]; xx = (x * cos(radians(angle)) - (y * sin(radians(angle)); yy = (x * sin(radians(angle)) + (y * cos(radians(angle)); setpixel(xx,yy,color); } } There are some 'holes' in an image using this method at angles which are not right angles. I have experimented with methods that set surrounding pixels to the same value (and covering some of them over later with real values) to eliminate the 'holes', but have had limited success. ------------------------------------------------------- "There must be some kind of way out of here." Mike Macgirvin - mike@relgyro.stanford.edu (36.64.0.50) -------------------------------------------------------