title: 32-bit TIFF image appears white and different from RAW
body: <p>I have a problem with saving an image using the LibTIFF library. </p>
  
  <p>In my code I have an array of floats representing the pixel values of the image. When I save these values to a RAW file, it looks fine. However, when I try to save it as a TIFF file using the LibTIFF library, the image looks perfectly fine when I open it in ImageJ, however when I open it in Photoshop or Windows, it looks strange (look below), and Gimp shows a completely transparent image (like there was no data in the image at all).</p>
  
  <p>I use ImageJ to open the RAW file, image type is set to 32bit - Real and Little-endian byte order is ticked.</p>
  
  <p><img src="https://i.stack.imgur.com/gHKI6.jpg" alt="RAW on the left, TIFF on the right"></p>
  
  <p>Here's the code I use to save the TIFF image:</p>
  
  <pre><code>TIFF *tif= TIFFOpen(name, "w");
  
  TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, width);
  TIFFSetField (tif, TIFFTAG_IMAGELENGTH, height);
  TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
  TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, 1);
  TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP, 1);
  TIFFSetField (tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
  TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
  TIFFSetField (tif, TIFFTAG_BITSPERSAMPLE, 32);
  TIFFSetField (tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
  
  tsize_t strip_size = TIFFStripSize (tif);
  tstrip_t strips_num = TIFFNumberOfStrips (tif); 
  
  float* strip_buf=(float*)_TIFFmalloc(strip_size);
  for (unsigned int s=0; s&lt;strips_num; s++) {
      for (unsigned int col=0; col&lt;width; col++) {
          strip_buf[col]=image[s][col];
      }
      TIFFWriteEncodedStrip (tif, s, strip_buf, strip_size);
  
  }
  _TIFFfree(strip_buf);
  TIFFClose(tif);
  </code></pre>
  
  <p>I'm pretty sure something's wrong with the way I'm saving the file - but I have no idea what. Thanks a lot for your help!</p>