I am trying to see if there is a way to quickly convert an 8-bit array of numbers into a 16-bit array of numbers. Basically, I get data from an outside piece of hardware that I need to display on the screen. Right now the data is treated as 8-bit integers, even though I technically need 16-bit integers. What my code does is take two adjacent values and multiplies them, here is an example:
Byte1 = 3
Byte2 = 11
Value = Byte2*256 + Byte1 = 2819
This works, but I have a *lot* of these data points (it's basically a 1024x768 image) so there are many of these calculations. I am wondering if there is a way to speed this up. So right now:
Byte1 = 00000011
Byte2 = 00001011
And I want to have the program just take 0000101100000011 as its value. I do *not* want to just caste the values into a short, because that will just give me 0000000000000011 and 0000000000001011 and not accomplish anything, as far as I understand.
Basically I'm trying to get a pointer to an array of 8-bit integers and tell my program "OK, now they are 16-bit integers and there are only half as many of them."
And I want to have the program just take 0000101100000011 as its value. I do *not* want to just caste the values into a short, because that will just give me 0000000000000011 and 0000000000001011 and not accomplish anything, as far as I understand.
Dont cast the values - cast the array name (whic is a pointer) to a pointer to short.