At 3:09 PM -0500 8/22/02, Hadley, Joshua wrote:
Here's what I had yesterday before I started to work on the other idea you
suggested about not bit-shifting. This code does NOT reflect that change,
which is why I'm calling the lower/uppperNibbleFromByte routines which
simply do the bit shifting and return the nibble value. I then index into an
array of 16 gamma-corrected colors with the nibble value. Based on your
advice, I would omit those routines and create an array of 256
gamma-corrected colors instead, which I would index into with the full byte
value (?).
Right. The inner portion of your loop should look like this:
surf.Pixel(xPos,yPos) = UpperNibbleLUT(l_byte)
surf.Pixel(xPos+1,yPos) = LowerNibbleLUT(l_byte)
xPos=xPos+2
if xPos >= maxXPos then
xPos=0 //reset x position . . .
yPos=yPos+1 //and move down y position
end if
So, we have two LUT (look-up table) color arrays. One is populated
by ignoring the lower nibble and stuffing the color determined by the
upper nibble of the index value. The other ignores the upper nibble,
and stores colors that depend only on the lower nibble.
I've also moved the "bpl*2" computation out of the loop; no sense
doing that work inside the loop if you don't have to.
These changes eliminate two function calls, and a handful of mods,
divisions, and multiplies. I'd be curious to hear how much that
improves it.
Cheers,
- Joe
P.S. Be sure you work with a 32-bit RGBSurface. Any lower depth will
simply mean more work for RB.
--
,------------------------------------------------------------------.
| Joseph J. Strout REAL Software, Inc. |
| joe at realsoftware dot com http://www.realsoftware.com |
`------------------------------------------------------------------'
|