• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

#用到的库LibTiff

LibTiff .网络(bitmiracle.com)

#tiff格式介绍

争执图像文件格式详解整理_sqzeng的博客程序员博客_tiff格式

一口标签参考,搜索页面(awaresystems.be)

#常用的标签

图像宽度:图片宽度

图像长度:图片高度

SAMPLESPERPIXEL:一个像素的通道数量,一般就是rgb 3个通道

位元样本:每个通道的位数量

XRESOLUTION:x方向分辨率,正常的图片为72dpi,印刷用图片300dpi

YRESOLUTION:y方向分辨率

分辨率单位:分辨率单位,一般为英寸

光度:色彩空间,如rgb

压缩:压缩类型,如联合图象专家组

方向:行和列从哪边开始,一般行从左向右,列从上往下,即:左上方

ROWSPERSTRIP:每个条的行数,一般设为和图像长度相同的值

条带字节计数:当采用某种压缩方式后,每个条带内包含的字节数

#保存

公共静态void SaveTiff(字符串路径,Texture2D纹理)

{

使用(Tiff tiff=Tiff .打开(路径,' w '))

{

var宽度=texture.width

变量高度=纹理高度

tiff .SetField(TiffTag .图像宽度,宽度);

tiff .SetField(TiffTag .IMAGELENGTH,height);

tiff .SetField(TiffTag .SAMPLESPERPIXEL,3);

tiff .SetField(TiffTag .BITSPERSAMPLE,8,8,8);

tiff .SetField(TiffTag .定位,定位.左上);

tiff .SetField(TiffTag .ROWSPERSTRIP,height);

tiff .SetField(TiffTag .XRESOLUTION,72.0);

tiff .SetField(TiffTag .YRESOLUTION,72.0);

tiff .SetField(TiffTag .解决单位,结果单位.寸);

tiff .SetField(TiffTag .平面配置,平面配置.重叠群);

tiff .SetField(TiffTag .光度,光度. RGB);

tiff .SetField(TiffTag .压缩,压缩。无);

Color32[] colors=纹理. get pixels 32();

字节[]扫描线=新字节[3 *宽度];

for(int row=0;行高;行)

{

for(int col=0;列宽度;col)

{

color 32 color=colors[(height-row-1)* width col];

扫描线[列* 3 0]=颜色。r;

扫描线[列* 3 1]=颜色。g;

扫描线[列* 3 2]=颜色。b;

}

tiff .WriteScanline(scanline,row);

}

}

}

#读取

公共静态void ReadTiff(字符串tiffPath)

{

使用(Tiff tiff=Tiff .Open(tiffPath,' r '))

{

if (tiff==null)

{

调试LogErrorFormat(“无效的tiff ");

返回;

}

变量字段=tiff .GetField(TiffTag .艺人);

定义变量元数据字节=字段[0].GetBytes();

字符串metadataString=System .文字。Encoding.UTF8.GetString(元数据字节);

调试. log($ ' export tiff meta JSON : {元数据字符串} ');

int imageWidth=tiff .GetField(TiffTag .IMAGEWIDTH)[0].ToInt();

int imageHeight=tiff .GetField(TiffTag .IMAGELENGTH)[0].ToInt();

var xResolution=tiff .GetField(TiffTag .XRESOLUTION)[0].ToInt();

var yResolution=tiff .GetField(TiffTag .yre resolution)[0].ToInt();

压缩compression=(Compression)tiff .GetField(TiffTag .压缩)[0]。ToShort();

}

}

【其他参考】

java -如何从争执图像数据创建争执文件瘦虫子

libtiff中的标签标签含义|学步园(xuebuyuan.com)

LIBTIFF -随笔分类-一杯清酒邀明月-博客园(cnblogs.com)

使用争执库(libtiff.org)

翻译一下libtiff的手册-一杯清酒邀明月-博客园(cnblogs.com)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now