Hi everyone,

I have a Scratch Pad kind of a application written in CW which writes a
on-screen bitmap (user drawn) to a seperate resource file and later on read
from the file and display it.

My app works fine in OS 4 and under and it has been using for long without
any any issue.

But the app does not work ok in OS 5. When it tries to display the bitmap
resource the simulator crashes or the Tungsrten T displays a junk bitmap
(distorted set of pixels).

Although the error is given when displaying the resource, AFAIK the
"DrawBitmap" proceudre is ok since I use the same proceudre to display some
other bitmaps created by the CW constructor.

Another thing I tried is that I have created the bitmap resource file from a
OS 4 dedvice and then beamed the file to the Tungsten. The Tungsten
displayed this bitmap without any problems, but once i change it in Tugsten
and save it, the Tungsten could not display the bitmap next time.

I guess this shows that the problem is with the save in OS 5, not the
display.

Following is the code i have used for it. Any help in this is greatly
appriciated
.

Code for displaying the bitmap resource
===========================

//... open the resource file in dmModeReadOnly mode
DrawBitmap (0, x, y);
//... close the resource file

where DrawBitmap is
void DrawBitmap(Int16 resID, Int16 x, Int16 y)
{
   MemHandle resH;
   BitmapPtr resP;
   resH = DmGetResource(bitmapRsc, resID);
   ErrFatalDisplayIf( !resH, "Missing bitmap" );
   resP = (BitmapType*)MemHandleLock(resH);
   WinDrawBitmap (resP, x, y);
   MemPtrUnlock(resP);
   DmReleaseResource( resH );
}

Code for writing the bitmap resource
=========================
BitmapType *wowScratchBitmapP, *resBitmapP;
...
WinHandle saveWinH = WinSaveBits ( &bounds , &err );
....
wowScratchBitmapP = WinGetBitmap ( saveWinH );
...
 // open/create database to save
....
// if resource already exist remove it using DmRemoveResource
...
 resH = DmNewResource (dbScratchRef, bitmapRsc, resID, BmpSize
(wowScratchBitmapP) );
...
 resBitmapP = (BitmapType*) MemHandleLock (resH);
 DmWrite ( resBitmapP, 0, wowScratchBitmapP, BmpSize (wowScratchBitmapP) );
 MemHandleUnlock (resH);
 DmReleaseResource (resH);

 WinRestoreBits( saveWinH , SCR_WOW_ACTIVE_X, SCR_WOW_ACTIVE_Y);

// close database


_DNR



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

Reply via email to