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

2015.11.21 09:00 "Re: [Tiff] Write 32bit Float data to Tiff (Libtiff)", by xb1 xbv1

Thanks a lot. i am using the libtiff.net library for the c#. so the code was a bit different but it worked :)

now i am trying to add a new custom tag to the header (like in the example here: https://bitmiracle.github.io/libtiff.net/).

it worked great for this tag (ASCII Data): http://www.awaresystems.be/imaging/tiff/tifftags/gdal_nodata.html but it wont work for this (Double-Data): http://www.awaresystems.be/imaging/tiff/tifftags/modelpixelscaletag.html

i tried it for the second one with TiffType.Double and a double array with 3 values but after looking at the tags with gdalinfo.exe it wont show up - >any idea what i am doing wrong?

2015-11-20 15:31 GMT+01:00 <jcupitt@gmail.com>:

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.