Hi,

I would like to be able to create a bitmap dynamically - in some
cases it will be a bitmap on a form, in other cases it will be a
bitmap to be used in a graphic button.  For now, I'm just trying to
get the form bitmap to work.

I am creating the bitmap, using Win draw functions to draw the
bitmap, then storing it in my own resource database, and attempting a
FrmNewBitmap.  Unfortunately, nothing is showing up.  I was hoping
that someone might tell me where I'm going astray.

Ugly code below... I know this is not how you would normally do this.
(It is just a test for now.) Also, there is a FrmDrawForm call
following this function.

static const UInt32 kDBType = 'data';
DmOpenRef bm_dbR;      // reference to bitmap database

void DynWidgetTest ()
{
  BitmapType *bmpP;
  FormPtr     frmP;
  WinHandle   win;
  Err         error;
  MemHandle   bmH;     // handle to bitmap
  RectangleType onScreenRect;

  // making a simple b&w (depth=1) bitmap
  bmpP = BmpCreate(10, 10, 1, NULL, &error);
  if (bmpP) {
    win = WinCreateBitmapWindow(bmpP, &error);
    if (win) {
      WinSetDrawWindow(win);
      WinDrawPixel (1,1);
      WinDrawPixel (2,2);
      WinDrawPixel (3,3);
      WinDrawPixel (4,4);
      WinDrawPixel (4,6);
      WinDrawPixel (3,7);
      WinDrawPixel (2,8);
      WinDrawPixel (1,9);

      // is this proper use of WinSetBounds? is this nec?
      onScreenRect.topLeft.x = 0;
      onScreenRect.topLeft.y = 0;
      onScreenRect.extent.x = 9;
      onScreenRect.extent.y = 9;
      WinSetBounds(win, &onScreenRect);

      // for now... create a resource db
      error = DmCreateDatabase (0, "PB",
                                MY_FILE_CREATOR, kDBType, true);
      if (!error) {
        // now open the db
        bm_dbR = DmOpenDatabaseByTypeCreator (kDBType,
                      MY_FILE_CREATOR,
                      dmModeReadWrite);

        // did it open?
        if (bm_dbR) {
          // now store the bitmap in the resource db
          bmH = DmNewResource (bm_dbR, 'Tbmp', 3333, BmpSize(bmpP));
          if (bmH) {
            // draw it on the current form
            frmP = FrmGetActiveForm();
            // Not so sure about these parameters ... esp. the first 3333
            FrmNewBitmap(&frmP, 3333, 3333, 50, 100);
           }
    ... more below ... releasing resources .. closing db...and displaying 
form


I'm really uncertain about the FrmNewBitmap call. I don't know if the
first index parameter is correct - or what it should be.  I'm also uneasy 
with the WinSetBounds.  Is there another (and better) way to do this?

Thanks for any help,
Ellen




_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.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