On Tue, Jan 15, 2002 at 10:29:46PM +1100, Stephen Best wrote:
> How does one use BmpCreate with a dynamically created palette without
> accessing the contents of the passed ColorTableType? The Palm OS Reference
> says I shouldn't be poking around in this structure.
Oh no, Palm's documentation writers are out of control! :-) [1]
The standard boilerplate has been applied to ColorTableType (Ref. p494):
WARNING! Palm, Inc. does not support or provide backward
compatibility for the ColorTableType structure. Never access its
structure members directly, or your code may break in future
versions. Use BmpGetColortable to access this structure.
Considering that BmpGetColortable returns a pointer to a ColorTableType,
the text quoted above makes no sense whatsoever. Ignore it.
If you look in Bitmap.h, you'll see that ColorTableType has no
ALLOW_ACCESS_FOO stuff in it. This further suggests that the Reference
is wrong. Presumably what it really wants to say is that you shouldn't
peer through a BitmapType pointer to examine the colour table therein,
but that has already been conveyed by the warning on BitmapType.
> I want to add a palette to a bitmap without an existing one (ie. convert it
> from grayscale to color) but this seems pretty well impossible without
> compile time messages or upsetting the emulator.
char ctbl_buf[sizeof (ColorTableType) + 2 * sizeof (RGBColorType)];
ColorTableType *ctbl = (ColorTableType *) ctbl_buf;
RGBColorType *colors = ColorTableEntries (ctbl);
BitmapType *bm;
UInt16 err;
ctbl->numEntries = 2;
colors[0].r = colors[0].g = colors[0].b = 0;
colors[1].r = colors[1].g = colors[1].b = 0xff;
bm = BmpCreate (10, 10, 1, ctbl, &err);
This works fine for me, and doesn't upset the emulator. Perhaps you
could show us the code that triggers a warning from the emulator.
John
[1] It's not the first time; see also
http://www.escribe.com/computing/pcpqa/m48109.html
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/