AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
February 2004

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

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

2004.02.06 21:35 "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