未验证 提交 3bbcc7fd 编写于 作者: O openharmony_ci 提交者: Gitee

!23506 示例代码整改

Merge pull request !23506 from 朱静茹/master
...@@ -100,11 +100,11 @@ ...@@ -100,11 +100,11 @@
4. 设置解码参数DecodingOptions,解码获取PixelMap图片对象。 4. 设置解码参数DecodingOptions,解码获取PixelMap图片对象。
```ts ```ts
class decodingOption { class DecodingOption {
flag : boolean = true editable : boolean = true
n : number = 0 desiredPixelFormat : number = 0
} }
let decodingOptions = { let decodingOptions : DecodingOption = {
editable: true, editable: true,
desiredPixelFormat: 3, desiredPixelFormat: 3,
} }
......
...@@ -20,11 +20,7 @@ ...@@ -20,11 +20,7 @@
format为图像的编码格式;quality为图像质量,范围从0-100,100为最佳质量。 format为图像的编码格式;quality为图像质量,范围从0-100,100为最佳质量。
```ts ```ts
class PackOpts { let packOpts : image.PackingOption = { format:"image/jpeg", quality:98 };
format : string = ""
quality : number = 0
}
let packOpts : PackOpts = { format:"image/jpeg", quality:98 };
``` ```
3. [创建PixelMap对象或创建ImageSource](image-decoding.md)对象。 3. [创建PixelMap对象或创建ImageSource](image-decoding.md)对象。
...@@ -34,7 +30,7 @@ ...@@ -34,7 +30,7 @@
方法一:通过PixelMap进行编码。 方法一:通过PixelMap进行编码。
```ts ```ts
imagePackerApi.packing(pixelMap : PixelMap, packOpts : PackingOption).then( data => { imagePackerApi.packing(pixelMap : PixelMap, packOpts : image.PackingOption).then( data => {
// data 为打包获取到的文件流,写入文件保存即可得到一张图片 // data 为打包获取到的文件流,写入文件保存即可得到一张图片
}).catch(error => { }).catch(error => {
console.error('Failed to pack the image. And the error is: ' + error); console.error('Failed to pack the image. And the error is: ' + error);
...@@ -44,7 +40,7 @@ ...@@ -44,7 +40,7 @@
方法二:通过imageSource进行编码。 方法二:通过imageSource进行编码。
```ts ```ts
imagePackerApi.packing(imageSource : ImageSource, packOpts : PackingOption).then( data => { imagePackerApi.packing(imageSource : ImageSource, packOpts : image.PackingOption).then( data => {
// data 为打包获取到的文件流,写入文件保存即可得到一张图片 // data 为打包获取到的文件流,写入文件保存即可得到一张图片
}).catch(error => { }).catch(error => {
console.error('Failed to pack the image. And the error is: ' + error); console.error('Failed to pack the image. And the error is: ' + error);
......
...@@ -36,11 +36,11 @@ ...@@ -36,11 +36,11 @@
}) })
// 场景二:读取指定区域内的图片数据,结果写入area.pixels中 // 场景二:读取指定区域内的图片数据,结果写入area.pixels中
const area = { const area : image.PositionArea = {
pixels: new ArrayBuffer(8), pixels: new ArrayBuffer(8),
offset: 0, offset: 0,
stride: 8, 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(() => { pixelMap.readPixels(area).then(() => {
console.info('Succeeded in reading the image data in the area.'); console.info('Succeeded in reading the image data in the area.');
......
...@@ -27,7 +27,7 @@ EXIF信息的读取与编辑相关API的详细介绍请参见[API参考](../refe ...@@ -27,7 +27,7 @@ EXIF信息的读取与编辑相关API的详细介绍请参见[API参考](../refe
```ts ```ts
// 读取EXIF信息,BitsPerSample为每个像素比特数 // 读取EXIF信息,BitsPerSample为每个像素比特数
imageSource.getImageProperty('BitsPerSample', (error : void, data : BitsPerSample) => { imageSource.getImageProperty('BitsPerSample', (error, data : GetImagePropertyOptions) => {
if (error) { if (error) {
console.error('Failed to get the value of the specified attribute key of the image.And the error is: ' + error); console.error('Failed to get the value of the specified attribute key of the image.And the error is: ' + error);
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册