> > That actually happened but I ended up doing this before the form is 
> > loaded so it works if I simply delete a bitmap resource and copy 
> > another into its place.
> 
> so, it was an issue at one point :)

Sort of.

> i am not sure what this problem may be then - maybe more sample code or
> doing a little demo to demonstrate the issue (in full) is at order to 
> get more investigation in place.

Here is some test code that I run before the form is drawn.

static void Fred2(void)
{
   BitmapPtr pBitmap;
   WinHandle hWin;
   WinHandle hScreen;
   Err error;
   // RectangleType onScreenRect;

   pBitmap = BmpCreate(30, 30, 8, NULL, &error);
   if(pBitmap) {
      hWin = WinCreateBitmapWindow(pBitmap, &error);
      if(hWin) {
         hScreen = WinSetDrawWindow(hWin);
         WinSetForeColor(113);  // some sort of red
         WinDrawLine(0, 0, 10, 10);
         WinSetDrawWindow(hScreen);
         WinDeleteWindow(hWin, false);
      }
   }
   WinDrawBitmap(pBitmap, 0, 0);  // bitmap actually shows up on the screen
   SysFatalAlert("wait to view bitmap");
   Fred3(pBitmap);
   BmpDelete(pBitmap);
}


static void Fred3(BitmapPtr pCreatedBitmap)
{
   DmOpenRef dbApp;
   UInt16 index;
   MemHandle hRes;
   UInt32 createdBitmapSize;
   MemHandle hNewBitmap;
   BitmapPtr pNewBitmap;
   Err err;

   // open application database
   dbApp = DmOpenDatabaseByTypeCreator(APP_TYPE, APP_ID, dmModeReadWrite);

   // find and delete existing bitmap resource
   hRes = DmGet1Resource(bitmapRsc, bitmapID_colors);
   if(hRes) {
      index = DmFindResource(dbApp, bitmapRsc, bitmapID_colors, hRes);
      DmRemoveResource(dbApp, index);
   }

   // create new bitmap resource
   BmpGetSizes(pCreatedBitmap, &createdBitmapSize, NULL);
   hNewBitmap = DmNewResource(dbApp, bitmapRsc, bitmapID_colors,
                              createdBitmapSize);
   pNewBitmap = MemHandleLock(hNewBitmap);
   err = DmWrite(pNewBitmap, 0, BmpGetBits(pCreatedBitmap), createdBitmapSize);
   if(err != 0)
      SysFatalAlert("ERROR");
   MemHandleUnlock(hNewBitmap);
   DmReleaseResource(hNewBitmap);

   // close application database
   DmCloseDatabase(dbApp);
}

> i'm sure you'll figure it out and let us all know ;)

Yep.

> PS: any reason why you are not drawing the bitmap manually? :)
>     that is what i would have done (after driving myself mad)

Yes.  My application displays a large number of colors and whenever the form
needs to be updated it has to for a FrmDrawForm.  That will make the screen
blink.  I figured that I could avoid the screen blink by using this resource
technique.  Also, I just want to know how to do it.

It looks as if I am real close. I'm guessing that the following lines from
Fred3() may be the problem:

   BmpGetSizes(pCreatedBitmap, &createdBitmapSize, NULL);
   hNewBitmap = DmNewResource(dbApp, bitmapRsc, bitmapID_colors,
                              createdBitmapSize);
   pNewBitmap = MemHandleLock(hNewBitmap);
   err = DmWrite(pNewBitmap, 0, BmpGetBits(pCreatedBitmap), createdBitmapSize);

Thanks,

Mike

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.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