提交 646c31c4 编写于 作者: W wusongqing

update docs against 5758

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 3c8dfac4
# Image Processing # Image Processing
> **NOTE**<br/> > **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -20,7 +21,7 @@ Creates a **PixelMap** object. This API uses a promise to return the result. ...@@ -20,7 +21,7 @@ Creates a **PixelMap** object. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ | | ------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
| colors | ArrayBuffer | Yes | Color array. | | colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. |
| options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.| | options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
**Return value** **Return value**
...@@ -32,7 +33,9 @@ Creates a **PixelMap** object. This API uses a promise to return the result. ...@@ -32,7 +33,9 @@ Creates a **PixelMap** object. This API uses a promise to return the result.
**Example** **Example**
```js ```js
image.createPixelMap(Color, opts) const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then((pixelmap) => { .then((pixelmap) => {
}) })
``` ```
...@@ -49,14 +52,16 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return ...@@ -49,14 +52,16 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------------- | | -------- | ------------------------------------------------ | ---- | -------------------------- |
| colors | ArrayBuffer | Yes | Color array. | | colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. |
| options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties. | | options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties. |
| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.| | callback | AsyncCallback\<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.|
**Example** **Example**
```js ```js
image.createPixelMap(Color, opts, (pixelmap) => { const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) => {
}) })
``` ```
...@@ -95,11 +100,11 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u ...@@ -95,11 +100,11 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
**Example** **Example**
```js ```js
pixelmap.readPixelsToBuffer(readBuffer).then(() => { pixelmap.readPixelsToBuffer(ReadBuffer).then(() => {
// Called if the condition is met. console.log('readPixelsToBuffer succeeded.'); // Called if the condition is met.
}).catch(error => { }).catch(error => {
// Called if no condition is met. console.log('readPixelsToBuffer failed.'); // Called if no condition is met.
}) })
``` ```
### readPixelsToBuffer<sup>7+</sup> ### readPixelsToBuffer<sup>7+</sup>
...@@ -120,8 +125,13 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u ...@@ -120,8 +125,13 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
**Example** **Example**
```js ```js
pixelmap.readPixelsToBuffer(readBuffer, () => { pixelmap.readPixelsToBuffer(ReadBuffer, (err, res) => {
}) if(err) {
console.log('readPixelsToBuffer failed.'); // Called if the condition is met.
} else {
console.log('readPixelsToBuffer succeeded.'); // Called if the condition is met.
}
})
``` ```
### readPixels<sup>7+</sup> ### readPixels<sup>7+</sup>
...@@ -147,11 +157,11 @@ Reads image pixel map data in an area. This API uses a promise to return the dat ...@@ -147,11 +157,11 @@ Reads image pixel map data in an area. This API uses a promise to return the dat
**Example** **Example**
```js ```js
pixelmap.readPixels(area).then((data) => { pixelmap.readPixels(Area).then((data) => {
// Called if the condition is met. console.log('readPixels succeeded.'); // Called if the condition is met.
}).catch(error => { }).catch(error => {
// Called if no condition is met. console.log('readPixels failed.'); // Called if no condition is met.
}) })
``` ```
### readPixels<sup>7+</sup> ### readPixels<sup>7+</sup>
...@@ -175,14 +185,12 @@ Reads image pixel map data in an area. This API uses an asynchronous callback to ...@@ -175,14 +185,12 @@ Reads image pixel map data in an area. This API uses an asynchronous callback to
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => { image.createPixelMap(color, opts, (err, pixelmap) => {
if(pixelmap == undefined){ if(pixelmap == undefined){
console.info('createPixelMap failed'); console.info('createPixelMap failed.');
expect(false).assertTrue(); } else {
done();
}else{
const area = { pixels: new ArrayBuffer(8), const area = { 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, () => { pixelmap.readPixels(area, () => {
console.info('readPixels success'); console.info('readPixels success');
}) })
...@@ -218,9 +226,7 @@ let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } ...@@ -218,9 +226,7 @@ let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts) image.createPixelMap(color, opts)
.then( pixelmap => { .then( pixelmap => {
if (pixelmap == undefined) { if (pixelmap == undefined) {
console.info('createPixelMap failed'); console.info('createPixelMap failed.');
expect(false).assertTrue()
done();
} }
const area = { pixels: new ArrayBuffer(8), const area = { pixels: new ArrayBuffer(8),
offset: 0, offset: 0,
...@@ -240,11 +246,8 @@ image.createPixelMap(color, opts) ...@@ -240,11 +246,8 @@ image.createPixelMap(color, opts)
region: { size: { height: 1, width: 2 }, x: 0, y: 0 } region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
} }
}) })
}) }).catch(error => {
.catch(error => {
console.log('error: ' + error); console.log('error: ' + error);
expect().assertFail();
done();
}) })
``` ```
...@@ -266,14 +269,14 @@ Writes image pixel map data to an area. This API uses an asynchronous callback t ...@@ -266,14 +269,14 @@ Writes image pixel map data to an area. This API uses an asynchronous callback t
**Example** **Example**
```js ```js
pixelmap.writePixels(area, () => { pixelmap.writePixels(Area, () => {
const readArea = { const readArea = {
pixels: new ArrayBuffer(20), pixels: new ArrayBuffer(20),
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 },
} }
}) })
``` ```
### writeBufferToPixels<sup>7+</sup> ### writeBufferToPixels<sup>7+</sup>
...@@ -299,11 +302,11 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj ...@@ -299,11 +302,11 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
**Example** **Example**
```js ```js
pixelMap.writeBufferToPixels(colorBuffer).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((err) => {
console.error("Failed to write data from a buffer to a PixelMap."); console.error("Failed to write data from a buffer to a PixelMap.");
}); })
``` ```
### writeBufferToPixels<sup>7+</sup> ### writeBufferToPixels<sup>7+</sup>
...@@ -324,12 +327,13 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj ...@@ -324,12 +327,13 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
**Example** **Example**
```js ```js
pixelMap.writeBufferToPixels(colorBuffer, function(err) { PixelMap.writeBufferToPixels(color, function(err) {
if (err) { if (err) {
console.error("Failed to write data from a buffer to a PixelMap."); console.error("Failed to write data from a buffer to a PixelMap.");
return; return;
} } else {
console.log("Succeeded in writing data from a buffer to a PixelMap."); console.log("Succeeded in writing data from a buffer to a PixelMap.");
}
}); });
``` ```
...@@ -350,7 +354,7 @@ Obtains pixel map information of this image. This API uses a promise to return t ...@@ -350,7 +354,7 @@ Obtains pixel map information of this image. This API uses a promise to return t
**Example** **Example**
```js ```js
pixelMap.getImageInfo().then(function(info) { PixelMap.getImageInfo().then(function(info) {
console.log("Succeeded in obtaining the image pixel map information."); console.log("Succeeded in obtaining the image pixel map information.");
}).catch((err) => { }).catch((err) => {
console.error("Failed to obtain the image pixel map information."); console.error("Failed to obtain the image pixel map information.");
...@@ -374,7 +378,11 @@ Obtains pixel map information of this image. This API uses an asynchronous callb ...@@ -374,7 +378,11 @@ Obtains pixel map information of this image. This API uses an asynchronous callb
**Example** **Example**
```js ```js
pixelmap.getImageInfo((imageInfo) => {}) pixelmap.getImageInfo((imageInfo) => {
console.log("getImageInfo succeeded.");
}).catch((err) => {
console.error("getImageInfo failed.");
})
``` ```
### getBytesNumberPerRow<sup>7+</sup> ### getBytesNumberPerRow<sup>7+</sup>
...@@ -394,7 +402,9 @@ Obtains the number of bytes per line of the image pixel map. ...@@ -394,7 +402,9 @@ Obtains the number of bytes per line of the image pixel map.
**Example** **Example**
```js ```js
rowCount = pixelmap.getBytesNumberPerRow() image.createPixelMap(clolr, opts, (err,pixelmap) => {
let rowCount = pixelmap.getBytesNumberPerRow();
})
``` ```
### getPixelBytesNumber<sup>7+</sup> ### getPixelBytesNumber<sup>7+</sup>
...@@ -414,7 +424,7 @@ Obtains the total number of bytes of the image pixel map. ...@@ -414,7 +424,7 @@ Obtains the total number of bytes of the image pixel map.
**Example** **Example**
```js ```js
pixelBytesNumber = pixelmap.getPixelBytesNumber() let pixelBytesNumber = pixelmap.getPixelBytesNumber();
``` ```
### release<sup>7+</sup> ### release<sup>7+</sup>
...@@ -434,8 +444,13 @@ Releases this **PixelMap** object. This API uses a promise to return the result. ...@@ -434,8 +444,13 @@ Releases this **PixelMap** object. This API uses a promise to return the result.
**Example** **Example**
```js ```js
pixelmap.release().then(() => { }) image.createPixelMap(color, opts, (pixelmap) => {
.catch(error => {}) pixelmap.release().then(() => {
console.log('release succeeded.');
}).catch(error => {
console.log('release failed.');
})
})
``` ```
### release<sup>7+</sup> ### release<sup>7+</sup>
...@@ -455,7 +470,13 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret ...@@ -455,7 +470,13 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret
**Example** **Example**
```js ```js
pixelmap.release(()=>{ }) image.createPixelMap(color, opts, (pixelmap) => {
pixelmap.release().then(() => {
console.log('release succeeded.');
}).catch(error => {
console.log('release failed.');
})
})
``` ```
## image.createImageSource ## image.createImageSource
...@@ -508,7 +529,7 @@ Creates an **ImageSource** instance based on the file descriptor. ...@@ -508,7 +529,7 @@ Creates an **ImageSource** instance based on the file descriptor.
**Example** **Example**
```js ```js
const imageSourceApi = image.createImageSource(0) const imageSourceApi = image.createImageSource(0);
``` ```
## ImageSource ## ImageSource
...@@ -541,7 +562,13 @@ Obtains information about an image with the specified index. This API uses an as ...@@ -541,7 +562,13 @@ Obtains information about an image with the specified index. This API uses an as
**Example** **Example**
```js ```js
imageSourceApi.getImageInfo(0,(error, imageInfo) => {}) imageSourceApi.getImageInfo(0,(error, imageInfo) => {
if(error) {
console.log('getImageInfo failed.');
} else {
console.log('getImageInfo succeeded.');
}
})
``` ```
### getImageInfo ### getImageInfo
...@@ -561,7 +588,11 @@ Obtains information about this image. This API uses an asynchronous callback to ...@@ -561,7 +588,11 @@ Obtains information about this image. This API uses an asynchronous callback to
**Example** **Example**
```js ```js
imageSourceApi.getImageInfo(imageInfo => {}) imageSourceApi.getImageInfo(imageInfo => {
console.log('getImageInfo succeeded.');
}).catch(error => {
console.log('getImageInfo failed.');
})
``` ```
### getImageInfo ### getImageInfo
...@@ -588,8 +619,11 @@ Obtains information about an image with the specified index. This API uses a pro ...@@ -588,8 +619,11 @@ Obtains information about an image with the specified index. This API uses a pro
```js ```js
imageSourceApi.getImageInfo(0) imageSourceApi.getImageInfo(0)
.then(imageInfo => {}) .then(imageInfo => {
.catch(error => {}) console.log('getImageInfo succeeded.');
}).catch(error => {
console.log('getImageInfo failed.');
})
``` ```
### getImageProperty<sup>7+</sup> ### getImageProperty<sup>7+</sup>
...@@ -617,8 +651,11 @@ Obtains the value of a property with the specified index in this image. This API ...@@ -617,8 +651,11 @@ Obtains the value of a property with the specified index in this image. This API
```js ```js
imageSourceApi.getImageProperty("BitsPerSample") imageSourceApi.getImageProperty("BitsPerSample")
.then(data => {}) .then(data => {
.catch(error => {}) console.log('getImageProperty succeeded.');
}).catch(error => {
console.log('getImageProperty failed.');
})
``` ```
### getImageProperty<sup>7+</sup> ### getImageProperty<sup>7+</sup>
...@@ -639,7 +676,13 @@ Obtains the value of a property with the specified index in this image. This API ...@@ -639,7 +676,13 @@ Obtains the value of a property with the specified index in this image. This API
**Example** **Example**
```js ```js
imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {}) imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {
if(error) {
console.log('getImageProperty failed.');
} else {
console.log('getImageProperty succeeded.');
}
})
``` ```
### getImageProperty<sup>7+</sup> ### getImageProperty<sup>7+</sup>
...@@ -661,7 +704,13 @@ Obtains the value of a property in this image. This API uses an asynchronous cal ...@@ -661,7 +704,13 @@ Obtains the value of a property in this image. This API uses an asynchronous cal
**Example** **Example**
```js ```js
imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {}) imageSourceApi.getImageProperty("BitsPerSample",Property,(error,data) => {
if(error) {
console.log('getImageProperty failed.');
} else {
console.log('getImageProperty succeeded.');
}
})
``` ```
### createPixelMap<sup>7+</sup> ### createPixelMap<sup>7+</sup>
...@@ -687,8 +736,11 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses ...@@ -687,8 +736,11 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Example** **Example**
```js ```js
imageSourceApi.createPixelMap().then(pixelmap => {}) imageSourceApi.createPixelMap().then(pixelmap => {
.catch(error => {}) console.log('createPixelMap succeeded.');
}).catch(error => {
console.log('createPixelMap failed.');
})
``` ```
### createPixelMap<sup>7+</sup> ### createPixelMap<sup>7+</sup>
...@@ -708,7 +760,11 @@ Creates a **PixelMap** object based on the default parameters. This API uses an ...@@ -708,7 +760,11 @@ Creates a **PixelMap** object based on the default parameters. This API uses an
**Example** **Example**
```js ```js
imageSourceApi.createPixelMap(pixelmap => {}) imageSourceApi.createPixelMap(pixelmap => {
console.log('createPixelMap succeeded.');
}).catch(error => {
console.log('createPixelMap failed.');
})
``` ```
### createPixelMap<sup>7+</sup> ### createPixelMap<sup>7+</sup>
...@@ -729,7 +785,11 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses ...@@ -729,7 +785,11 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Example** **Example**
```js ```js
imageSourceApi.createPixelMap(decodingOptions, pixelmap => {}) imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
console.log('createPixelMap succeeded.');
}).catch(error => {
console.log('createPixelMap failed.');
})
``` ```
### release ### release
...@@ -749,7 +809,11 @@ Releases this **ImageSource** instance. This API uses an asynchronous callback t ...@@ -749,7 +809,11 @@ Releases this **ImageSource** instance. This API uses an asynchronous callback t
**Example** **Example**
```js ```js
imageSourceApi.release(() => {}) imageSourceApi.release(() => {
console.log('release succeeded.');
}).catch(error => {
console.log('release failed.');
})
``` ```
### release ### release
...@@ -769,7 +833,11 @@ Releases this **ImageSource** instance. This API uses a promise to return the re ...@@ -769,7 +833,11 @@ Releases this **ImageSource** instance. This API uses a promise to return the re
**Example** **Example**
```js ```js
imageSourceApi.release().then(()=>{ }).catch(error => {}) imageSourceApi.release().then(()=>{
console.log('release succeeded.');
}).catch(error => {
console.log('release failed.');
})
``` ```
## image.createImagePacker ## image.createImagePacker
...@@ -823,8 +891,8 @@ Packs an image. This API uses an asynchronous callback to return the result. ...@@ -823,8 +891,8 @@ Packs an image. This API uses an asynchronous callback to return the result.
**Example** **Example**
```js ```js
let packOpts = { format:["image/jpeg"], quality:98 } let packOpts = { format:["image/jpeg"], quality:98 };
imagePackerApi.packing(imageSourceApi, packOpts, data => {}) imagePackerApi.packing(ImageSourceApi, packOpts, data => {})
``` ```
### packing ### packing
...@@ -852,9 +920,12 @@ Packs an image. This API uses a promise to return the result. ...@@ -852,9 +920,12 @@ Packs an image. This API uses a promise to return the result.
```js ```js
let packOpts = { format:["image/jpeg"], quality:98 } let packOpts = { format:["image/jpeg"], quality:98 }
imagePackerApi.packing(imageSourceApi, packOpts) imagePackerApi.packing(ImageSourceApi, packOpts)
.then( data => { }) .then( data => {
.catch(error => {}) console.log('packing succeeded.');
}).catch(error => {
console.log('packing failed.');
})
``` ```
### packing<sup>8+</sup> ### packing<sup>8+</sup>
...@@ -877,7 +948,11 @@ Packs an image. This API uses an asynchronous callback to return the result. ...@@ -877,7 +948,11 @@ Packs an image. This API uses an asynchronous callback to return the result.
```js ```js
let packOpts = { format:["image/jpeg"], quality:98 } let packOpts = { format:["image/jpeg"], quality:98 }
imagePackerApi.packing(pixelMapApi, packOpts, data => {}) imagePackerApi.packing(PixelMapApi, packOpts, data => {
console.log('packing succeeded.');
}).catch(error => {
console.log('packing failed.');
})
``` ```
### packing<sup>8+</sup> ### packing<sup>8+</sup>
...@@ -905,9 +980,12 @@ Packs an image. This API uses a promise to return the result. ...@@ -905,9 +980,12 @@ Packs an image. This API uses a promise to return the result.
```js ```js
let packOpts = { format:["image/jpeg"], quality:98 } let packOpts = { format:["image/jpeg"], quality:98 }
imagePackerApi.packing(pixelMapApi, packOpts) imagePackerApi.packing(PixelMapApi, packOpts)
.then( data => { }) .then( data => {
.catch(error => {}) console.log('packing succeeded.');
}).catch(error => {
console.log('packing failed.');
})
``` ```
### release ### release
...@@ -927,7 +1005,11 @@ Releases this **ImagePacker** instance. This API uses an asynchronous callback t ...@@ -927,7 +1005,11 @@ Releases this **ImagePacker** instance. This API uses an asynchronous callback t
**Example** **Example**
```js ```js
imagePackerApi.release(()=>{}) imagePackerApi.release(()=>{
console.log('release succeeded.');
}).catch(error => {
console.log('release failed.');
})
``` ```
### release ### release
...@@ -947,8 +1029,11 @@ Releases this **ImagePacker** instance. This API uses a promise to return the re ...@@ -947,8 +1029,11 @@ Releases this **ImagePacker** instance. This API uses a promise to return the re
**Example** **Example**
```js ```js
imagePackerApi.release().then(()=>{ imagePackerApi.release().then(()=>{
}).catch((error)=>{}) console.log('release succeeded.');
}).catch((error)=>{
console.log('release failed.');
})
``` ```
## image.createImageReceiver<sup>9+</sup> ## image.createImageReceiver<sup>9+</sup>
...@@ -977,7 +1062,7 @@ Create an **ImageReceiver** instance by specifying the image width, height, form ...@@ -977,7 +1062,7 @@ Create an **ImageReceiver** instance by specifying the image width, height, form
**Example** **Example**
```js ```js
var receiver = image.createImageReceiver(8192, 8, 4, 8) var receiver = image.createImageReceiver(8192, 8, 4, 8);
``` ```
## ImageReceiver<sup>9+</sup> ## ImageReceiver<sup>9+</sup>
...@@ -1013,7 +1098,13 @@ Obtains a surface ID for the camera or other components. This API uses an asynch ...@@ -1013,7 +1098,13 @@ Obtains a surface ID for the camera or other components. This API uses an asynch
**Example** **Example**
```js ```js
receiver.getReceivingSurfaceId((err, id) => {}); receiver.getReceivingSurfaceId((err, id) => {
if(err) {
console.log('getReceivingSurfaceId failed.');
} else {
console.log('getReceivingSurfaceId succeeded.');
}
});
``` ```
### getReceivingSurfaceId<sup>9+</sup> ### getReceivingSurfaceId<sup>9+</sup>
...@@ -1034,8 +1125,10 @@ Obtains a surface ID for the camera or other components. This API uses a promise ...@@ -1034,8 +1125,10 @@ Obtains a surface ID for the camera or other components. This API uses a promise
```js ```js
receiver.getReceivingSurfaceId().then( id => { receiver.getReceivingSurfaceId().then( id => {
}).catch(error => { console.log('getReceivingSurfaceId succeeded.');
}) }).catch(error => {
console.log('getReceivingSurfaceId failed.');
})
``` ```
### readLatestImage<sup>9+</sup> ### readLatestImage<sup>9+</sup>
...@@ -1055,7 +1148,13 @@ Reads the latest image from the **ImageReceiver** instance. This API uses an asy ...@@ -1055,7 +1148,13 @@ Reads the latest image from the **ImageReceiver** instance. This API uses an asy
**Example** **Example**
```js ```js
receiver.readLatestImage((err, img) => { }); receiver.readLatestImage((err, img) => {
if(err) {
console.log('readLatestImage failed.');
} else {
console.log('readLatestImage succeeded.');
}
});
``` ```
### readLatestImage<sup>9+</sup> ### readLatestImage<sup>9+</sup>
...@@ -1075,8 +1174,11 @@ Reads the latest image from the **ImageReceiver** instance. This API uses a prom ...@@ -1075,8 +1174,11 @@ Reads the latest image from the **ImageReceiver** instance. This API uses a prom
**Example** **Example**
```js ```js
receiver.readLatestImage().then(img => {}) receiver.readLatestImage().then(img => {
.catch(error => {}) console.log('readLatestImage succeeded.');
}).catch(error => {
console.log('readLatestImage failed.');
})
``` ```
### readNextImage<sup>9+</sup> ### readNextImage<sup>9+</sup>
...@@ -1096,7 +1198,13 @@ Reads the next image from the **ImageReceiver** instance. This API uses an async ...@@ -1096,7 +1198,13 @@ Reads the next image from the **ImageReceiver** instance. This API uses an async
**Example** **Example**
```js ```js
receiver.readNextImage((err, img) => {}); receiver.readNextImage((err, img) => {
if(err) {
console.log('readNextImage failed.');
} else {
console.log('readNextImage succeeded.');
}
});
``` ```
### readNextImage<sup>9+</sup> ### readNextImage<sup>9+</sup>
...@@ -1116,9 +1224,11 @@ Reads the next image from the **ImageReceiver** instance. This API uses a promis ...@@ -1116,9 +1224,11 @@ Reads the next image from the **ImageReceiver** instance. This API uses a promis
**Example** **Example**
```js ```js
receiver.readNextImage().then(img => { receiver.readNextImage().then(img => {
}).catch(error => { console.log('readNextImage succeeded.');
}) }).catch(error => {
console.log('readNextImage failed.');
})
``` ```
### on('imageArrival')<sup>9+</sup> ### on('imageArrival')<sup>9+</sup>
...@@ -1139,7 +1249,7 @@ Listens for image arrival events. ...@@ -1139,7 +1249,7 @@ Listens for image arrival events.
**Example** **Example**
```js ```js
receiver.on('imageArrival', () => {}) receiver.on('imageArrival', () => {})
``` ```
### release<sup>9+</sup> ### release<sup>9+</sup>
...@@ -1159,7 +1269,7 @@ Releases this **ImageReceiver** instance. This API uses an asynchronous callback ...@@ -1159,7 +1269,7 @@ Releases this **ImageReceiver** instance. This API uses an asynchronous callback
**Example** **Example**
```js ```js
receiver.release(() => {}) receiver.release(() => {})
``` ```
### release<sup>9+</sup> ### release<sup>9+</sup>
...@@ -1179,8 +1289,11 @@ Releases this **ImageReceiver** instance. This API uses a promise to return the ...@@ -1179,8 +1289,11 @@ Releases this **ImageReceiver** instance. This API uses a promise to return the
**Example** **Example**
```js ```js
receiver.release().then(() => {}) receiver.release().then(() => {
.catch(error => {}) console.log('release succeeded.');
}).catch(error => {
console.log('release failed.');
})
``` ```
## Image<sup>9+</sup> ## Image<sup>9+</sup>
...@@ -1215,7 +1328,13 @@ Obtains the component buffer from the **Image** instance based on the color comp ...@@ -1215,7 +1328,13 @@ Obtains the component buffer from the **Image** instance based on the color comp
**Example** **Example**
```js ```js
img.getComponent(4, (err, component) => {}) img.getComponent(4, (err, component) => {
if(err) {
console.log('getComponent failed.');
} else {
console.log('getComponent succeeded.');
}
})
``` ```
### getComponent<sup>9+</sup> ### getComponent<sup>9+</sup>
...@@ -1263,7 +1382,11 @@ The corresponding resources must be released before another image arrives. ...@@ -1263,7 +1382,11 @@ The corresponding resources must be released before another image arrives.
**Example** **Example**
```js ```js
img.release(() =>{ }) img.release(() =>{
console.log('release succeeded.');
}).catch(error => {
console.log('release failed.');
})
``` ```
### release<sup>9+</sup> ### release<sup>9+</sup>
...@@ -1286,8 +1409,10 @@ The corresponding resources must be released before another image arrives. ...@@ -1286,8 +1409,10 @@ The corresponding resources must be released before another image arrives.
```js ```js
img.release().then(() =>{ img.release().then(() =>{
}).catch(error => { console.log('release succeeded.');
}) }).catch(error => {
console.log('release failed.');
})
``` ```
## PositionArea<sup>7+</sup> ## PositionArea<sup>7+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册