> > To catch all cases you need a loop,

> A loop over what? Over the rgb-compontents? Or over different colordepth?

Over the width of the expanded version, with a stepsize determined by the
significant bits of the to-be-expanded one.

> > which is why I am worrying about performance.
> What about unrolling the loop?

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

CU, ANdy

-- 
= Andreas Beck                    |  Email :  <[EMAIL PROTECTED]>        =

Reply via email to