How can I get the StripOffsets tag to stay the same when using the LibTiff.Net 2.3 library?

廉价感情. 提交于 2019-12-04 19:48:38

STRIPOFFSETS tag is set automatically by the library when it writes the image data to the file.

Usually it doesn't matter what is the value of this tag (unless it's correct number, of course).

But sometimes there is the requirement: image data must be saved after directory (page) header. Some applications require TIFFs to be written that way.

In such a case you should use a call to CheckpointDirectory method before any of the methods that write raster data to a file or a stream to write TIFF tags before raster data.

CheckpointDirectory will save directory data along with tags data but won't close output and you'll be able to continue creating an image.

Your code should look something like this:

using (Tiff tif = Tiff.Open("file.tif", "w"))
{
 ...
 tif.SetField(..);
 ...
 tif.SetField(..);
 tif.CheckpointDirectory();

 ...
 tif.WriteRawStrip(..);
 ...
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!