The bitmap is a pointer to bitmap data that was generated from our jpeg lib.

But to ensure that this is a valid bitmap, if I call WinDrawBitmap on the
source data, it's a valid bitmap.
Here is what I'm doing: - I simplified the code to use records instead of
resources

    UInt32 cbMem = ((UInt32)uiBmpRowBytes * (UInt32)cinfo.image_height);
    Err err = errNone;
    err = DmCreateDatabase( 0, "tcBitmaps", 'town', 'cach', false );
    LocalID idDbCache = DmFindDatabase( 0, "tcBitmaps" );
    DmOpenRef rDbCache = DmOpenDatabase( 0, idDbCache, dmModeReadWrite );

    MemHandle hRecBmp = NULL;
    MemPtr  pRecBmp = NULL;
    UInt16  bmpRecIndex = dmMaxRecordIndex;

    hRecBmp = DmNewRecord( rDbCache, &bmpRecIndex, cbMem );
    pRecBmp = MemHandleLock( hRecBmp );
    err = DmWrite( pRecBmp, 0, pBmp, cbMem );
    MemHandleUnlock( hRecBmp );
    err = DmReleaseRecord( rDbCache, bmpRecIndex, false );

    hRecBmp = DmGetRecord( rDbCache, bmpRecIndex );
    BitmapPtr bitmap = (BitmapPtr)MemHandleLock(hRecBmp);

Now if I call WinDrawBitmap on "bitmap" I get garbage.
If I call WinDrawBitmap on "pBmp" (the one used in DmWrite) - I get a clean
bitmap image.


Do you see anything that I may be doing wrong here?
Note that what's missing is the last  two lines of code (after the
WinDrawBitmap)

    MemHandleUnlock( hRecBmp );
    DmReleaseRecord( rDbCache, bmpRecIndex, false );

Any Ideas?

Thanks - bill


"Ben Combee" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> At 01:52 PM 1/29/2004, Fruber Malcome wrote:
> >calling this function, seems to give me a bad bitmap.
> >
> >I'll provide some additional insight:
> >If I call WinDrawBitmap on the pBmp, I get a perfect image.
> >
> >If I do the following:
> >MemHandle resH = NULL;
> >resH = DmGetResource( 'Tbmp', 501 );
> >BitmapPtr bitmap = (BitmapPtr)MemHandleLock(resH);
> >
> >Then call WinDrawBitmap on the bitmap - I get garbage.
> >
> >Also - is there no other way to load a resource rather than calling the
> >above function that performs the unecessary process of searching resource
> >databases for the bitmap rather than use one that I know is correct?
>
> DmGetResource1 will only search the topmost database.
>
> This should work, but its likely that you aren't saving the bitmap to your
> record/resource appropriately.  Is the bitmap coming from PilRC or another
> resource compiler?  If not, is it being saved from your app?  When you
save
> your bitmap to a resource, do you write your own bitmap header and then
> copy the bits?  Did you follow the examples in the BitmapRsc code from the
> palmsource Knowledgebase?  Have you tried exporting your resource DB from
> PalmSim or POSE and then viewing it with PRC Explorer?
>
>
> -- 
> Ben Combee <[EMAIL PROTECTED]>
> CodeWarrior for Palm OS technical lead
> Palm OS programming help @ www.palmoswerks.com
>
>



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

Reply via email to