添加自定义字段时的TIFFSetField警告(未知标签)

时间:2018-08-02 19:38:42

标签: c++ tiff

我正在创建一个GeoTIFF,并使用下面的代码似乎运行良好,但是该库会生成很多警告,特别是有关我要添加的自定义字段的警告。有人可以指出为什么是这种情况还是我做错了什么?

警告特别是:TIFFSetField: [filename]: Unknown tag 34264TIFFSetField: [filename]: Unknown tag 34736

#define TIFFTAG_GEOTRANSMATRIX  34264
#define TIFFTAG_GEOKEYDIRECTORY 34735
#define TIFFTAG_GEODOUBLEPARAMS 34736

TIFF* tif = TIFFOpen(filename.c_str(), "w");
if (!tif) throw std::runtime_error("Error creating TIFF object");

// Add custom tags
// [enum, read count, write count, type, bit, ok to change, pass count, name]
// -1 for read count/write count signifies variable length
const TIFFFieldInfo xtiffFieldInfo[] = {
    { TIFFTAG_GEOTRANSMATRIX,  -1, -1, TIFF_DOUBLE, FIELD_CUSTOM, 1, 1, (char*)"GeoTransformationMatrix" },
    { TIFFTAG_GEOKEYDIRECTORY, -1, -1, TIFF_SHORT,  FIELD_CUSTOM, 1, 1, (char*)"GeoKeyDirectory" },
    { TIFFTAG_GEODOUBLEPARAMS, -1, -1, TIFF_DOUBLE, FIELD_CUSTOM, 1, 1, (char*)"GeoDoubleParams" },
};
TIFFMergeFieldInfo(tif, xtiffFieldInfo, 3); // manually set 3 for testing

TIFFSetField(tif, TIFFTAG_GEOTRANSMATRIX,    16, &xform[0]); // <- generates warning
{
    const Float64 tmp[2] = { 298.257223563, // GeogInvFlatteningGeoKey
                             6378137.0 };   // GeogSemiMajorAxisGeoKey; WGS 84 reference ellipsoid defines 6,378,137m
    TIFFSetField(tif, TIFFTAG_GEODOUBLEPARAMS, 2, &tmp[0]); // <- generates warning
}

// Write a few other tags and image scanlines

TIFFClose(tif);

0 个答案:

没有答案