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
August 2007

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

2007.08.17 14:51 "tiff problems win to mac", by Balint Radics
2007.08.17 15:27 "Re: tiff problems win to mac", by Bob Friesenhahn
2007.08.17 15:32 "Re: tiff problems win to mac", by Balint Radics
2007.08.17 15:45 "Re: tiff problems win to mac", by Bob Friesenhahn
2007.08.17 19:25 "Re: tiff problems win to mac", by Balint Radics
2007.08.17 20:05 "Re: tiff problems win to mac", by Bob Friesenhahn

2007.08.17 14:51 "tiff problems win to mac", by Balint Radics

Dear experts,

I had a working code (32 windows, libtiff 3.7.3) reading Tiff files. I
wanted to use exactly the same on a 64 bit Mac OS X 10.4.10 (cpu powerpc
970) but I get the strange behaviour that while on the windows libtiff
found the pixel values to be 16 bit per sample, on the Mac OS X it sees
them to be 1048576 bits. I don't understand what is going on, please help!

Here is the result of tiffinfo on my tiff files:

TIFF Directory at offset 0x8 (8)
  Subfile Type: (0 = 0x0)
  Image Width: 1242 Image Length: 1152
  Resolution: 72, 72 pixels/inch
  Bits/Sample: 16
  Sample Format: unsigned integer
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Smaples/Pixel: 1
  Rows/Strip: 1152
  Planar Configuration: single image plane

I attached the minimal c++ code that works on 32 windows but doesn't work
on 64 bit Mac OS X. Maybe I have to use additional flags when compiling
under Mac. I have gcc 4.0.1 (powerpc-apple-darwin8-gcc-4.0.1).

#include <tiffio.h>
#include <iostream>

int main(int argc, char * argv[]){

  TIFF *Tif;
  int bitspersample;
  int bytespersample;
  int ImageHeight;
  int ImageWidth;
  int tmpw;
  int tmph;
  int out;

  Tif = TIFFOpen(argv[1], "r");

  if (TIFFGetField(Tif, TIFFTAG_IMAGELENGTH, &ImageHeight) == 0 ||
      TIFFGetField(Tif, TIFFTAG_IMAGEWIDTH, &ImageWidth) == 0 ||
      TIFFGetField(Tif, TIFFTAG_BITSPERSAMPLE, &bitspersample) == 0 ){
    std::cerr << "error reading some properities of image " << argv[1] <<
std::endl;
    exit(-1);
  }

  std::cerr << "***Bitspersample: " << bitspersample << std::endl;
  std::cerr << "***ImageWidth: " << ImageWidth << std::endl;
  std::cerr << "***Image: " << ImageHeight << std::endl;
  bytespersample = bitspersample/8;

  /*  unsigned char * buf;
  buf = new unsigned char[TIFFScanlineSize(Tif)];

  for (int rows = 0; rows < ImageHeight; rows++){
    TIFFReadScanline(Tif, buf, rows);
    for (int cols = 0; cols < ImageWidth; cols++){
      out = 0;
      for (int kk = bytespersample; kk > 0; kk--) {
        out <<= 8;
        out += buf[cols*bytespersample+kk-1]; //here is the pixel value
      }
    }
  }

  delete [] buf;*/

  TIFFClose(Tif);

}




Please, help!

Thank you,
Balint