Hi!

I am trying to use the same technique for sprites that the Reptoids
sample code is using. It works well on a grayscale display, but shows
funny colors when two such images overlap on a color device.

Below is my code. width and height are the width and height of the
image, maskID and bitmapID are the IDs of bitmap families which contain
2bpp and 8bpp versions of the mask and the image.

Any help would be appreciated.

Cheers,
Tilo Christ


==================================
BITMAPFAMILY ID 2001 "" "bernard_mask.bmp" "" "bernard_mask.bmp"
BITMAPFAMILY ID 2000 "" "bernard2bpp.bmp" "" "bernard8bpp.bmp"
===================================

   UInt16 error;

   RectangleType bounds;
   bounds.topLeft.x = 0;
   bounds.topLeft.y = 0;
   bounds.extent.x = width;
   bounds.extent.y = height;

   WinHandle offScreenH = WinCreateOffscreenWindow(width, height,
screenFormat, &error);
   WinSetDrawWindow(offScreenH);

   {
    // Paint sprite-mask to offscreen window
    MemHandle resH = DmGetResource( bitmapRsc, maskID );
    ErrFatalDisplayIf( !resH, "Missing mask" );
    BitmapType* resP = (BitmapPtr)MemHandleLock(resH);

    WinDrawBitmap (resP, 0,0);

    MemPtrUnlock(resP);
    DmReleaseResource( resH );

    WinCopyRectangle(offScreenH, drawWindow, &bounds, x, y, winMask);
   }

   {
    // Paint sprite-overlay over the masked-out area
    MemHandle resH = DmGetResource( bitmapRsc, bitmapID );
    ErrFatalDisplayIf( !resH, "Missing bitmap" );
    BitmapType* resP = (BitmapPtr)MemHandleLock(resH);

    WinDrawBitmap (resP, 0,0);

    MemPtrUnlock(resP);
    DmReleaseResource( resH );

    WinCopyRectangle(offScreenH, drawWindow, &bounds, x, y, winOverlay);

   }

   WinSetDrawWindow(drawWindow);
   WinDeleteWindow(offScreenH, false);



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

Reply via email to