未验证 提交 348c7057 编写于 作者: 刘关鹏 提交者: Gitee

update zh-cn/application-dev/reference/apis/js-apis-image.md.

Signed-off-by: N刘关鹏 <liuguanpeng1@huawei.com>
上级 03af4feb
...@@ -41,7 +41,7 @@ let bufferArr : Uint8Array = new Uint8Array(color); ...@@ -41,7 +41,7 @@ let bufferArr : Uint8Array = new Uint8Array(color);
let opts : image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } let opts : image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelmap : image.PixelMap) => { image.createPixelMap(color, opts).then((pixelmap : image.PixelMap) => {
console.log('Succeeded in creating pixelmap.'); console.log('Succeeded in creating pixelmap.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('Failed to create pixelmap.'); console.log('Failed to create pixelmap.');
}) })
``` ```
...@@ -115,7 +115,7 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\<void> ...@@ -115,7 +115,7 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\<void>
const readBuffer : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4 const readBuffer : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
pixelmap.readPixelsToBuffer(readBuffer).then(() => { pixelmap.readPixelsToBuffer(readBuffer).then(() => {
console.log('Succeeded in reading image pixel data.'); //符合条件则进入 console.log('Succeeded in reading image pixel data.'); //符合条件则进入
}).catch(error => { }).catch((error : BusinessError) => {
console.log('Failed to read image pixel data.'); //不符合条件则进入 console.log('Failed to read image pixel data.'); //不符合条件则进入
}) })
``` ```
...@@ -179,7 +179,7 @@ const area : image.PositionArea = { ...@@ -179,7 +179,7 @@ const area : image.PositionArea = {
} }
pixelmap.readPixels(area).then(() => { pixelmap.readPixels(area).then(() => {
console.log('Succeeded in reading the image data in the area.'); //符合条件则进入 console.log('Succeeded in reading the image data in the area.'); //符合条件则进入
}).catch(error => { }).catch((error : BusinessError) => {
console.log('Failed to read the image data in the area.'); //不符合条件则进入 console.log('Failed to read the image data in the area.'); //不符合条件则进入
}) })
``` ```
...@@ -264,7 +264,7 @@ image.createPixelMap(color, opts) ...@@ -264,7 +264,7 @@ image.createPixelMap(color, opts)
pixelmap.writePixels(area).then(() => { pixelmap.writePixels(area).then(() => {
console.info('Succeeded to write pixelmap into the specified area.'); console.info('Succeeded to write pixelmap into the specified area.');
}) })
}).catch(error => { }).catch((error : BusinessError) => {
console.log('error: ' + error); console.log('error: ' + error);
}) })
``` ```
...@@ -335,7 +335,7 @@ for (var i = 0; i < bufferArr.length; i++) { ...@@ -335,7 +335,7 @@ for (var i = 0; i < bufferArr.length; i++) {
} }
pixelmap.writeBufferToPixels(color).then(() => { pixelmap.writeBufferToPixels(color).then(() => {
console.log("Succeeded in writing data from a buffer to a PixelMap."); console.log("Succeeded in writing data from a buffer to a PixelMap.");
}).catch((err) => { }).catch((error : BusinessError) => {
console.error("Failed to write data from a buffer to a PixelMap."); console.error("Failed to write data from a buffer to a PixelMap.");
}) })
``` ```
...@@ -1076,7 +1076,7 @@ release():Promise\<void> ...@@ -1076,7 +1076,7 @@ release():Promise\<void>
```js ```js
pixelmap.release().then(() => { pixelmap.release().then(() => {
console.log('Succeeded in releasing pixelmap object.'); console.log('Succeeded in releasing pixelmap object.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('Failed to release pixelmap object.'); console.log('Failed to release pixelmap object.');
}) })
``` ```
...@@ -1414,7 +1414,7 @@ getImageInfo(index?: number): Promise\<ImageInfo> ...@@ -1414,7 +1414,7 @@ getImageInfo(index?: number): Promise\<ImageInfo>
imageSourceApi.getImageInfo(0) imageSourceApi.getImageInfo(0)
.then((imageInfo : image.ImageInfo) => { .then((imageInfo : image.ImageInfo) => {
console.log('Succeeded in obtaining the image information.'); console.log('Succeeded in obtaining the image information.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('Failed to obtain the image information.'); console.log('Failed to obtain the image information.');
}) })
``` ```
...@@ -1644,7 +1644,7 @@ createPixelMap(options?: DecodingOptions): Promise\<PixelMap> ...@@ -1644,7 +1644,7 @@ createPixelMap(options?: DecodingOptions): Promise\<PixelMap>
```js ```js
imageSourceApi.createPixelMap().then((pixelmap : image.PixelMap) => { imageSourceApi.createPixelMap().then((pixelmap : image.PixelMap) => {
console.log('Succeeded in creating pixelmap object through image decoding parameters.'); console.log('Succeeded in creating pixelmap object through image decoding parameters.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('Failed to create pixelmap object through image decoding parameters.'); console.log('Failed to create pixelmap object through image decoding parameters.');
}) })
``` ```
...@@ -2007,7 +2007,7 @@ release(): Promise\<void> ...@@ -2007,7 +2007,7 @@ release(): Promise\<void>
```js ```js
imageSourceApi.release().then(()=>{ imageSourceApi.release().then(()=>{
console.log('Succeeded in releasing the image source instance.'); console.log('Succeeded in releasing the image source instance.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('Failed to release the image source instance.'); console.log('Failed to release the image source instance.');
}) })
``` ```
...@@ -2097,7 +2097,7 @@ let packOpts : image.PackingOption = { format:"image/jpeg", quality:98 } ...@@ -2097,7 +2097,7 @@ let packOpts : image.PackingOption = { format:"image/jpeg", quality:98 }
imagePackerApi.packing(imageSourceApi, packOpts) imagePackerApi.packing(imageSourceApi, packOpts)
.then( data : ArrayBuffer => { .then( data : ArrayBuffer => {
console.log('packing succeeded.'); console.log('packing succeeded.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('packing failed.'); console.log('packing failed.');
}) })
``` ```
...@@ -2164,7 +2164,7 @@ image.createPixelMap(color, opts).then((pixelmap : image.PixelMap) => { ...@@ -2164,7 +2164,7 @@ image.createPixelMap(color, opts).then((pixelmap : image.PixelMap) => {
imagePackerApi.packing(pixelmap, packOpts) imagePackerApi.packing(pixelmap, packOpts)
.then( data : ArrayBuffer => { .then( data : ArrayBuffer => {
console.log('Succeeded in packing the image.'); console.log('Succeeded in packing the image.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('Failed to pack the image..'); console.log('Failed to pack the image..');
}) })
}) })
...@@ -2211,7 +2211,7 @@ release(): Promise\<void> ...@@ -2211,7 +2211,7 @@ release(): Promise\<void>
```js ```js
imagePackerApi.release().then(()=>{ imagePackerApi.release().then(()=>{
console.log('Succeeded in releasing image packaging.'); console.log('Succeeded in releasing image packaging.');
}).catch((error)=>{ }).catch((error : BusinessError)=>{
console.log('Failed to release image packaging.'); console.log('Failed to release image packaging.');
}) })
``` ```
...@@ -2306,7 +2306,7 @@ getReceivingSurfaceId(): Promise\<string> ...@@ -2306,7 +2306,7 @@ getReceivingSurfaceId(): Promise\<string>
```js ```js
receiver.getReceivingSurfaceId().then( (id : string) => { receiver.getReceivingSurfaceId().then( (id : string) => {
console.log('getReceivingSurfaceId succeeded.'); console.log('getReceivingSurfaceId succeeded.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('getReceivingSurfaceId failed.'); console.log('getReceivingSurfaceId failed.');
}) })
``` ```
...@@ -2356,7 +2356,7 @@ readLatestImage(): Promise\<Image> ...@@ -2356,7 +2356,7 @@ readLatestImage(): Promise\<Image>
```js ```js
receiver.readLatestImage().then((img : image.Image) => { receiver.readLatestImage().then((img : image.Image) => {
console.log('readLatestImage succeeded.'); console.log('readLatestImage succeeded.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('readLatestImage failed.'); console.log('readLatestImage failed.');
}) })
``` ```
...@@ -2406,7 +2406,7 @@ readNextImage(): Promise\<Image> ...@@ -2406,7 +2406,7 @@ readNextImage(): Promise\<Image>
```js ```js
receiver.readNextImage().then((img : image.Image) => { receiver.readNextImage().then((img : image.Image) => {
console.log('readNextImage succeeded.'); console.log('readNextImage succeeded.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('readNextImage failed.'); console.log('readNextImage failed.');
}) })
``` ```
...@@ -2471,7 +2471,7 @@ release(): Promise\<void> ...@@ -2471,7 +2471,7 @@ release(): Promise\<void>
```js ```js
receiver.release().then(() => { receiver.release().then(() => {
console.log('release succeeded.'); console.log('release succeeded.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('release failed.'); console.log('release failed.');
}) })
``` ```
...@@ -2563,7 +2563,7 @@ dequeueImage(): Promise\<Image> ...@@ -2563,7 +2563,7 @@ dequeueImage(): Promise\<Image>
```js ```js
creator.dequeueImage().then((img : image.Image) => { creator.dequeueImage().then((img : image.Image) => {
console.info('dequeueImage succeeded.'); console.info('dequeueImage succeeded.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('dequeueImage failed: ' + error); console.log('dequeueImage failed: ' + error);
}) })
``` ```
...@@ -2643,7 +2643,7 @@ creator.dequeueImage().then((img : image.Image) => { ...@@ -2643,7 +2643,7 @@ creator.dequeueImage().then((img : image.Image) => {
}) })
creator.queueImage(img).then(() => { creator.queueImage(img).then(() => {
console.info('queueImage succeeded.'); console.info('queueImage succeeded.');
}).catch(error => { }).catch((error : BusinessError) => {
console.info('queueImage failed: ' + error); console.info('queueImage failed: ' + error);
}) })
}) })
...@@ -2719,7 +2719,7 @@ release(): Promise\<void> ...@@ -2719,7 +2719,7 @@ release(): Promise\<void>
```js ```js
creator.release().then(() => { creator.release().then(() => {
console.info('release succeeded'); console.info('release succeeded');
}).catch(error => { }).catch((error : BusinessError) => {
console.info('release failed'); console.info('release failed');
}) })
``` ```
...@@ -2836,7 +2836,7 @@ release(): Promise\<void> ...@@ -2836,7 +2836,7 @@ release(): Promise\<void>
```js ```js
img.release().then(() =>{ img.release().then(() =>{
console.log('release succeeded.'); console.log('release succeeded.');
}).catch(error => { }).catch((error : BusinessError) => {
console.log('release failed.'); console.log('release failed.');
}) })
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册