只是想添加我关于类似主题的信息。我最终只是从最新的(4.0.3)源构建 libTiff。我的项目都在 x64 中,但这很容易:
- 下载并解压 libTIFF 源
- 为 x64(或 x32)cmd 打开 VS2010(或其他)
- cd 到步骤 1 中解压缩的文件夹
- 类型:nmake /f makefile.vc
- 从 /libtiff 文件夹中获取文件并添加到您的项目中
下面是一个读取 16 位 TIFF 数据的示例:
TIFF *MultiPageTiff = TIFFOpen("C:\\MultiPageTiff.tif", "r");
std::vector<unsigned short*> SimulatedQueue;
//Read First TIFF to setup the Buffers and init
//everything
int Width, Height;
//Bit depth, in bits
unsigned short depth;
TIFFGetField(MultiPageTiff, TIFFTAG_IMAGEWIDTH, &Width);
TIFFGetField(MultiPageTiff, TIFFTAG_IMAGELENGTH, &Height);
TIFFGetField(MultiPageTiff, TIFFTAG_BITSPERSAMPLE, &depth);
//This should be Width*(depth / sizeof(char))
tsize_t ScanlineSizeBytes = TIFFScanlineSize(MultiPageTiff);
if(MultiPageTiff){
int dircount = 0;
do{
dircount++;
//I'm going to be QQueue'ing these up, so a buffer needs to be
//allocated per new TIFF page
unsigned short *Buffer = new unsigned short[Width*Height];
//Copy all the scan lines
for(int Row = 0; Row < Height; Row++){
TIFFReadScanline(MultiPageTiff, &Buffer[Row*Width], Row, 0);
}
SimulatedQueue.push_back(Buffer);
}while(TIFFReadDirectory(MultiPageTiff));
TIFFClose(MultiPageTiff);
}
资料来源:从 VS 构建 libTIFF - http://www.remotesensing.org/libtiff/build.html#PC
多页 TIFF 示例 - http://www.remotesensing.org/libtiff/libtiff.html
杂项。Tiff 手册 - http: //www.remotesensing.org/libtiff/man/