Hi Alex,

Thanks, That's really I want it. Thank you very much.  BTW, Would you mind
give me some ideas about PNG on Palm,  the bitmap is still too lagre for
transfer over wilreless network.

Best Regards

Hans
----- Original Message -----
From: "Alex Pakhotin" <[EMAIL PROTECTED]>
To: "Hans Han" <[EMAIL PROTECTED]>
Cc: "palm-dev-forum" <[EMAIL PROTECTED]>
Sent: Tuesday, November 14, 2000 10:33 AM
Subject: Re: How to convert a 8-bits bitmaps to 4-bits Grayscale bitmaps


> If you don't need a color conversion it's even more simple.
> You need something like this:
>
> void DrawBitmap(BitmapType *bmp)
> {
>     UInt16 err;
>     BitmapType *myBmp;
>     UInt8 *src, *dst;
>     Int16 i;
>
>     myBmp = BmpCreate( bmp->width, bmp->height, 4, NULL, &err );
>     if ( err != errNone )
>         return;
>     src = (UInt8*) BmpGetBits( bmp );
>     dst = (UInt8*) BmpGetBits( myBmp );
>
>     // convert from 8 bit to 4 bit grayscale
>     for ( i = 0; i < bmp->width * bmp->height / 2; i++ )
>     {
>         UInt8 b, bHi, bLo;
>         b = *src++;
>         bHi = b >> 4; // 8bit -> 4bit - we ignore 4 low bits
>         b = *src++;
>         bLo = b >> 4;
>
>         *dst++ = (bHi<<4) | bLo;
>     }
>     WinDrawBitmap( myBmp, 0, 0 );
>     BmpDelete( myBmp );
> }
>
> Very simple isn't it? What's the problem?
>
> If the original bitmap has 0 value as black and 255 as white (standard
> grayscale format) you need to invert it (just use ~(b>>4) in conversion).
> For color original bitmap you should get RGB from the palette for every
> pixel and convert to grayscale using formula like I wrote in my previous
> letter.
>
> Good luck,
> Alex
>
> PS. It's for PalmOS 3.5 of course. For earlier versions you have to write
> your own BmpXXXX() functions. But it's not difficult.
>
> ----- Original Message -----
> From: "Hans Han"
> Sent: Monday, November 13, 2000 12:38 PM
> Subject: Re: How to convert a 8-bits bitmaps to 4-bits Grayscale bitmaps
>
>
> > Hi,
> >
> > For preformance reason, I want write on the  Bitmap data area of  an
> > offscreen window directly while I receive the bitmap from network.  The
> > pixel size of  window is 4 , so how to covert the 8-bits grayscale
values
> to
> > 4-bits index value? Wait for help.
> >
> > Regrads
> >
> > Hans
> > ----- Original Message -----
> > From: "Hans Han"
> > Sent: Friday, November 10, 2000 4:12 PM
> > Subject: How to convert a 8-bits bitmaps to 4-bits Grayscale bitmaps
> >
> >
> > > Hi All,
> > >
> > >
> > > I wonder how to convert 8-bits bitmaps to 4-bits Grayscale bitmaps.Any
> > tips
> > > or sourcecode are welcome.
> > >
> > > Thanks
> > >
> > > Hans
>
>


-- 
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