1.下载
Index of /libtiff/ (osgeo.org)
2.配置
3.使用
4.测试程序
#include <iostream>
#include <cstdint> // 包含 stdint.h 头文件
#include "tiffio.h"
int main()
{
std::cout << "Hello World!\n";
// 打开一个 TIFF 文件
const char* filename = "D://test//ImageAnalysis//JL1GF06A23_PMS_20240712205830_200281859_103_0010_001_L0_MSS.tif";
TIFF* tiff = TIFFOpen(filename, "r");
if (tiff) {
std::cout << "TIFF file opened successfully.\n";
uint32_t width, height; // 使用 uint32_t 和 uint16_t
uint16_t samplesPerPixel;
// 获取图像的宽度和高度
TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &height);
TIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel);
std::cout << "Image dimensions: " << width << "x" << height << "\n";
std::cout << "Samples per pixel: " << samplesPerPixel << "\n";
// 关闭 TIFF 文件
TIFFClose(tiff);
}
else {
std::cerr << "Failed to open TIFF file.\n";
}
return 0;
}