Oops, sorry about that. My newsreader got away from me before I was
finished. :) Here is the code:

-- PILRC SAMPLE --

BITMAPFAMILYEX ID BMF_TestBitmap
BEGIN
  BITMAP "bmp1_Test.bmp"   BPP 1 DENSITY 1
  BITMAP "bmp1dd_Test.bmp" BPP 1 DENSITY 2
END

-- CODE SAMPLE --

MemHandle     resH;
BitmapType    *resP;
BitmapType    *bmpP;
BitmapTypeV3  *bmpV3;
Err           error;
WinHandle     winH;
RectangleType rect;

// Create a 1-bit high-density bitmap and offscreen window.
bmpP  = BmpCreate(40, 40, 1, NULL, &error);
bmpV3 = BmpCreateBitmapV3(bmpP, kDensityDouble, BmpGetBits(bmpP), NULL);
winH  = WinCreateBitmapWindow((BitmapType*)bmpV3, &error);

// Draw a resource bitmap onto the new offscreen window.
WinSetDrawWindow(winH);
resH = DmGetResource(bitmapRsc, BMF_TestBitmap);
resP = MemHandleLock(resH);
WinDrawBitmap(resP, 0, 0);
MemPtrUnlock(resP);
DmReleaseResource(resH);

// Draw a diagonal line across the offscreen window.
WinDrawLine(0, 0, 20, 20);

// Copy the offscreen window to the screen.
RctSetRectangle(&rect, 0, 0, 20, 20);
WinCopyRectangle(winH, WinGetDisplayWindow(), &rect, 0, 0, winPaint);

// Delete the offscreen window and bitmaps.
WinDeleteWindow(winH, false);
BmpDelete(bmpP);
BmpDelete((BitmapType*)bmpV3);

-- END CODE SAMPLE --


What I get with this sample is a corrupted image from the WinDrawBitmap
code. I put the code to draw the diagonal line on the offscreen window to
check if there was a problem with the WinCopyRectangle from the offscreen
window to the screen, but the diagonal line displays perfectly over the
corrupted bitmap image as expected.

My understanding is that you should be able to create an offscreen window in
this manner and draw to it from a resource bitmap. In fact, this code works
without trouble if the bitmap used to create the window is created as 8-bit
or 16-bit. It works as is if you put the Palm Simulator in 1-bit display
mode, and it works if you create the V3 bitmap as kDensityLow. Also, with
8-bit and 16-bit resource bitmaps on 16-bit high-density offscreen windows,
this method works fine. But creating a 1-bit high-density offscreen window
and then drawing a 1-bit resource bitmap to it doesn't seem to work for me.

I'm sure I'm staring right at the answer, but after hours of looking through
the docs and my code, I just can't see it. :) Does anyone have any ideas
about what I'm doing wrong here?

-Tom Cain



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

Reply via email to