I am trying to find a fast way to convert a byte array that stores 12 bit data into an integer array in CSharp.
I compared using a for loop vs the Array.Copy() and there is a sigficant optimization when using the Array.Copy. Now I am trying to see if there is a similar function that you can use on more unique datatypes?
The code I currently use to convert my 12 bit data into an integer is as follow:
temp_buffer is a byte array that holds the 12 bit values, so every three bytes contain two 12-bit values.Code:index2 = 0; for(index = 0; index < 230; index+=2) { ecg_buffer[index] = (temp_buffer[index2] << 4) | ((temp_buffer[index2+1] & 0xF0)>> 4); ecg_buffer[index+1] = ((temp_buffer[index2+1] & 0x0F) << 8) | temp_buffer[index2+2]; index2+=3; }
ecg_buffer contain the converted integer values
Now is there an optimized function in CSharp that will convert every 12 bits to another datatype array?
Thank you much,
Kevin



LinkBack URL
About LinkBacks


