简体   繁体   中英

Convert 14-bit image to 16-bit TIFF using C#

I have a buffer with 14-bit image (640 x 512). I need save this image as 16-bit TIFF.

So, each pixel takes 2 bytes, and I can trasform into grayscale (8 bit) like this:

(buffer[index] | buffer[index + 1] << 8) & 0x3FFF

( index is number of pixel for example).

As I understand, 8-bit image I can easily save as BMP using bitmap:

bmp.Save("c:\\button.gif", System.Drawing.Imaging.ImageFormat.Bmp);

But i don`t know, how can I transform it into 16-bit TIFF. Should I transform 8-bit into 16, or 14 into 16? And how?

Somebody told me I have to form some TIFF Header and add image data to this header. Is it true? Is there any example of this? Or some library to automate this process.

You can use LibTiff .NET to save image in TIFF format:

LibTiff .NET

To convert 14 to 16 bit multiply every pixel (2 bytes) by 4.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM