# gdip.image 库模块帮助文档

## gdip 成员列表 <a id="gdip" href="#gdip">&#x23;</a>

### gdip.CloneImage <a id="gdip.CloneImage" href="#gdip.CloneImage">&#x23;</a>
`$.api("GdipCloneImage","int(PTR img,ptr& cloneImage)")`

### gdip.GetAllPropertyItems <a id="gdip.GetAllPropertyItems" href="#gdip.GetAllPropertyItems">&#x23;</a>
`$.api("GdipGetAllPropertyItems","int(PTR img,int totalBufferSize,int numProperties,struct& allItems)")`

### gdip.GetImageHeight <a id="gdip.GetImageHeight" href="#gdip.GetImageHeight">&#x23;</a>
`$.api("GdipGetImageHeight","int(PTR img,int& Height)")`

### gdip.GetImageHorizontalResolution <a id="gdip.GetImageHorizontalResolution" href="#gdip.GetImageHorizontalResolution">&#x23;</a>
`$.api("GdipGetImageHorizontalResolution","int(PTR img,float& resolution)")`

### gdip.GetImagePixelFormat <a id="gdip.GetImagePixelFormat" href="#gdip.GetImagePixelFormat">&#x23;</a>
`$.api("GdipGetImagePixelFormat","int(PTR img,int& PixelFormat)")`

### gdip.GetImageThumbnail <a id="gdip.GetImageThumbnail" href="#gdip.GetImageThumbnail">&#x23;</a>
`$.api("GdipGetImageThumbnail","int(PTR img,int w,int h,pointer& thumb,pointer callback,pointer callbackData )")`

### gdip.GetImageVerticalResolution <a id="gdip.GetImageVerticalResolution" href="#gdip.GetImageVerticalResolution">&#x23;</a>
`$.api("GdipGetImageVerticalResolution","int(PTR img,float& resolution)")`

### gdip.GetImageWidth <a id="gdip.GetImageWidth" href="#gdip.GetImageWidth">&#x23;</a>
`$.api("GdipGetImageWidth","int(PTR img,int& Width)")`

### gdip.GetPropertyCount <a id="gdip.GetPropertyCount" href="#gdip.GetPropertyCount">&#x23;</a>
`$.api("GdipGetPropertyCount","int(PTR img,int& numOfProperty)")`

### gdip.GetPropertyIdList <a id="gdip.GetPropertyIdList" href="#gdip.GetPropertyIdList">&#x23;</a>
`$.api("GdipGetPropertyIdList","int(PTR img,int numOfProperty,struct& list)")`

### gdip.GetPropertyItem <a id="gdip.GetPropertyItem" href="#gdip.GetPropertyItem">&#x23;</a>
`$.api("GdipGetPropertyItem","int(PTR img,int propId,int propSize,string& buffer)")`

### gdip.GetPropertyItemSize <a id="gdip.GetPropertyItemSize" href="#gdip.GetPropertyItemSize">&#x23;</a>
`$.api("GdipGetPropertyItemSize","int(PTR img,int propId,int& size)")`

### gdip.GetPropertySize <a id="gdip.GetPropertySize" href="#gdip.GetPropertySize">&#x23;</a>
`$.api("GdipGetPropertySize","int(PTR img,int& totalBufferSize,int& numProperties)")`

### gdip.ImageGetFrameCount <a id="gdip.ImageGetFrameCount" href="#gdip.ImageGetFrameCount">&#x23;</a>
`$.api("GdipImageGetFrameCount","int(PTR img,struct dimensionID,INT& count)")`

### gdip.ImageGetFrameDimensionsCount <a id="gdip.ImageGetFrameDimensionsCount" href="#gdip.ImageGetFrameDimensionsCount">&#x23;</a>
`$.api("GdipImageGetFrameDimensionsCount","int(PTR img,int& count)")`

### gdip.ImageGetFrameDimensionsList <a id="gdip.ImageGetFrameDimensionsList" href="#gdip.ImageGetFrameDimensionsList">&#x23;</a>
`$.api("GdipImageGetFrameDimensionsList","int(PTR img,struct& dimensionIDs,int count)")`

### gdip.ImageRotateFlip <a id="gdip.ImageRotateFlip" href="#gdip.ImageRotateFlip">&#x23;</a>
`$.api("GdipImageRotateFlip","int(PTR img,int rfType)")`

### gdip.ImageSelectActiveFrame <a id="gdip.ImageSelectActiveFrame" href="#gdip.ImageSelectActiveFrame">&#x23;</a>
`$.api("GdipImageSelectActiveFrame","int(PTR img,struct& dimensionID,int frameIndex)")`

### gdip.LoadImageFromFile <a id="gdip.LoadImageFromFile" href="#gdip.LoadImageFromFile">&#x23;</a>
`$.api("GdipLoadImageFromFile","int(ustring FileName,pointer& Image)")`

### gdip.LoadImageFromStream <a id="gdip.LoadImageFromStream" href="#gdip.LoadImageFromStream">&#x23;</a>
`$.api("GdipLoadImageFromStream","int(POINTER stream,pointer& Image)")`

### gdip.RemovePropertyItem <a id="gdip.RemovePropertyItem" href="#gdip.RemovePropertyItem">&#x23;</a>
`$.api("GdipRemovePropertyItem","int(PTR img,int propId)")`

### gdip.SaveImageToFile <a id="gdip.SaveImageToFile" href="#gdip.SaveImageToFile">&#x23;</a>
`$.api("GdipSaveImageToFile","int(PTR img,ustring FileName,struct clsidEncoder,struct encoderParams)")`

### gdip.SaveImageToStream <a id="gdip.SaveImageToStream" href="#gdip.SaveImageToStream">&#x23;</a>
`$.api("GdipSaveImageToStream","int(PTR img,PTR stream,struct clsidEncoder,struct encoderParams)")`

### gdip.SetPropertyItem <a id="gdip.SetPropertyItem" href="#gdip.SetPropertyItem">&#x23;</a>
`$.api("GdipSetPropertyItem","int(PTR img,struct& Item)")`

### gdip.image("字符串参数") <a id="gdip.image" href="#gdip.image">&#x23;</a>
创建 GDI+ 图片对象

### gdip.image() <a id="gdip.image" href="#gdip.image">&#x23;</a>
[返回对象:gdipimageObject](#gdipimageObject)

## gdip.image 成员列表 <a id="gdip.image" href="#gdip.image">&#x23;</a>

GDI+ 图片对象，gdip.bitmap 的基类

### gdip.image.is() <a id="gdip.image.is" href="#gdip.image.is">&#x23;</a>
参数 @1 指定的是否 gdip.image 或 gdip.bitmap 对象。  
> gdip.bitmap 继承自 gdip.image 。

## gdipExifItemObject 成员列表 <a id="gdipExifItemObject" href="#gdipExifItemObject">&#x23;</a>

### gdipExifItemObject.length <a id="gdipExifItemObject.length" href="#gdipExifItemObject.length">&#x23;</a>
数据长度

### gdipExifItemObject.number <a id="gdipExifItemObject.number" href="#gdipExifItemObject.number">&#x23;</a>
数值格式  
如果是数组仅显示第一个数值  
如果value为文本则number字段为空

### gdipExifItemObject.propId <a id="gdipExifItemObject.propId" href="#gdipExifItemObject.propId">&#x23;</a>
属性 ID

### gdipExifItemObject.text <a id="gdipExifItemObject.text" href="#gdipExifItemObject.text">&#x23;</a>
尝试转换为文本格式的值，  
将对象转入 tostring 函数返回此字段。  
此字段有可能是根据 value 在 _get 元方法中动态生成。

### gdipExifItemObject.type <a id="gdipExifItemObject.type" href="#gdipExifItemObject.type">&#x23;</a>
数据类型

### gdipExifItemObject.value <a id="gdipExifItemObject.value" href="#gdipExifItemObject.value">&#x23;</a>
原始数据值。  
值可能为文本、buffer、或一个结构体。  
如果是结构体,则数组值放在 items 字段里  
如果 value 为文本或 buffer 则 number 字段为空

### gdipExifItemObject.value.items <a id="gdipExifItemObject.value.items" href="#gdipExifItemObject.value.items">&#x23;</a>
数组值

## gdipimageObject 成员列表 <a id="gdipimageObject" href="#gdipimageObject">&#x23;</a>

### gdipimageObject.activeFrame <a id="gdipimageObject.activeFrame" href="#gdipimageObject.activeFrame">&#x23;</a>
当前帧索引  
修改该属性请使用 selectActiveFrame 函数

### gdipimageObject.clone() <a id="gdipimageObject.clone" href="#gdipimageObject.clone">&#x23;</a>
复制图像  

[返回对象:gdipimageObject](#gdipimageObject)

### gdipimageObject.createAnimation <a id="gdipimageObject.createAnimation" href="#gdipimageObject.createAnimation">&#x23;</a>
如果图像是一个动画,创建定时器执行动画  
注意每个图像同时只能在一个窗口上创建动画  
创建动画前自动删除之前创建的动画定时器  
如果图像不是动画,此函数不执行任何操作  
成功返回定时器ID

### gdipimageObject.createAnimation(窗口对象,回调函数) <a id="gdipimageObject.createAnimation" href="#gdipimageObject.createAnimation">&#x23;</a>
在窗口上创建定时器,  
每帧动画触发回调函数,  
回调函数owner参数被设为参数@1指定的窗口对象  

如果不指定控件,则默认指定为上次创建动画的控件,  
如果不指定回调函数,则默认指定为控件的redrawTransparent函数

### gdipimageObject.delete() <a id="gdipimageObject.delete" href="#gdipimageObject.delete">&#x23;</a>
释放图像  
此对象支持自动释放,不必手工调用此函数

### gdipimageObject.eachFrame <a id="gdipimageObject.eachFrame" href="#gdipimageObject.eachFrame">&#x23;</a>
如果图像支持动画，则返回一个帧迭代器。  
否则此函数返回 null。

### gdipimageObject.eachFrame(loopCount) <a id="gdipimageObject.eachFrame" href="#gdipimageObject.eachFrame">&#x23;</a>
遍历动画帧。  
每次调用帧迭代器切换到下一帧并返回当前帧所需延时，帧索引。  
动画完成迭代器返回 null 。  
可选用 @loopCount 参数指定循环所有帧的次数，0 为无限循环。  
不指定参数则获取图像默认循环次数。  

示例：  
```aardio  
for delay,frame in bmp.eachFrame(1) {  
    bmp.save("/"+frame+".gif");  
}  
```

### gdipimageObject.eachProperty() <a id="gdipimageObject.eachProperty" href="#gdipimageObject.eachProperty">&#x23;</a>

```aardio
for( tagId,propertyItem in gdipimageObject.eachProperty() ){  
	 propertyItem./*遍历图像属性字段*/  
}  

[返回对象:gdipExifItemObject](#gdipExifItemObject)
```

### gdipimageObject.frameDimension <a id="gdipimageObject.frameDimension" href="#gdipimageObject.frameDimension">&#x23;</a>
当前分辨率GUID

### gdipimageObject.getFrameDelays() <a id="gdipimageObject.getFrameDelays" href="#gdipimageObject.getFrameDelays">&#x23;</a>
返回多帧图像每帧延时数值组成的数组,  
延时单位为厘秒,即0.01秒

### gdipimageObject.getFrameDimensionsList() <a id="gdipimageObject.getFrameDimensionsList" href="#gdipimageObject.getFrameDimensionsList">&#x23;</a>
图像帧分辨率列表  
该值是GUID数组

### gdipimageObject.getGraphics() <a id="gdipimageObject.getGraphics" href="#gdipimageObject.getGraphics">&#x23;</a>
从图像获取画板（gdip.graphics 对象）。  
需要导入 gdip.graphics 。  

[返回对象:gdipgraphicsObject](#gdipgraphicsObject)

### gdipimageObject.getLoopCount() <a id="gdipimageObject.getLoopCount" href="#gdipimageObject.getLoopCount">&#x23;</a>
获取动画循环次数,0为一直循环,  
根据 GDI+ 的规则,循环次数为 2 会改为 1,其他不变,  
为不影响性能默认不处理这个问题  

如果要处理,步骤如下:  
1、读取循环次数如果为1就进行下一步  
2、在GIF图像数据中搜索关键字"NETSCAPE2.0"  
如果找到就将此图像的 $loopCount 属性赋值为2,  
注意 plus 控件支持将加载好的GDI+图像作为参数  

GIF动画循环次数一般不是0就是1,  
其他数值基本无人使用,搞这么复杂是不必要的

### gdipimageObject.getPixelFormat() <a id="gdipimageObject.getPixelFormat" href="#gdipimageObject.getPixelFormat">&#x23;</a>
返回像素格式

### gdipimageObject.getPropertyIds() <a id="gdipimageObject.getPropertyIds" href="#gdipimageObject.getPropertyIds">&#x23;</a>
返回所有属性ID数组

### gdipimageObject.getPropertyItem() <a id="gdipimageObject.getPropertyItem" href="#gdipimageObject.getPropertyItem">&#x23;</a>
[返回对象:gdipExifItemObject](#gdipExifItemObject)

### gdipimageObject.getPropertyItem(属性ID) <a id="gdipimageObject.getPropertyItem" href="#gdipimageObject.getPropertyItem">&#x23;</a>
返回字段

### gdipimageObject.getResolution() <a id="gdipimageObject.getResolution" href="#gdipimageObject.getResolution">&#x23;</a>
返回分辨率 xdpi,ydpi

### gdipimageObject.getThumbnail() <a id="gdipimageObject.getThumbnail" href="#gdipimageObject.getThumbnail">&#x23;</a>
[返回对象:gdipimageObject](#gdipimageObject)

### gdipimageObject.getThumbnail(宽度,高度,是否保持比例) <a id="gdipimageObject.getThumbnail" href="#gdipimageObject.getThumbnail">&#x23;</a>
获取缩略图,  
返回 gdip.image 对象.  
宽度,高度指定新的像素大小,也可以用小于1大于0的小数指定缩放百分比.

### gdipimageObject.graphics <a id="gdipimageObject.graphics" href="#gdipimageObject.graphics">&#x23;</a>
[返回对象:gdipgraphicsObject](#gdipgraphicsObject)

### gdipimageObject.graphics() <a id="gdipimageObject.graphics" href="#gdipimageObject.graphics">&#x23;</a>
[返回对象:gdipgraphicsObject](#gdipgraphicsObject)

### gdipimageObject.height <a id="gdipimageObject.height" href="#gdipimageObject.height">&#x23;</a>
高度

### gdipimageObject.isPlaying() <a id="gdipimageObject.isPlaying" href="#gdipimageObject.isPlaying">&#x23;</a>
是否正在播放动画

### gdipimageObject.isValid() <a id="gdipimageObject.isValid" href="#gdipimageObject.isValid">&#x23;</a>
图像是否有效  
delete 函数释放以后返回 false

### gdipimageObject.origHeight <a id="gdipimageObject.origHeight" href="#gdipimageObject.origHeight">&#x23;</a>
原始高度，  
对于一个 gdip.image 对象会一直缓存第一次读取的值

### gdipimageObject.origWidth <a id="gdipimageObject.origWidth" href="#gdipimageObject.origWidth">&#x23;</a>
原始宽度，  
对于一个 gdip.image 对象会一直缓存第一次读取的值

### gdipimageObject.removePropertyItem(属性ID) <a id="gdipimageObject.removePropertyItem" href="#gdipimageObject.removePropertyItem">&#x23;</a>
移除字段

### gdipimageObject.rotateFlip(_GdipRotate指定翻转选项) <a id="gdipimageObject.rotateFlip" href="#gdipimageObject.rotateFlip">&#x23;</a>
翻转图片

### gdipimageObject.save("字符串参数") <a id="gdipimageObject.save" href="#gdipimageObject.save">&#x23;</a>
保存图像。  
成功返回 true，失败返回 null，错误信息。  
使用参数指定的文件路径或加载图片时的路径  
根据后缀名自动设定格式,  
可选在参数@3使用gdip.encoder.parameter数组指定保存参数

### gdipimageObject.save("字符串参数",80) <a id="gdipimageObject.save" href="#gdipimageObject.save">&#x23;</a>
保存图像。  
成功返回 true，失败返回 null，错误信息。  
使用参数指定的文件路径或加载图片时的路径  
根据后缀名自动设定格式  
jpg文件可使用第二个参数指定图像质量,  
可选在参数@3使用gdip.encoder.parameter数组指定保存参数

### gdipimageObject.saveAdd() <a id="gdipimageObject.saveAdd" href="#gdipimageObject.saveAdd">&#x23;</a>
添加当前图像到多帧图像

### gdipimageObject.saveAdd(图像) <a id="gdipimageObject.saveAdd" href="#gdipimageObject.saveAdd">&#x23;</a>
添加其他 gdip.image 或 gdip.bitmap 对象到多帧图像。  
可选使用参数 @2 指定 saveFlag ，可选在参数 @3 使用 gdip.encoder.parameter 数组指定保存参数

### gdipimageObject.saveAdd(图像路径) <a id="gdipimageObject.saveAdd" href="#gdipimageObject.saveAdd">&#x23;</a>
创建多帧图像，参数 @1 指定保存路径。  
后续添加图像帧时，参数 @1 不能再指定路径。  
在添加所有帧以后调用 saveFlush 函数保存文件。

### gdipimageObject.saveToBuffer(后缀名,输出质量) <a id="gdipimageObject.saveToBuffer" href="#gdipimageObject.saveToBuffer">&#x23;</a>
保存图像到 buffer，返回 buffer 对象,  
后缀名默认为"*.jpg",质量默认为100,  
可选在参数@3使用gdip.encoder.parameter数组指定保存参数

### gdipimageObject.saveToStream <a id="gdipimageObject.saveToStream" href="#gdipimageObject.saveToStream">&#x23;</a>
保存到内存流对象,  
该函数成功返回值为流对象

### gdipimageObject.saveToStream() <a id="gdipimageObject.saveToStream" href="#gdipimageObject.saveToStream">&#x23;</a>
[返回对象:fsysStreamObject](https://www.aardio.com/zh-cn/docs/library-reference/fsys/stream.html#fsysStreamObject)

### gdipimageObject.saveToStream(流对象,后缀名,输出质量) <a id="gdipimageObject.saveToStream" href="#gdipimageObject.saveToStream">&#x23;</a>
流对象请使用 fsys.stream 创建  
后缀名默认为"*.jpg",质量默认为100,  
可选在参数@4使用gdip.encoder.parameter数组指定保存参数

### gdipimageObject.selectActiveFrame(帧序号) <a id="gdipimageObject.selectActiveFrame" href="#gdipimageObject.selectActiveFrame">&#x23;</a>
设置当前动画帧

### gdipimageObject.setFrameDelays() <a id="gdipimageObject.setFrameDelays" href="#gdipimageObject.setFrameDelays">&#x23;</a>
修改多帧图像每帧延时数值  
参数必须是由数值组成的非空数组,  
延时单位为厘秒,即0.01秒  
必须在调用saveAdd以前设置

### gdipimageObject.setPropertyItem(字段结构体) <a id="gdipimageObject.setPropertyItem" href="#gdipimageObject.setPropertyItem">&#x23;</a>
修改字段

### gdipimageObject.stopAnimation() <a id="gdipimageObject.stopAnimation" href="#gdipimageObject.stopAnimation">&#x23;</a>
如果此图像已运行动画,则停止动画并返回 true

### gdipimageObject.totalFrames <a id="gdipimageObject.totalFrames" href="#gdipimageObject.totalFrames">&#x23;</a>
动画帧总数  
不是动画返回1

### gdipimageObject.width <a id="gdipimageObject.width" href="#gdipimageObject.width">&#x23;</a>
宽度
