Hello!
I had some problems when implementing High Density API in an application
that previously was implemented for Sony High Resolution API. The Simulator
unexpectedly was being shut down without any warning. I did a very simple
application that reproduce the behavior. So the following code is what makes
the Simulator sad. Note: If I don't pass the Color Table to BmpCreate,
everything is ok (succesfully drawn "a fence"). But I don't like the
situation since I'm not sure every 1-bit depth bitmap by default has the
proper table (0:White, 1:Black). So what might I do wrong or is there a
report that PalmOS 5 has a bug related to the issue?
Max
---------- Code fragment -----------
typedef struct {
UInt16 numEntries;
RGBColorType Entries[2];
} MonoColorTable;
Boolean frmMain_HandleEvent(EventPtr event)
{
FormPtr form;
Boolean handled = false;
BitmapType *GeneralBitmap, *HiDensBitmap;
WinHandle BmpWindow, ScreenWindow;
UInt16 error;
MemPtr *Bits;
RectangleType Rect;
MonoColorTable *ColorTable;
switch (event->eType)
{
case frmOpenEvent:
form = FrmGetActiveForm();
FrmDrawForm(form);
ColorTable = MemPtrNew(sizeof(MonoColorTable));
ColorTable->numEntries = 2;
ColorTable->Entries[0].index = 0;
ColorTable->Entries[0].r = 255;
ColorTable->Entries[0].g = 255;
ColorTable->Entries[0].b = 255;
ColorTable->Entries[1].index = 1;
ColorTable->Entries[1].r = 0;
ColorTable->Entries[1].g = 0;
ColorTable->Entries[1].b = 0;
GeneralBitmap = BmpCreate(320, 320, 1, (ColorTableType*) ColorTable,
&error);
Bits = BmpGetBits(GeneralBitmap);
MemSet(Bits, 12800, 0xAA); // 12800 = 320*320/8
HiDensBitmap = BmpCreateBitmapV3(GeneralBitmap, kDensityDouble, Bits,
NULL); // Docs state NULL is allowed to force getting the original color
table
BmpWindow = WinCreateBitmapWindow(HiDensBitmap, &error);
ScreenWindow = FrmGetWindowHandle(form);
RctSetRectangle(&Rect, 0, 0, 320, 320);
WinCopyRectangle(BmpWindow, ScreenWindow, &Rect, 0, 0, winPaint);
WinDeleteWindow(BmpWindow, false);
BmpDelete(HiDensBitmap);
BmpDelete(GeneralBitmap);
MemPtrFree(ColorTable);
handled = true;
break;
}
return handled;
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/