I've attached example code that shows the problem.
Put this into Starter.c in a new CW stationary program and
call DrawBullet() in the Event handler.  Fails on 3.5 en-ez and en-nonenz
ROMs
Works on en-color ROM.  Seems like I must have missed some doc about
proper handling of bitmap/color depth issues.

-- Chuck
---------------------------------------------------------------
static
BitmapType* createBitmap(UInt16 height, UInt16 width,
                         UInt8 depth, UInt8 rowBytes,
                         void* data)
{
  BitmapType* bitmap = NULL;

  // First, determine the size of the data.
 UInt32 image_byte_count = height * rowBytes;
  UInt32 bitmap_datalen = bitmap_datalen = sizeof(BitmapType) +
image_byte_count;
  void* image_data = NULL;

  // Second, allocate space
 bitmap = (BitmapType*) MemPtrNew(bitmap_datalen);
 MemSet(bitmap, bitmap_datalen, 0);

  // Third, fill in the header
  bitmap->width = width;
  bitmap->height = height;
  bitmap->rowBytes = rowBytes;
  file://bitmap->flags = 0;    // leave empty
  bitmap->pixelSize = depth;
  bitmap->version = 2;
  bitmap->nextDepthOffset = 0;  // only one bitmap, not a family
  bitmap->transparentIndex = 0;
  bitmap->compressionType = BitmapCompressionTypeNone;
  bitmap->reserved = 0;  // leave empty

  // Finally, copy the image data
  image_data = BmpGetBits(bitmap);
  MemMove(image_data, data, image_byte_count);
  return bitmap;
}

static const UInt8 Bullet[] = {
    0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff };

void DrawBullet(UInt16 x, UInt16 y)
{
  BitmapType *pBitmap;
   pBitmap = createBitmap(8,8,1,1, (void*)Bullet);
  WinSetDrawWindow(WinGetDisplayWindow());
  WinPushDrawState();
  WinSetForeColor(UIColorGetTableEntryIndex(UIFieldBackground));
  WinSetBackColor(UIColorGetTableEntryIndex(UIObjectForeground));
 WinDrawBitmap(pBitmap, x, y);
  WinPopDrawState();
 }
----------------------------------------------------------------------------
------
"Chuck Ingold" <[EMAIL PROTECTED]> wrote in message
news:63451@palm-dev-forum...
>
> Hi all,
>
> I have a problem similar to the Capturing Signatures thread, namely trying
> to allocate and initialize a BitmapType for display by WinDrawBitmap().
> I have a network app which has received the bitmap data.  The conversion
> function seems to be fine running on the 3.5 en-color ROM, but when I run
it
> on the 3.5 en-ez ROM, I get an error accessing a multibyte value at an odd
> address.  The troublesome address is N+1 where N is the address of the
image
> data.
>
> What I want to know is what is different between the ROMs, and how am I
> supposed to handle it?
> My attempts to search for this information produce either Constructor docs
> or the pre-3.5 code for the Singature sample.  Is the unsupported part of
> Signature getting the bits from the screen or using the bits in a bitmap
by
> copying them to the location after the [BitmapType + optional ColorTable]?
>
> Thanks,
>
> Chuck
>
>
>
>



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

Reply via email to