diff --git a/zh-cn/application-dev/media/image-decoding.md b/zh-cn/application-dev/media/image-decoding.md index 0bf549398dc30ed69aed778ec5c2ed614ca43b5f..86fe57babfc3aaf67bb5fadda536b133eb2d6945 100644 --- a/zh-cn/application-dev/media/image-decoding.md +++ b/zh-cn/application-dev/media/image-decoding.md @@ -41,7 +41,7 @@ // Stage模型参考如下代码 const context = getContext(this); const filePath = context.cacheDir + '/test.jpg'; - const file : File = fs.openSync(filePath, fs.OpenMode.READ_WRITE); + const file : fs.File = fs.openSync(filePath, fs.OpenMode.READ_WRITE); const fd : number = file?.fd; ``` @@ -51,7 +51,7 @@ const context = featureAbility.getContext(); const filePath = context.getCacheDir() + "/test.jpg"; - const file : File = fs.openSync(filePath, fs.OpenMode.READ_WRITE); + const file : fs.File = fs.openSync(filePath, fs.OpenMode.READ_WRITE); const fd : number = file?.fd; ``` - 方法三:通过资源管理器获取资源文件的ArrayBuffer。具体请参考[ResourceManager API参考文档](../reference/apis/js-apis-resource-manager.md#getrawfilecontent9-1)。 @@ -60,7 +60,7 @@ // Stage模型 const context : Context = getContext(this); // 获取resourceManager资源管理器 - const resourceMgr : resmgr.ResourceManager = context.resourceManager; + const resourceMgr : resourceManager.ResourceManager = context.resourceManager; ``` ```ts @@ -83,18 +83,18 @@ ```ts // path为已获得的沙箱路径 - const imageSource : ImageSource = image.createImageSource(filePath); + const imageSource : image.ImageSource = image.createImageSource(filePath); ``` - 方法二:通过文件描述符fd创建ImageSource。文件描述符可以通过步骤2的方法二获取。 ```ts // fd为已获得的文件描述符 - const imageSource : ImageSource = image.createImageSource(fd); + const imageSource : image.ImageSource = image.createImageSource(fd); ``` - 方法三:通过缓冲区数组创建ImageSource。缓冲区数组可以通过步骤2的方法三获取。 ```ts - const imageSource : ImageSource = image.createImageSource(buffer); + const imageSource : image.ImageSource = image.createImageSource(buffer); ``` 4. 设置解码参数DecodingOptions,解码获取PixelMap图片对象。 @@ -105,7 +105,7 @@ desiredPixelFormat: 3, } // 创建pixelMap并进行简单的旋转和缩放 - const pixelMap : PixelMap = await imageSource.createPixelMap(decodingOptions); + const pixelMap : image.PixelMap = await imageSource.createPixelMap(decodingOptions); ``` 解码完成,获取到PixelMap对象后,可以进行后续[图片处理](image-transformation.md)。 @@ -122,7 +122,7 @@ ```ts const context : Context = getContext(this); // 获取resourceManager资源管理 - const resourceMgr : resmgr.ResourceManager = context.resourceManager; + const resourceMgr : resourceManager.ResourceManager = context.resourceManager; ``` 2. 获取rawfile文件夹下test.jpg的ArrayBuffer。 @@ -136,13 +136,13 @@ 3. 创建imageSource。 ```ts - const imageSource : resmgr.ImageSource = image.createImageSource(buffer); + const imageSource : image.ImageSource = image.createImageSource(buffer); ``` 4. 创建PixelMap。 ```ts - const pixelMap : PixelMap = await imageSource.createPixelMap(); + const pixelMap : image.PixelMap = await imageSource.createPixelMap(); ``` 5. 释放pixelMap。 diff --git a/zh-cn/application-dev/media/image-encoding.md b/zh-cn/application-dev/media/image-encoding.md index 60c79e4ba94d3b651b08eb7c1992ddc27737949f..8a5ab62e15e1842b56b39994b115d15d143a92be 100644 --- a/zh-cn/application-dev/media/image-encoding.md +++ b/zh-cn/application-dev/media/image-encoding.md @@ -30,7 +30,7 @@ 方法一:通过PixelMap进行编码。 ```ts - imagePackerApi.packing(pixelMap : PixelMap, packOpts : image.PackingOption).then( data => { + imagePackerApi.packing(pixelMap, packOpts).then( data => { // data 为打包获取到的文件流,写入文件保存即可得到一张图片 }).catch(error => { console.error('Failed to pack the image. And the error is: ' + error); @@ -40,7 +40,7 @@ 方法二:通过imageSource进行编码。 ```ts - imagePackerApi.packing(imageSource : ImageSource, packOpts : image.PackingOption).then( data => { + imagePackerApi.packing(imageSource, packOpts).then( data => { // data 为打包获取到的文件流,写入文件保存即可得到一张图片 }).catch(error => { console.error('Failed to pack the image. And the error is: ' + error); diff --git a/zh-cn/application-dev/media/image-tool.md b/zh-cn/application-dev/media/image-tool.md index 4407bef007dc9fa21874d58aad221412ea5eaeff..cfd8a7a557f6ee1b86265d17dec704e0b19e1a2b 100644 --- a/zh-cn/application-dev/media/image-tool.md +++ b/zh-cn/application-dev/media/image-tool.md @@ -20,7 +20,7 @@ EXIF信息的读取与编辑相关API的详细介绍请参见[API参考](../refe // 获取沙箱路径创建ImageSource const fd : number = ...; // 获取需要被处理的图片的fd - const imageSource : ImageSource = image.createImageSource(fd); + const imageSource : image.ImageSource = image.createImageSource(fd); ``` 2. 读取、编辑EXIF信息。 @@ -37,7 +37,7 @@ EXIF信息的读取与编辑相关API的详细介绍请参见[API参考](../refe // 编辑EXIF信息 imageSource.modifyImageProperty('ImageWidth', '120').then(() => { - const width : string = imageSource.getImageProperty("ImageWidth"); + const width : Promise = imageSource.getImageProperty("ImageWidth"); console.info('The new imageWidth is ' + width); }) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index 15e663eb67d9bd63ad7b10f19d8a42ed74133565..69eded1155c4df06a9d23b48ff5836905fce7678 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -939,6 +939,7 @@ setColorSpace(colorSpace: colorSpaceManager.ColorSpaceManager): void ```js import colorSpaceManager from '@ohos.graphics.colorSpaceManager'; async function Demo() { + let colorSpaceName = colorSpaceManager.ColorSpace.SRGB; var csm = colorSpaceManager.create(colorSpaceName); pixelmap.setColorSpace(csm); } @@ -1023,6 +1024,7 @@ unmarshalling(sequence: rpc.MessageSequence): Promise\ | ------- | --------------------------------------------| | 62980115 | If the input parameter invalid | | 62980097 | If the ipc error | +| 62980096 | If the Operation failed | **示例:** @@ -1725,7 +1727,7 @@ createPixelMapList(options?: DecodingOptions): Promise>; | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 62980096| If the operation invalid | +| 62980096| If the operation failed | | 62980103| If the image data unsupport | | 62980110| If the image source data error | | 62980111| If the image source data incomplete | @@ -1765,7 +1767,7 @@ createPixelMapList(callback: AsyncCallback>): void | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 62980096| If the operation invalid | +| 62980096| If the operation failed | | 62980103| If the image data unsupport | | 62980110| If the image source data error | | 62980111| If the image source data incomplete | @@ -1800,7 +1802,7 @@ createPixelMapList(options: DecodingOptions, callback: AsyncCallback>): void; | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 62980096| If the operation invalid | +| 62980096| If the operation failed | | 62980110| If the image source data error | | 62980111| If the image source data incomplete | | 62980113| If the image format unknown | @@ -1878,7 +1880,7 @@ getDelayTimeList(): Promise>; | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 62980096| If the operation invalid | +| 62980096| If the operation failed | | 62980110| If the image source data error | | 62980111| If the image source data incomplete | | 62980113| If the image format unknown | @@ -1912,7 +1914,7 @@ getFrameCount(callback: AsyncCallback\): void; | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 62980096| If the operation invalid | +| 62980096| If the operation failed | | 62980110| If the image source data error | | 62980111| If the image source data incomplete | | 62980113| If the image format unknown | @@ -1942,6 +1944,20 @@ getFrameCount(): Promise\; | -------------- | --------------------------- | | Promise\ | Promise实例,异步返回图像帧数。 | +**错误码:** + +以下错误码的详细介绍请参见[Image错误码](../errorcodes/errorcode-image.md)。 + +| 错误码ID | 错误信息 | +| ------- | --------------------------------------------| +| 62980096| If the operation failed | +| 62980110| If the image source data error | +| 62980111| If the image source data incomplete | +| 62980113| If the image format unknown | +| 62980116| If the image decode failed | +| 62980118| If the image plugin create failed | +| 62980122| If the image decode head abnormal | + **示例:** ```js @@ -3005,6 +3021,7 @@ PixelMap的初始化选项。 | GPS_DATE_STAMP10+ | "GPSDateStamp" | GPS日期戳,当前为只读属性。 | | IMAGE_DESCRIPTION10+ | "ImageDescription" | 图像信息描述,当前为只读属性。 | | MAKE10+ | "Make" | 生产商,当前为只读属性。 | +| MODEL10+ | "Model" | 设备型号,当前为只读属性。 | | PHOTO_MODE10+ | "PhotoMode " | 拍照模式,当前为只读属性。 | | SENSITIVITY_TYPE10+ | "SensitivityType" | 灵敏度类型,当前为只读属性。 | | STANDARD_OUTPUT_SENSITIVITY10+ | "StandardOutputSensitivity" | 标准输出灵敏度,当前为只读属性。 |