it has been clarified. For 16-bit bitmaps, the value is a RGB565 value, i.e.Ben,
(red (0..31) << 11) | (green (0..63) << 5) | (blue (0.31))
I'm glad they clarified this.
Thanks for your help.
Unfortunately, it appears that BmpGlueSetTransparentValue/BmpSetTransparentValue simply does not work with 16-bit bitmaps, regardless of what the latest documentation says.
Under the OS 5 Palm and Sony simulators, I can't even get them to work passing in 0 (for black).
Also, BmpGlueGetTransparentValue/BmpGetTransparentValue always return 0 for 16-bit bitmaps.
Fortunately the functions in Palm's "BitmapRsrcDR1" High Density Bitmaps example do seem to work.
Not difficult, but it'd be nice if I hadn't wasted a day trying to get the API calls working. grr.
Code using the API (which doesn't work):
// Get my 16x16x16 bitmap, which has some black, some white and a few other colors
Handle imageH = (Handle)DmGetResource('Tbmp', 2200);
BitmapPtr imageP = (BitmapPtr)MemHandleLock(imageH);
// Create a new bitmap and copy the resource bitmap to it
UInt16 err;
BitmapType *newBmp = BmpCreate (16, 16, 16, NULL,&err);
UInt16* oldBits = (UInt16*)BmpGetBits(imageP);
UInt16* newBits = (UInt16*)BmpGetBits(newBmp);
MemMove(BmpGetBits(newBmp), BmpGetBits(imageP), BmpBitsSize(newBmp));
// Set the transparency on the new bitmap and draw that puppy
UInt32 color = 0; // even black doesn't work on OS 5!
BmpGlueSetTransparentValue (newBmp, color);
WinDrawBitmap(newBmp,50,50); // On OS 5, this will be drawn but without black being transparent.
Code using Palm's BitmapRsrc functions (this works):
Handle imageH = (Handle)DmGetResource('Tbmp', 2200);
BitmapPtr imageP = (BitmapPtr)MemHandleLock(imageH);
UInt16 err;
BmpRsrcType* newBmp=BmpRsrcV2Create(16, 16, 16, NULL,NULL);
UInt16* oldBits = (UInt16*)BmpGetBits(imageP);
UInt16* newBits = (UInt16*)BmpGetBits((BitmapType*)newBmp);
BmpRsrcSetFlag(newBmp, kHasTransparencyFlag, 1);
BmpRsrcSetTransparentValue(newBmp, 65535); // white
WinDrawBitmap((BitmapType*)newBmp,50,50);
--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
