diff --git a/zh-cn/application-dev/media/image-decoding.md b/zh-cn/application-dev/media/image-decoding.md index e29616d74ff332ec3ba98425607909e90e1ce803..c4f366e30d4df22b6dd2e518e441e67c77df66e6 100644 --- a/zh-cn/application-dev/media/image-decoding.md +++ b/zh-cn/application-dev/media/image-decoding.md @@ -39,8 +39,8 @@ ```ts // Stage模型参考如下代码 - const context : Context = getContext(this); - const filePath : string = context.cacheDir + '/test.jpg'; + const context = getContext(this); + const filePath = context.cacheDir + '/test.jpg'; const file : File = fs.openSync(filePath, fs.OpenMode.READ_WRITE); const fd : number = file?.fd; ``` @@ -60,7 +60,7 @@ // Stage模型 const context : Context = getContext(this); // 获取resourceManager资源管理器 - const resourceMgr : ResourceManager = context.resourceManager; + const resourceMgr : resmgr.ResourceManager = context.resourceManager; ``` ```ts @@ -73,7 +73,7 @@ 不同模型获取资源管理器的方式不同,获取资源管理器后,再调用resourceMgr.getRawFileContent()获取资源文件的ArrayBuffer。 ```ts - const fileData : Content = await resourceMgr.getRawFileContent('test.jpg'); + const fileData : void = await resourceMgr.getRawFileContent('test.jpg'); // 获取图片的ArrayBuffer const buffer = fileData.buffer; ``` @@ -126,13 +126,13 @@ ```ts const context : Context = getContext(this); // 获取resourceManager资源管理 - const resourceMgr : ResourceManager = context.resourceManager; + const resourceMgr : resmgr.ResourceManager = context.resourceManager; ``` 2. 获取rawfile文件夹下test.jpg的ArrayBuffer。 ```ts - const fileData : Content = await resourceMgr.getRawFileContent('test.jpg'); + const fileData : void = await resourceMgr.getRawFileContent('test.jpg'); // 获取图片的ArrayBuffer const buffer = fileData.buffer; ``` @@ -140,7 +140,7 @@ 3. 创建imageSource。 ```ts - const imageSource : ImageSource = image.createImageSource(buffer); + const imageSource : resmgr.ImageSource = image.createImageSource(buffer); ``` 4. 创建PixelMap。 diff --git a/zh-cn/application-dev/media/image-encoding.md b/zh-cn/application-dev/media/image-encoding.md index 21ac741da6bbb6cba167859a29fbd6ea907cbd0f..9dd6d2da953e52c76b025d0ab297cb3fbcb69f6d 100644 --- a/zh-cn/application-dev/media/image-encoding.md +++ b/zh-cn/application-dev/media/image-encoding.md @@ -20,7 +20,11 @@ format为图像的编码格式;quality为图像质量,范围从0-100,100为最佳质量。 ```ts - let packOpts : Context = { format:"image/jpeg", quality:98 }; + class PackOpts { + format : string = "" + quality : number = 0 + } + let packOpts : PackOpts = { format:"image/jpeg", quality:98 }; ``` 3. [创建PixelMap对象或创建ImageSource](image-decoding.md)对象。 @@ -30,9 +34,9 @@ 方法一:通过PixelMap进行编码。 ```ts - imagePackerApi.packing(pixelMap : PixelMap, packOpts).then( data => { + imagePackerApi.packing(pixelMap : PixelMap, packOpts : PackingOption).then( data => { // data 为打包获取到的文件流,写入文件保存即可得到一张图片 - }).catch(error : void => { + }).catch(error => { console.error('Failed to pack the image. And the error is: ' + error); }) ``` @@ -40,9 +44,9 @@ 方法二:通过imageSource进行编码。 ```ts - imagePackerApi.packing(imageSource, packOpts).then( data => { + imagePackerApi.packing(imageSource : ImageSource, packOpts : PackingOption).then( data => { // data 为打包获取到的文件流,写入文件保存即可得到一张图片 - }).catch(error : void => { + }).catch(error => { console.error('Failed to pack the image. And the error is: ' + error); }) ``` diff --git a/zh-cn/application-dev/media/image-pixelmap-operation.md b/zh-cn/application-dev/media/image-pixelmap-operation.md index d0706e4a6f3c8f54433d4a167410eee8aa3bab07..f327d2c6192000ce8237ecb79d460049706433a4 100644 --- a/zh-cn/application-dev/media/image-pixelmap-operation.md +++ b/zh-cn/application-dev/media/image-pixelmap-operation.md @@ -40,7 +40,7 @@ pixels: new ArrayBuffer(8), offset: 0, stride: 8, - region: { size: { height: 1, width: 2 }, x: 0, y: 0 } + region: { size : { height: 1, width: 2 }, x: 0, y: 0 } } pixelMap.readPixels(area).then(() => { console.info('Succeeded in reading the image data in the area.'); diff --git a/zh-cn/application-dev/media/image-tool.md b/zh-cn/application-dev/media/image-tool.md index 7fc7947bb0dd804e32e25b4302aea0578c4adb60..e628d615f3cd9075b8231cc6e66840347451ebf9 100644 --- a/zh-cn/application-dev/media/image-tool.md +++ b/zh-cn/application-dev/media/image-tool.md @@ -37,7 +37,7 @@ EXIF信息的读取与编辑相关API的详细介绍请参见[API参考](../refe // 编辑EXIF信息 imageSource.modifyImageProperty('ImageWidth', '120').then(() => { - const width : number = imageSource.getImageProperty("ImageWidth"); + const width : Promise = imageSource.getImageProperty("ImageWidth"); console.info('The new imageWidth is ' + width); }) ```