Hi all,
I'm quite new to PalmOS programming and REALLY need help figuring out why I
can't open and draw a bitmap resource from a PRC that I generate via PilRC
and Par. I can find and open the PRC DB just fine... but I always get NULL
when I try to get a handle to the bitmap resource that I HOPE is inside it.
I've included a step by step of how I attempted to go about this whole
process. If anyone could find errors or give me pointers on how to more
effectively achieve this (especially via email if possible), I would be
quite thankful.
Additionally... if someone could tell me they've successfully done what I'm
trying to do with PalmOS 3.5... that would give me some hope.
The Process
-------------------
1. Create/save some 8 bit windows BMP files in Photoshop
2. Create/save a new PilRC resource file and name it "whatever.rcp"
3. Add lines within this file that represent the bitmaps to be created
example (2 BMPs for a 2-state button):
BITMAPCOLOR 2000 "bn_up.bmp"
BITMAPCOLOR 2100 "bn_down.bmp"
4. Open a DOS window and run PilRC with a command line that contains the
aforementioned .rcp file and an existing output dir for any resource files
it will create
example:
pilrc whatever.rcp ..\par\graphics
5. Verify that there were 2 binary graphic files created by PilRC
6. In the DOS window, run Par and feed it a command line containing 'c' so
it creates a PRC, a filename, the PRC name that the device will recognize,
the PRC type, my app's creator, and finally.. a directory where the files
are that I want in the PRC
NOTE - In the example below... I'd love to add the -a attributes that would
set the backup bit and the resource bit... but Par always seems to complain
about "Invalid attribute specification" when I try that
example:
par c myPRC.prc myPRC DATA triV .\graphics\*.bin
7. Verify that a PRC file was created by Par
8. Drag this PRC file onto the running POSE application to install it
9. Attempt to find and open the PRC... and access one of the BMPs from C
code within my app:
DmOpenRef s_dbRef;
UInt16 cardNo = 0;
Err theErr = 0;
LocalID dbID = 0;
UInt16 dbAttrs;
BitmapPtr theBMPPtr;
MemHandle theBMPHandle;
UInt16 recordindex = 0;
dbID = DmFindDatabase( cardNo, "myPRC" );
if( dbID )
s_dbRef = DmOpenDatabase( cardNo, dbID, dmModeReadOnly );
// attempt to make it a resource DB since Par complains when trying
// to do it via the command line
DmOpenDatabaseInfo( s_dbRef, &dbID, NULL, NULL, &cardNo, NULL );
DmDatabaseInfo( cardNo, dbID, NULL, &dbAttrs, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
dbAttrs |= dmHdrAttrResDB;
DmSetDatabaseInfo( cardNo, dbID, NULL, &dbAttrs, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
// just for kicks... see which index we think our resource is at
recordindex = DmFindResource( s_dbRef, bitmapRsc, 2000, NULL );
// try to get a handle to one of our BMP resources
// ****** this is ALWAYS returning NULL ******
theBMPHandle = DmGetResource( bitmapRsc, 2000 );
theErr = DmGetLastErr();
// draw it if we got it...
if( theBMPHandle )
{
theBMPPtr = (BitmapType *)MemHandleLock( theBMPHandle ) ;
WinDrawBitmap( theBMPPtr, 10, 50 );
MemHandleUnlock( theBMPHandle );
DmReleaseResource( theBMPHandle );
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/