如何在c中读取tiff文件头?
实际上我想学习TIFF Tag ImageWidth和TIFF Tag ImageLength。
我怎样才能获得这些属性?
http://www.awaresystems.be/imaging/tiff/tifftags/imagewidth.html
http://www.awaresystems.be/imaging/tiff/tifftags/imagelength.html
这段代码的c翻译可以帮助我:
https://stackoverflow.com/a/9071933/2079158
我不太了解c,
尝试过这样的事情:
#include "stdio.h"
#include "stdlib.h"
main()
{
FILE* f = fopen("tifo.tif", "rb");
unsigned char info[500];
fread(info, sizeof(unsigned char), 500, f);
long int width = *(long int*)&info[256];
short int height = *(short int*)&info[257];
printf("width : %d \n", width);
printf("height : %d \n", height);
fclose(f);
}
我能为tiff文件做些什么??
最佳答案
您将“标记id”(256和257)错误地解释为索引,这是行不通的。
您需要在文件中搜索所需的ID,然后提取与每个ID相关联的值。
请注意,TIFF没有包含所有信息的“header”,您需要通过文件查找您要查找的内容。
关于c - 如何在c中读取TIFF文件头?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16980088/