2017.10.22 16:59 "Re: [Tiff] Memory management of Image", by Su
there are two ways to add additional, user defined or custom tags to the TIFF library:
a.) Patch the libtiff and compile your own, private libtiff version.
b.) Keep the official libtiff and add the custom tags from your own code by a feature of libtiff, which allows to define new custom directories with your own tags and handle them with libtiff functions.
----- For a.): -----
Look into the libtiff files
- tiff_dirinfo.c definition of tiff tags in tiffFields; just extend the field at the end with the definition of your tags.
- tiff.h definition of the tiff tag numbers; you should use unused tags, e.g. above 66000
However, tag definition and correct usage of TIFFSetField() and TIFFGetField() is also not easy, because some unwritten rules apply.
For custom tags, the LibTiff TiffSetField() and TiffGetField() functions are using va_arg() lists. Thus, there won’t be a compiler error, if the wrong parameter type is used.
Note the "variable promotion" of va_arg() lists:
If an argument has not been declared, the compiler doesn’t have any information needed to perform standard type checking and type conversion for it. Since use of ellipsis doesn’t impose type safety which is one of the major goals of C++, it is sometimes considered a bad programming practice. But at times, you may need to use variable argument function particularly dealing with old C style functions. Different conversions are applied to functions declared with ellipses than to those functions for which the formal and actual argument types are known