文档章节

GdiPlus[53]: 图像(五) 图像的属性(图像元数据)

涂孟超
 涂孟超
发布于 2014/09/26 15:34
字数 911
阅读 12
收藏 0

相关方法和属性:
IGPImage.GetPropertyItem();    { 获取属性项 }
IGPImage.SetPropertyItem();    { 设置属性项 }
IGPImage.RemovePropertyItem(); { 删除属性项 }

IGPImage.PropertyIdList; { 获取图像属性 ID 数组 }
IGPImage.PropertyItems;  { 获取图像属性集合 }

 
 
 
 
 

 

 

  

IGPImage.PropertyItems 指向一个 IGPPropertyItems 类型的数组;
IGPPropertyItem 是 IGPPropertyItems 属性数组中的一个属性(或叫属性项).

每个属性项都包含:
IGPPropertyItem.Id;        { 属性 ID, 也就是属性类别, 譬如是标题还是版权说明等 }
IGPPropertyItem.ValueType; { 属性的数据类型 }
IGPPropertyItem.Length;    { 属性数据长度 }
IGPPropertyItem.Value;     { 属性数据指针 }

 
 
 
 
 

 

 

  

IGPImage.PropertyIdList 只是获取属性 ID 的数组.

IGPPropertyItem.ValueType 常数:
PropertyTagTypeByte        = 1; { 字节数组 }
PropertyTagTypeASCII       = 2; { PAnsiChar }
PropertyTagTypeShort       = 3; { Word }
PropertyTagTypeLong        = 4; { Cardinal }
PropertyTagTypeRational    = 5; { Cardinal/Cardinal; 第一个数是分子, 第二个数是分母 }
PropertyTagTypeUndefined   = 7; { 可包含任何数据类型的字节数组 }
PropertyTagTypeSLONG       = 9; { Integer }
PropertyTagTypeSRational  = 10; { Integer/Integer; 第一个数是分子, 第二个数是分母 }

 
 
 
 
 

 

 

  

IGPPropertyItem.Id 常数:
PropertyTagGpsVer                         = $0000
PropertyTagGpsLatitudeRef                 = $0001
PropertyTagGpsLatitude                    = $0002
PropertyTagGpsLongitudeRef                = $0003
PropertyTagGpsLongitude                   = $0004
PropertyTagGpsAltitudeRef                 = $0005
PropertyTagGpsAltitude                    = $0006
PropertyTagGpsGpsTime                     = $0007
PropertyTagGpsGpsSatellites               = $0008
PropertyTagGpsGpsStatus                   = $0009
PropertyTagGpsGpsMeasureMode              = $000A
PropertyTagGpsGpsDop                      = $000B
PropertyTagGpsSpeedRef                    = $000C
PropertyTagGpsSpeed                       = $000D
PropertyTagGpsTrackRef                    = $000E
PropertyTagGpsTrack                       = $000F
PropertyTagGpsImgDirRef                   = $0010
PropertyTagGpsImgDir                      = $0011
PropertyTagGpsMapDatum                    = $0012
PropertyTagGpsDestLatRef                  = $0013
PropertyTagGpsDestLat                     = $0014
PropertyTagGpsDestLongRef                 = $0015
PropertyTagGpsDestLong                    = $0016
PropertyTagGpsDestBearRef                 = $0017
PropertyTagGpsDestBear                    = $0018
PropertyTagGpsDestDistRef                 = $0019
PropertyTagGpsDestDist                    = $001A
PropertyTagNewSubfileType                 = $00FE
PropertyTagSubfileType                    = $00FF
PropertyTagImageWidth                     = $0100
PropertyTagImageHeight                    = $0101
PropertyTagBitsPerSample                  = $0102
PropertyTagCompression                    = $0103
PropertyTagPhotometricInterp              = $0106
PropertyTagThreshHolding                  = $0107
PropertyTagCellWidth                      = $0108
PropertyTagCellHeight                     = $0109
PropertyTagFillOrder                      = $010A
PropertyTagDocumentName                   = $010D
PropertyTagImageDescription               = $010E
PropertyTagEquipMake                      = $010F
PropertyTagEquipModel                     = $0110
PropertyTagStripOffsets                   = $0111
PropertyTagOrientation                    = $0112
PropertyTagSamplesPerPixel                = $0115
PropertyTagRowsPerStrip                   = $0116
PropertyTagStripBytesCount                = $0117
PropertyTagMinSampleValue                 = $0118
PropertyTagMaxSampleValue                 = $0119
PropertyTagXResolution                    = $011A
PropertyTagYResolution                    = $011B
PropertyTagPlanarConfig                   = $011C
PropertyTagPageName                       = $011D
PropertyTagXPosition                      = $011E
PropertyTagYPosition                      = $011F
PropertyTagFreeOffset                     = $0120
PropertyTagFreeByteCounts                 = $0121
PropertyTagGrayResponseUnit               = $0122
PropertyTagGrayResponseCurve              = $0123
PropertyTagT4Option                       = $0124
PropertyTagT6Option                       = $0125
PropertyTagResolutionUnit                 = $0128
PropertyTagPageNumber                     = $0129
PropertyTagTransferFunction               = $012D
PropertyTagSoftwareUsed                   = $0131
PropertyTagDateTime                       = $0132
PropertyTagArtist                         = $013B
PropertyTagHostComputer                   = $013C
PropertyTagPredictor                      = $013D
PropertyTagWhitePoint                     = $013E
PropertyTagPrimaryChromaticities          = $013F
PropertyTagColorMap                       = $0140
PropertyTagHalftoneHints                  = $0141
PropertyTagTileWidth                      = $0142
PropertyTagTileLength                     = $0143
PropertyTagTileOffset                     = $0144
PropertyTagTileByteCounts                 = $0145
PropertyTagInkSet                         = $014C
PropertyTagInkNames                       = $014D
PropertyTagNumberOfInks                   = $014E
PropertyTagDotRange                       = $0150
PropertyTagTargetPrinter                  = $0151
PropertyTagExtraSamples                   = $0152
PropertyTagSampleFormat                   = $0153
PropertyTagSMinSampleValue                = $0154
PropertyTagSMaxSampleValue                = $0155
PropertyTagTransferRange                  = $0156
PropertyTagJPEGProc                       = $0200
PropertyTagJPEGInterFormat                = $0201
PropertyTagJPEGInterLength                = $0202
PropertyTagJPEGRestartInterval            = $0203
PropertyTagJPEGLosslessPredictors         = $0205
PropertyTagJPEGPointTransforms            = $0206
PropertyTagJPEGQTables                    = $0207
PropertyTagJPEGDCTables                   = $0208
PropertyTagJPEGACTables                   = $0209
PropertyTagYCbCrCoefficients              = $0211
PropertyTagYCbCrSubsampling               = $0212
PropertyTagYCbCrPositioning               = $0213
PropertyTagREFBlackWhite                  = $0214
PropertyTagGamma                          = $0301
PropertyTagICCProfileDescriptor           = $0302
PropertyTagSRGBRenderingIntent            = $0303
PropertyTagImageTitle                     = $0320
PropertyTagResolutionXUnit                = $5001
PropertyTagResolutionYUnit                = $5002
PropertyTagResolutionXLengthUnit          = $5003
PropertyTagResolutionYLengthUnit          = $5004
PropertyTagPrintFlags                     = $5005
PropertyTagPrintFlagsVersion              = $5006
PropertyTagPrintFlagsCrop                 = $5007
PropertyTagPrintFlagsBleedWidth           = $5008
PropertyTagPrintFlagsBleedWidthScale      = $5009
PropertyTagHalftoneLPI                    = $500A
PropertyTagHalftoneLPIUnit                = $500B
PropertyTagHalftoneDegree                 = $500C
PropertyTagHalftoneShape                  = $500D
PropertyTagHalftoneMisc                   = $500E
PropertyTagHalftoneScreen                 = $500F
PropertyTagJPEGQuality                    = $5010
PropertyTagGridSize                       = $5011
PropertyTagThumbnailFormat                = $5012
PropertyTagThumbnailWidth                 = $5013
PropertyTagThumbnailHeight                = $5014
PropertyTagThumbnailColorDepth            = $5015
PropertyTagThumbnailPlanes                = $5016
PropertyTagThumbnailRawBytes              = $5017
PropertyTagThumbnailSize                  = $5018
PropertyTagThumbnailCompressedSize        = $5019
PropertyTagColorTransferFunction          = $501A
PropertyTagThumbnailData                  = $501B
PropertyTagThumbnailImageWidth            = $5020
PropertyTagThumbnailImageHeight           = $5021
PropertyTagThumbnailBitsPerSample         = $5022
PropertyTagThumbnailCompression           = $5023
PropertyTagThumbnailPhotometricInterp     = $5024
PropertyTagThumbnailImageDescription      = $5025
PropertyTagThumbnailEquipMake             = $5026
PropertyTagThumbnailEquipModel            = $5027
PropertyTagThumbnailStripOffsets          = $5028
PropertyTagThumbnailOrientation           = $5029
PropertyTagThumbnailSamplesPerPixel       = $502A
PropertyTagThumbnailRowsPerStrip          = $502B
PropertyTagThumbnailStripBytesCount       = $502C
PropertyTagThumbnailResolutionX           = $502D
PropertyTagThumbnailResolutionY           = $502E
PropertyTagThumbnailPlanarConfig          = $502F
PropertyTagThumbnailResolutionUnit        = $5030
PropertyTagThumbnailTransferFunction      = $5031
PropertyTagThumbnailSoftwareUsed          = $5032
PropertyTagThumbnailDateTime              = $5033
PropertyTagThumbnailArtist                = $5034
PropertyTagThumbnailWhitePoint            = $5035
PropertyTagThumbnailPrimaryChromaticities = $5036
PropertyTagThumbnailYCbCrCoefficients     = $5037
PropertyTagThumbnailYCbCrSubsampling      = $5038
PropertyTagThumbnailYCbCrPositioning      = $5039
PropertyTagThumbnailRefBlackWhite         = $503A
PropertyTagThumbnailCopyRight             = $503B
PropertyTagLuminanceTable                 = $5090
PropertyTagChrominanceTable               = $5091
PropertyTagFrameDelay                     = $5100
PropertyTagLoopCount                      = $5101
PropertyTagGlobalPalette                  = $5102
PropertyTagIndexBackground                = $5103
PropertyTagIndexTransparent               = $5104
PropertyTagPixelUnit                      = $5110
PropertyTagPixelPerUnitX                  = $5111
PropertyTagPixelPerUnitY                  = $5112
PropertyTagPaletteHistogram               = $5113
PropertyTagCopyright                      = $8298
PropertyTagExifExposureTime               = $829A
PropertyTagExifFNumber                    = $829D
PropertyTagExifIFD                        = $8769
PropertyTagICCProfile                     = $8773
PropertyTagExifExposureProg               = $8822
PropertyTagExifSpectralSense              = $8824
PropertyTagGpsIFD                         = $8825
PropertyTagExifISOSpeed                   = $8827
PropertyTagExifOECF                       = $8828
PropertyTagExifVer                        = $9000
PropertyTagExifDTOrig                     = $9003
PropertyTagExifDTDigitized                = $9004
PropertyTagExifCompConfig                 = $9101
PropertyTagExifCompBPP                    = $9102
PropertyTagExifShutterSpeed               = $9201
PropertyTagExifAperture                   = $9202
PropertyTagExifBrightness                 = $9203
PropertyTagExifExposureBias               = $9204
PropertyTagExifMaxAperture                = $9205
PropertyTagExifSubjectDist                = $9206
PropertyTagExifMeteringMode               = $9207
PropertyTagExifLightSource                = $9208
PropertyTagExifFlash                      = $9209
PropertyTagExifFocalLength                = $920A
PropertyTagExifMakerNote                  = $927C
PropertyTagExifUserComment                = $9286
PropertyTagExifDTSubsec                   = $9290
PropertyTagExifDTOrigSS                   = $9291
PropertyTagExifDTDigSS                    = $9292
PropertyTagExifFPXVer                     = $A000
PropertyTagExifColorSpace                 = $A001
PropertyTagExifPixXDim                    = $A002
PropertyTagExifPixYDim                    = $A003
PropertyTagExifRelatedWav                 = $A004
PropertyTagExifInterop                    = $A005
PropertyTagExifFlashEnergy                = $A20B
PropertyTagExifSpatialFR                  = $A20C
PropertyTagExifFocalXRes                  = $A20E
PropertyTagExifFocalYRes                  = $A20F
PropertyTagExifFocalResUnit               = $A210
PropertyTagExifSubjectLoc                 = $A214
PropertyTagExifExposureIndex              = $A215
PropertyTagExifSensingMethod              = $A217
PropertyTagExifFileSource                 = $A300
PropertyTagExifSceneType                  = $A301
PropertyTagExifCfaPattern                 = $A302

 
 
 
 
 

 

 

  

遍历属性:
uses GdiPlus;

procedure TForm1.Button1Click(Sender: TObject);
var
  Image: IGPImage;
  PropertyItem: IGPPropertyItem;
begin
  Image := TGPImage.Create('C:\GdiPlusImg\FakePhoto.jpg');

  Memo1.Clear;
  for PropertyItem in Image.PropertyItems do with Memo1.Lines do
  begin
    Add(Format('Id: $%.4x', [PropertyItem.Id]));
    Add(Format('ValueType: %d', [PropertyItem.ValueType]));
    Add(Format('Length: %d', [PropertyItem.Length]));
    Add(Format('Value: $%p', [PropertyItem.Value]));
    Add(EmptyStr);
  end;
end;

 
 
 
 
 

 

 

  

只遍历属性 ID:
uses GdiPlus;

procedure TForm1.Button1Click(Sender: TObject);
var
  Image: IGPImage;
  PropID: Cardinal;
begin
  Image := TGPImage.Create('C:\GdiPlusImg\FakePhoto.jpg');

  Memo1.Clear;
  for PropID in Image.PropertyIdList do
  begin
    Memo1.Lines.Add(Format('$%.4x', [PropID]));
  end;
end;

 
 
 
 
 

 

 

  

下面例子测试了 SetPropertyItem、GetPropertyItem、RemovePropertyItem 三个方法.

先给图像添加了标题属性(其属性 ID 是 PropertyTagImageTitle);
保存图像后重新打开再读取这个属性;
删除这个属性后有试着找了找...
uses GdiPlus;

procedure TForm1.Button1Click(Sender: TObject);
var
  Image: IGPImage;
  PropTitle: IGPPropertyItem;
  Title: AnsiString;
  i: Integer;
begin
  ChDir('C:\GdiPlusImg\');
  Image := TGPImage.Create('FakePhoto.jpg');

  //
  Title := 'New Title';
  PropTitle := TGPPropertyItem.Create;
  PropTitle.Id := PropertyTagImageTitle;
  PropTitle.ValueType := PropertyTagTypeASCII;
  PropTitle.Length := Length(Title) + 1;
  PropTitle.Value := PAnsiChar(Title);

  Image.SetPropertyItem(PropTitle);
  Image.Save('FakePhoto_Test.jpg', TGPImageFormat.Jpeg);
  Image := nil;

  //
  PropTitle := nil;
  Image := TGPImage.Create('FakePhoto_Test.jpg');
  PropTitle := Image.GetPropertyItem(PropertyTagImageTitle);
  ShowMessage(PAnsiChar(PropTitle.Value)); { New Title }

  //
  Image.RemovePropertyItem(PropertyTagImageTitle);
  for i := 0 to Image.PropertyIdList.Count - 1 do
    if Image.PropertyIdList[i] = PropertyTagImageTitle then
      ShowMessage('检测到属性标题存在');   { 已删除不会再有了 }
end;

 
 
 
 
 

 

 

  

本文转载自:http://www.cnblogs.com/del/archive/2009/12/29/1634844.html

共有 人打赏支持
涂孟超
粉丝 12
博文 2011
码字总数 14107
作品 0
深圳
程序员
GDI+图像处理学习笔记——改变图像的透明度

GDI+是WindowsXp和windows Server 2003中的一个子系统,主要用于处理系统的绘制消息。GDI+是GDI的扩展,其继承了GDI的有点并在其基础上进行了改进,包括增加了一些GDI无法绘制的图形函数,同...

晨曦之光
2012/05/23
491
0
VC实现多格式图像的转换

色彩鲜艳漂亮的高品质图像,一个个形象生动的Windows图标,高速运动、活灵活现的三维动画,这些无一不显示出程序设计者的艺术才华。在程序设计中,图像处理已经成为每个程序员的必修课。 在V...

余二五
2017/11/06
0
0
GDAL体系架构

在GDAL库中包含栅格数据的读写,矢量数据的读写,以及栅格和矢量数据的相关算法。下面主要对GDAL中栅格数据和矢量数据的体系架构做一个简单的说明。本人英文很烂,有些部分写出来的东西自己都...

长平狐
2013/12/25
871
0
【CVPR Oral】TensorFlow实现StarGAN代码全部开源,1天训练完

StarGAN 是去年 11 月由香港科技大学、新泽西大学和韩国大学等机构的研究人员提出的一个图像风格迁移模型,是一种可以在同一个模型中进行多个图像领域之间的风格转换的对抗生成方法。近日,有...

技术小能手
06/13
0
0
图表编辑器TMS Diagram Studio更新至v4.14,支持RAD Studio 10.2 Tokyo

TMS Diagram Studio是一款功能强大的图表控件,专为您的应用程序添加示意图和流程图表。 TMS Diagram Studio点击下载>>> v4.14 改进:更改handle检测的顺序。 修复:预览/打印错误。 修复:T...

Harriet666
2017/10/19
0
0

没有更多内容

加载失败,请刷新页面

加载更多

负载均衡的解决方案有哪些

负载均衡器服务可满足大型组织的需求,支持所有数据中心和跨数据中心高可靠性场景。 本地负载均衡,通过附带或者未附带持久性覆盖选项,Incapsula支持各种负载均衡算法,以优化服务器之间的流...

上树的熊
49分钟前
4
0
Java实现在线打开word文档加盖印章/盖章/签名功能

前言: 我们知道,大型一点的OA办公系统都会有很多在线处理office办公文档的需求。其中有一点也基本绕不开,那就是为文档盖章或添加手写签名来保护文档,让被盖章的文档不再被编辑。 在Java中...

山里的红杏
56分钟前
5
0
js控制输入正负数,小数点后保留两位

//限制数字function clearNoNum(obj){ //修复第一个字符是小数点 的情况. if(obj.value !=''&& obj.value.substr(0,1) == '.'){ obj.value=""; } obj.value ...

一直在成长的程序猿
59分钟前
3
0
动态代理

具体场景 为了使代理类与被代理类对第三方有相同的函数,代理类与被代理类一般实现一个公共的interface,定义如下 public interface Subject { void rent(); void hello(String s)...

wuyiyi
今天
2
0
时间字段

我们看看这几个数据库中(mysql、oracle和sqlserver)如何表示时间 mysql数据库:它们分别是 date、datetime、time、timestamp和year。date :“yyyy-mm-dd”格式表示的日期值 time :“hh:...

DemonsI
今天
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部