On Sun, 3 Dec 2000, Andreas Beck wrote:
> You can't do that generically. You'd have to introduce lots of special cases
> for the different color schemes, then.
> 
> The algorithm for expanding a right-aligned "value" of length "nowlegth"
> to "exlength" is:
> 
> res=0;
> for(a=exlength-nowlength;a>-nowlength;a-=nowlength)
>       if (a>=0)
>               res|=(value<<a);
>       else
>               res|=(value>>(-a));

How about splitting to two functions...

for >= 4bpp:

col->r = DOSHIFT(pixel & priv->red_mask, priv->red_unmap);
col->r |= col->r >> priv->red_nbits;
col->r |= col->r >> priv->red_nbits_times_two;

For stuff < 4bpp, use a different but similar function.

--
Brian

Reply via email to