c++用于读取原始文件流元数据的字节序感知的库?
我从图像文件中获取了原始数据流,例如:
vector<char> rawData(fileSize);
ifstream inFile("image.jpg");
inFile.read(&rawData[0]);
我想解析不同图像格式的标题的高度和宽度。是否有一个可移植库可以从缓冲区/流中读取整数、长整型、短整型等,并按指定转换为字节序?
我希望能够执行以下操作: short x = rawData.readLeShort(offset);
或 long y = rawData.readBeLong(offset)
更好的选择将是一个轻量级的可以处理原始图像数据的便携式图像元数据库(没有图像处理库的额外重量)。我发现 Exif 库不支持 png
和 gif
。
I've got raw data streams from image files, like:
vector<char> rawData(fileSize);
ifstream inFile("image.jpg");
inFile.read(&rawData[0]);
I want to parse the headers of different image formats for height and width. Is there a portable library that can can read ints, longs, shorts, etc. from the buffer/stream, converting for endianess as specified?
I'd like to be able to do something like: short x = rawData.readLeShort(offset);
or long y = rawData.readBeLong(offset)
An even better option would be a lightweight & portable image metadata library (without the extra weight of an image manipulation library) that can work on raw image data. I've found that Exif libraries out there don't support png
and gif
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自己做起来并不难。以下是读取小端 32 位数字
和读取大端 32 位数字的方法:
It's not that hard to do yourself. Here's how you can read a little endian 32 bit number:
and to read a big endian 32 bit number: