2001.03.29 16:57 "Re: Bit depth", by Chris 'Xenon' Hanson
What is required is a left shift of 5 places which is equivalent to multiplication by 65536/2048=32.
Nope, think it carefully... try those values
Max value of 11 bits: 2047 = 0x7FF, if you apply a left shif of 5 you got 65504=0xFFe0, while you should obtain maximum 16 bit value: 0xFFFF
This is a frequent mistake when converting from 8 to 16 bits, many implementations I've seen does simply shift left 8, while they should multiply by 257
Marti is basically right about preserving the upper range.
A trick that was suggested in the Amiga IFF documentation when converting to higher bit depths, was to replicate the higher-order bits into the unused low-order bits.
If your original value was 0x0fcb (12-bits lower used) you could convert this to either 0xfcbb or 0xfcbf, by grabbing either the highest nibble (4-bits) or the lowest nibble in the original value. In this way, as the original value approaches 0 or 0xfff, the 'fluff' bits that you are adding to complete the range will also properly scale to 0 or f.
I'm not really clear on whether using the highest or lowest nibble is better. Probably depends on the characteristics of your original data.
This operation can be done efficiently with masks and shifts, no floating-point multiplication or division is necessary.
Chris - Xenon
Chris Hanson | Xenon@3DNature.com | I've got friends in low latitudes!
New WCS 5 Demo Version! http://www.3DNature.com/demo/
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen