i want to blend pixels using adding. so:
destpixel = destpixel + srcpixel
the problem is of course, that there can be a overflow. in such a case one wants to use the maximum allowed value. so currently i'm doing this:
i assume, that using a lookup table to remove the 3 if blocks would speed things up, but i'd be happiest to get away without additional memory accesses....
any ideas on this?
DANIEL
destpixel = destpixel + srcpixel
the problem is of course, that there can be a overflow. in such a case one wants to use the maximum allowed value. so currently i'm doing this:
- Code:
unsigned short blendSC = *dstC;
unsigned int newR = (blendSC&RED;_MASK) + (newCol&RED;_MASK),
newG = (blendSC&GREEN;_MASK) + (newCol&GREEN;_MASK),
newB = (blendSC&BLUE;_MASK) + (newCol&BLUE;_MASK);
if(newR>RED_MASK)
newR = RED_MASK;
if(newG>GREEN_MASK)
newG = GREEN_MASK;
if(newB>BLUE_MASK)
newB = BLUE_MASK;
newCol = newR | newG | newB;
i assume, that using a lookup table to remove the 3 if blocks would speed things up, but i'd be happiest to get away without additional memory accesses....
any ideas on this?
DANIEL