Tricky said:
Ive read all of the data out of a Bitmap (Im ignoring anything other
than 8 bits). Because I may want to manipulate them as if they were 10
bit values I need to store them into something wider than a char
array.
No need to worry about the 10 bit thing, I know Im going to have to
bit shift them all left by 2 once they are in the int array. Its just
getting the values into the int array in the first place.
What happens to the data afterwards? If it's going back in the 8-bit array,
you might be able to deal with it in-place without duplicating the entire
array (which of course would take at least 2 times as much space, plus the
original).
Or (a long shot) you might be able to convert the original 8-bit bitmap to a
16-bit one (zero-extend each pixel) separately. Then load it as 16-bits
(short int) and work on it directly.
Otherwise, convert pixel by pixel as suggested (although this would be very
neat in a few lines of assembler if your compiler allows).
(BTW the conversion to 10-bit by left shifting will involve a very small
linearity error (0..255 will map to 0..1020 instead of 0..1023))