AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.02.06 21:35 "[Tiff] displaying 12 bit tiff image", by Liliana RESENDIZ
2004.02.09 09:00 "Re: [Tiff] displaying 12 bit tiff image", by Andrey Kiselev
2004.02.09 15:06 "Re: [Tiff] displaying 12 bit tiff image", by Bob Friesenhahn
2004.02.10 13:32 "Re: [Tiff] displaying 12 bit tiff image", by Liliana RESENDIZ
2004.02.10 21:41 "Re: [Tiff] displaying 12 bit tiff image", by Chris Cox
2004.02.10 22:30 "Re: [Tiff] displaying 12 bit tiff image", by Liliana RESENDIZ
2004.02.10 23:05 "Re: [Tiff] displaying 12 bit tiff image", by Bob Friesenhahn
2004.02.10 23:37 "Re: [Tiff] displaying 12 bit tiff image", by Frank Warmerdam
2004.02.11 00:21 "Re: [Tiff] displaying 12 bit tiff image", by Bob Friesenhahn

2004.02.06 21:35 "[Tiff] displaying 12 bit tiff image", by Liliana RESENDIZ

Hello,

I'm BCB6 user, I've reading the documentation in order to display correctly a 12-bit image on a TImage, first i proved with this code

TIFF* tif = TIFFOpen(FileName, "rl");

int max = 0;

if (tif)
{
  uint32 w, h, nOffset;
  size_t npixels;
  uint32* raster;
  uint16 pixel_val;
  unsigned short tfBitsPerSample, tfSamplesPerPixel, tfPlanarConfiguration,
                  tfPhotometricInterpretation, tfGrayResponseUnit,
                  tfImageDepth, tfBytesPerRow;

TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &tfPhotometricInterpretation);

TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &tfBitsPerSample);

TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &tfSamplesPerPixel);

TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &tfPlanarConfiguration);

TIFFGetFieldDefaulted(tif, TIFFTAG_GRAYRESPONSEUNIT, &tfGrayResponseUnit);

    tfImageDepth = tfBitsPerSample * tfSamplesPerPixel;

nOffset = TIFFCurrentDirOffset( tif );
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);

    npixels = w * h;
    raster = (uint32*) _TIFFmalloc(npixels * sizeof(uint32));

if (raster != NULL)
{
  if (TIFFReadRGBAImage(tif, w, h, raster))

    {
      for (int y = 0; y < h; ++y)
      {
        pixel_val = (uint16) *raster++;
        pixel_val = pixel_val;
        if (pixel_val > max)
          max = pixel_val;
      }
    }
    _TIFFfree(raster);
  }
  TIFFClose(tif);
}

with the TIFFReadRGBAImageOriented(tif, w, h, raster)) function, and i tried to display it on a TImage but it handles data range [0,256], but doing pixel_val = (uint16) *raster++, It seems i get a pixel value with data range [0,4096], is it correct?. I opened the image with the "rl" parameters to get the max pixel value of 3855, but now, how i can display int on a Timage?

If i direclty open the tiff image from the TImage and change its pixel format to pf16bit then it displays something but it is not correclty at all. I imagine that the TImage assumes a data range [0,256] and tries to display it as an 8-bit image because it appears black.

Can you help me to display it correctly?

Thank you in advance.

Liliana