24-bit and 16-bit to float number in C#

1.3k Views Asked by At

I have a 32-bit tiff file which stores 4-byte values per pixel. I used BitConverter.toSingle() to convert each 4-byte values to the pixel value and it works fine. But the problem is I have 24 and 16-bit tiff files which there are 3 and 2 bytes for each pixel value. I can't use BitConverter.toSingle() method because it only supports an array of 4 bytes. How can I convert these byte values to float numbers?

Update 1:

I added an image just for clarifying that the pixel values are the floating number (look at the comments). enter image description here

0

There are 0 best solutions below