geoff wrote:

> I know you have to type cast the value to something. But in ur example when
> u make it return UInt8. What does this value represent, a pixel?

It represents a byte.  The format of the data depends on which type
of bitmap you have.  It is different for 1-bit, 2-bit, 4-bit, 8-bit,
16-bit, etc.  For a 1-bit bitmap, it represents 8 pixels.  For a
2-bit, four pixels.  For a 16-bit, half a pixel.

There is one thing that remains true no matter what the format, though.
The number of bytes per row of the pixel data is equal to the rowbytes
value you can get from BmpGetDimensions().  This is important because
even if you have an 8-bit image that's 101 pixels wide, and even though
8-bit pixels take up one byte, rowbytes might not be 101.  It might be
102 or 104 or something.

> If so what
> pixel and how do u control what pixel data is returned.

You don't really control it any more than you control what kind of
bleach or detergent you need to get out a particular stain from a
piece of clothing.  You just figure out what you've got, and then
that's what you've got.

> Also do u change the
> color value of the pixel in rgb format?

Some bitmaps aren't RGB.  Some are greyscale.  So, for the greyscale
ones, the answer is no.  Some bitmaps are 8-bit indexed color, in
which case the answer is again no because the pixel data is composed
of indices into a color table.  Some bitmaps are 16-bit direct color,
in which case the pixel data is RGB data.  (But, it can be in more
than one format even with 16-bit, so you need to determine which
PixelFormatType the bitmap uses, but only if it's a V3 bitmap.)

> Can someone please show me an
> example of how to change color of one pixel from a 8 bit bitmap? Any help
> would be greatly appreciated!

You can't really change the color directly.  But you can change
the index into the color table.  Let's say you have a bitmap,
and you KNOW that it's 8-bit indexed color.  And you know the
index of the color you want to set it to is 42.  Then, you could
do this:

        UInt8 *pixeldata = (UInt8 *) BmpGetBits (bitmapptr);
        UInt16 rowbytes;

        BmpGetDimensions (bitmapptr, NULL, NULL, & rowbytes);
        
        pixeldata[ rowbytes * y + x ] = 42;

Of course, this ALSO assumes that the bitmap pixel data isn't
compressed!  If it is, then you can't modify it unless you
understand the compression format (or make an uncompressed
copy, then modify that).

  - Logan

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

Reply via email to