On November 16, 2002 05:31 pm, Aaron Ardiri wrote:
> pixel quadrupling :) the original demo is actually 40x40 :)

I did a very similar thing with my fractal demo - it's only rendering 1/2 of 
the screen.  Fact is, I made several versions of it that range from 1:1, 1:2, 
1:4, and 4:1 (anti-aliasing by rendering subpixels).  The 4:1 got really, 
really slow even on a damn fast desktop machine w/ the emulator, so I 
eventually went with 1:2.  My routine went something like this:

screen = (MemPtr)WinScreenLock(NULL);
WinScreenUnlock();

for each pixel on the screen (0..160 x 0..160)
  calculate color (0-255 greyscale)
  PutPixel ( screen, x/2, y/2, color )
end

inline void PutPixel ( UInt8 *bmp, UInt8 x, UInt8 y, UInt8 c ) {
  if ( (x<SCREEN_W) && (y<SCREEN_W) ) {
    if ( bmp[(y<<5)+(y<<7)+x] == 0 ) {
      bmp[(y<<5)+(y<<7)+x] = c;
    } else { // remove this if you don't want to average
      // the following is slow, but allows "anti-aliasing"
      bmp[(y<<5)+(y<<7)+x] = (bmp[(y<<5)+(y<<7)+x] + c)>>1;
    }
  }
}

-- 
Matthew (Darkstorm) Bevan       [EMAIL PROTECTED]
Margin Software, NECTI.         http://www.marginsoftware.com
        Re-inventing the wheel, every time.

 - Pascal Users:
        To show respect for the 313th anniversary (tomorrow) of the
death of Blaise Pascal, your programs will be run at half speed.


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to