Index: [thread] [date] [subject] [author]
  From: Andreas Beck <becka@rz.uni-duesseldorf.de>
  To  : ggi-develop@eskimo.com
  Date: Thu, 1 Jul 1999 14:35:22 +0200

Re: mono to any depth mapping

James Simmons <jsimmons@edgeglobal.com> wrote:
>   Anyone know where I can get really fast code for mapping a bitmap (just
> 1 and 0) to any color depth? Thank you alot.

Could you be a little more precise ? What is the exact input format ?
Bit-packed ? Output: always black/white ? or color doesn't matter ? or
two given colors ? or one color+transparency ?

That heavily influences how to do it efficiently. A fast and simple
"two-fixed-colors" approach would be to precalculate 256 arrays of the
appropriate type (either packed ggi_pixel or DirectBuffer contents) and 
then HLine or memcpy them 8 pixels at a time. If the source is not divisible
by 8, you can just adjust the length of the blitting.

If color changes rarely, this could still be employed by retinting the
array, but ...

With transparency you'll have to optimize the resulting putpixels. If you
are on DirectBuffer that shouldn't be much of a problem. If you have to
resort to a real putpixel, it might make sense to try to count the number of
bits to be set in a row and call PutHLine. This heavily depends on how
expensive drawing small areas is compared to large ones.

That again can be optimized by a lookup-table that gives "run,skip" pairs,
but that's only worth the bother, if you expect long runs and calling HLine
is much more efficient that calling PutPixel a number of times.

CU, ANdy

-- 
= Andreas Beck                    |  Email :  <andreas.beck@ggi-project.org> =

Index: [thread] [date] [subject] [author]