通过 LibTiff.Net 从 Stream 加载的 Tiff 没有字段值
我的应用程序必须处理存储在 MemoryStream 中的 TIFF 文件,但 LibTiff.Net 始终为字段值返回 null
。
MemoryStream ms = new MemoryStream();
FileStream fs = new FileStream("testfile.tif", FileMode.Open);
fs.CopyTo(ms);
//It seems (memory) streams have to be opened in write mode, "r" always returns <null>
Tiff tiff = Tiff.ClientOpen("someArbitraryName", "w", ms, new TiffStream());
FieldValue[] imageHeight = tif.GetField(TiffTag.IMAGELENGTH);
使用 Tiff.Open 直接打开文件进行读取效果很好。
这是 LibTiff.Net 库中的错误还是我遗漏了什么?
My application has to handle TIFF files that are stored in a MemoryStream, but LibTiff.Net always returns null
for the field values.
MemoryStream ms = new MemoryStream();
FileStream fs = new FileStream("testfile.tif", FileMode.Open);
fs.CopyTo(ms);
//It seems (memory) streams have to be opened in write mode, "r" always returns <null>
Tiff tiff = Tiff.ClientOpen("someArbitraryName", "w", ms, new TiffStream());
FieldValue[] imageHeight = tif.GetField(TiffTag.IMAGELENGTH);
Opening the file directly for reading using Tiff.Open
works fine.
Is this a bug in the LibTiff.Net library or am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Bit Miracle 支持团队为我提供了解决方案:
Tiff.ClientOpen
从流的当前位置读取数据。这解决了问题。
Bit Miracle support team provided me with the solution:
Tiff.ClientOpen
reads data from the current position of the stream.This fixes the problem.