2015.11.20 14:09 "[Tiff] Write 32bit Float data to Tiff (Libtiff)", by xb1 xbv1

2015.11.20 14:31 "Re: [Tiff] Write 32bit Float data to Tiff (Libtiff)", by John

On 20 November 2015 at 14:09, xb1 xbv1 <xb1mydealz@gmail.com> wrote:

now i am trying to write the float data (stored in an float-array) via WriteScanLine into the tif file, but WriteScanLine just supports byte-arrays which only stores 8bit integers.

what do i have to do, to save float to tif?

You can write all kinds of data to tiff, the type is set at runtime by the tags you attach to the header.

When you call the write function, you cast your typed data down to to a byte array to be packed off to the output. For example:

float *line_buffer = (float *) calloc(100, sizeof(float)); int i;

for (i = 0; i < 100; i++)
  line_buffer[i] = sin(2 * M_PI * i / 100);

TIFFWriteScanline(tif, (uchar *) line_buffer, 0, 0);

And TIFFWriteScanline() will figure out how many bytes to write by looking at your tiff header.

John