提交 5beb0504 编写于 作者: W wusongqing

update docs against 6198

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 c1924865
...@@ -34,6 +34,7 @@ Creates a **PixelMap** object. This API uses a promise to return the result. ...@@ -34,6 +34,7 @@ Creates a **PixelMap** object. This API uses a promise to return the result.
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
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) image.createPixelMap(color, opts)
.then((pixelmap) => { .then((pixelmap) => {
...@@ -60,6 +61,7 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return ...@@ -60,6 +61,7 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
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, (pixelmap) => { image.createPixelMap(color, opts, (pixelmap) => {
}) })
...@@ -100,10 +102,11 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u ...@@ -100,10 +102,11 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
**Example** **Example**
```js ```js
pixelmap.readPixelsToBuffer(ReadBuffer).then(() => { const readBuffer = new ArrayBuffer(400);
console.log('readPixelsToBuffer succeeded.'); // Called if the condition is met. pixelmap.readPixelsToBuffer(readBuffer).then(() => {
console.log('Succeeded in reading image pixel data.'); // Called if the condition is met.
}).catch(error => { }).catch(error => {
console.log('readPixelsToBuffer failed.'); // Called if no condition is met. ('Failed to read image pixel data.'); // Called if no condition is met.
}) })
``` ```
...@@ -125,11 +128,12 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u ...@@ -125,11 +128,12 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
**Example** **Example**
```js ```js
pixelmap.readPixelsToBuffer(ReadBuffer, (err, res) => { const readBuffer = new ArrayBuffer(400);
pixelmap.readPixelsToBuffer(readBuffer, (err, res) => {
if(err) { if(err) {
console.log('readPixelsToBuffer failed.'); // Called if the condition is met. console.log('Failed to read image pixel data.'); // Called if no condition is met.
} else { } else {
console.log('readPixelsToBuffer succeeded.'); // Called if the condition is met. console.log('Succeeded in reading image pixel data.'); // Called if the condition is met.
} }
}) })
``` ```
...@@ -157,10 +161,11 @@ Reads image pixel map data in an area. This API uses a promise to return the dat ...@@ -157,10 +161,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) => { const area = new ArrayBuffer(400);
console.log('readPixels succeeded.'); // Called if the condition is met. pixelmap.readPixels(area).then(() => {
console.log('Succeeded in reading the image data in the area.'); // Called if the condition is met.
}).catch(error => { }).catch(error => {
console.log('readPixels failed.'); // Called if no condition is met. console.log('Failed to read the image data in the area.'); // Called if no condition is met.
}) })
``` ```
...@@ -182,6 +187,8 @@ Reads image pixel map data in an area. This API uses an asynchronous callback to ...@@ -182,6 +187,8 @@ Reads image pixel map data in an area. This API uses an asynchronous callback to
**Example** **Example**
```js ```js
const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
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){
...@@ -222,6 +229,7 @@ Writes image pixel map data to an area. This API uses a promise to return the op ...@@ -222,6 +229,7 @@ Writes image pixel map data to an area. This API uses a promise to return the op
```js ```js
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
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) image.createPixelMap(color, opts)
.then( pixelmap => { .then( pixelmap => {
...@@ -233,7 +241,7 @@ image.createPixelMap(color, opts) ...@@ -233,7 +241,7 @@ image.createPixelMap(color, opts)
stride: 8, stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 } region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
} }
var bufferArr = new Uint8Array(area.pixels); let bufferArr = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) { for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1; bufferArr[i] = i + 1;
} }
...@@ -269,13 +277,18 @@ Writes image pixel map data to an area. This API uses an asynchronous callback t ...@@ -269,13 +277,18 @@ Writes image pixel map data to an area. This API uses an asynchronous callback t
**Example** **Example**
```js ```js
pixelmap.writePixels(Area, () => { const area = new ArrayBuffer(400);
const readArea = { pixelmap.writePixels(area, (error) => {
pixels: new ArrayBuffer(20), if (error!=undefined) {
offset: 0, console.info('Failed to write pixelmap into the specified area.');
stride: 8, } else {
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }, const readArea = {
} pixels: new ArrayBuffer(20),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 },
}
}
}) })
``` ```
...@@ -302,7 +315,10 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj ...@@ -302,7 +315,10 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
**Example** **Example**
```js ```js
PixelMap.writeBufferToPixels(color).then(() => { const color = new ArrayBuffer(96);
const pixelMap = new ArrayBuffer(400);
let bufferArr = new Unit8Array(color);
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.");
...@@ -327,7 +343,10 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj ...@@ -327,7 +343,10 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
**Example** **Example**
```js ```js
PixelMap.writeBufferToPixels(color, function(err) { const color = new ArrayBuffer(96);\
const pixelMap = new ArrayBuffer(400);
let bufferArr = new Unit8Array(color);
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;
...@@ -354,7 +373,8 @@ Obtains pixel map information of this image. This API uses a promise to return t ...@@ -354,7 +373,8 @@ Obtains pixel map information of this image. This API uses a promise to return t
**Example** **Example**
```js ```js
PixelMap.getImageInfo().then(function(info) { const pixelMap = new ArrayBuffer(400);
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.");
...@@ -379,9 +399,7 @@ Obtains pixel map information of this image. This API uses an asynchronous callb ...@@ -379,9 +399,7 @@ Obtains pixel map information of this image. This API uses an asynchronous callb
```js ```js
pixelmap.getImageInfo((imageInfo) => { pixelmap.getImageInfo((imageInfo) => {
console.log("getImageInfo succeeded."); console.log("Succeeded in obtaining the image pixel map information..");
}).catch((err) => {
console.error("getImageInfo failed.");
}) })
``` ```
...@@ -402,7 +420,10 @@ Obtains the number of bytes per line of the image pixel map. ...@@ -402,7 +420,10 @@ Obtains the number of bytes per line of the image pixel map.
**Example** **Example**
```js ```js
image.createPixelMap(clolr, opts, (err,pixelmap) => { const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err,pixelmap) => {
let rowCount = pixelmap.getBytesNumberPerRow(); let rowCount = pixelmap.getBytesNumberPerRow();
}) })
``` ```
...@@ -444,11 +465,14 @@ Releases this **PixelMap** object. This API uses a promise to return the result. ...@@ -444,11 +465,14 @@ Releases this **PixelMap** object. This API uses a promise to return the result.
**Example** **Example**
```js ```js
const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) => { image.createPixelMap(color, opts, (pixelmap) => {
pixelmap.release().then(() => { pixelmap.release().then(() => {
console.log('release succeeded.'); console.log('Succeeded in releasing pixelmap object.');
}).catch(error => { }).catch(error => {
console.log('release failed.'); console.log('Failed to release pixelmap object.');
}) })
}) })
``` ```
...@@ -470,11 +494,14 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret ...@@ -470,11 +494,14 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret
**Example** **Example**
```js ```js
const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) => { image.createPixelMap(color, opts, (pixelmap) => {
pixelmap.release().then(() => { pixelmap.release().then(() => {
console.log('release succeeded.'); console.log('Succeeded in releasing pixelmap object.');
}).catch(error => { }).catch(error => {
console.log('release failed.'); console.log('Failed to release pixelmap object.');
}) })
}) })
``` ```
...@@ -589,9 +616,7 @@ Obtains information about this image. This API uses an asynchronous callback to ...@@ -589,9 +616,7 @@ Obtains information about this image. This API uses an asynchronous callback to
```js ```js
imageSourceApi.getImageInfo(imageInfo => { imageSourceApi.getImageInfo(imageInfo => {
console.log('getImageInfo succeeded.'); console.log('Succeeded in obtaining the image information.');
}).catch(error => {
console.log('getImageInfo failed.');
}) })
``` ```
...@@ -620,9 +645,9 @@ Obtains information about an image with the specified index. This API uses a pro ...@@ -620,9 +645,9 @@ 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 => {
console.log('getImageInfo succeeded.'); console.log('Succeeded in obtaining the image information.');
}).catch(error => { }).catch(error => {
console.log('getImageInfo failed.'); console.log('Failed to obtain the image information.');
}) })
``` ```
...@@ -652,9 +677,7 @@ Obtains the value of a property with the specified index in this image. This API ...@@ -652,9 +677,7 @@ 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 => {
console.log('getImageProperty succeeded.'); console.log('Succeeded in getting the value of the specified attribute key of the image.');
}).catch(error => {
console.log('getImageProperty failed.');
}) })
``` ```
...@@ -678,9 +701,9 @@ Obtains the value of a property with the specified index in this image. This API ...@@ -678,9 +701,9 @@ Obtains the value of a property with the specified index in this image. This API
```js ```js
imageSourceApi.getImageProperty("BitsPerSample",(error,data) => { imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {
if(error) { if(error) {
console.log('getImageProperty failed.'); console.log('Failed to get the value of the specified attribute key of the image.');
} else { } else {
console.log('getImageProperty succeeded.'); console.log('Succeeded in getting the value of the specified attribute key of the image.');
} }
}) })
``` ```
...@@ -704,11 +727,12 @@ Obtains the value of a property in this image. This API uses an asynchronous cal ...@@ -704,11 +727,12 @@ 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) => { const property = new ArrayBuffer(400);
imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {
if(error) { if(error) {
console.log('getImageProperty failed.'); console.log('Failed to get the value of the specified attribute key of the image.');
} else { } else {
console.log('getImageProperty succeeded.'); console.log('Succeeded in getting the value of the specified attribute key of the image.');
} }
}) })
``` ```
...@@ -737,9 +761,9 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses ...@@ -737,9 +761,9 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
```js ```js
imageSourceApi.createPixelMap().then(pixelmap => { imageSourceApi.createPixelMap().then(pixelmap => {
console.log('createPixelMap succeeded.'); console.log('Succeeded in creating pixelmap object through image decoding parameters.');
}).catch(error => { }).catch(error => {
console.log('createPixelMap failed.'); console.log('Failed to create pixelmap object through image decoding parameters.');
}) })
``` ```
...@@ -761,9 +785,9 @@ Creates a **PixelMap** object based on the default parameters. This API uses an ...@@ -761,9 +785,9 @@ Creates a **PixelMap** object based on the default parameters. This API uses an
```js ```js
imageSourceApi.createPixelMap(pixelmap => { imageSourceApi.createPixelMap(pixelmap => {
console.log('createPixelMap succeeded.'); console.log('Succeeded in creating pixelmap object.');
}).catch(error => { }).catch(error => {
console.log('createPixelMap failed.'); console.log('Failed to create pixelmap object.');
}) })
``` ```
...@@ -785,11 +809,10 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses ...@@ -785,11 +809,10 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Example** **Example**
```js ```js
const decodingOptions = new ArrayBuffer(400);
imageSourceApi.createPixelMap(decodingOptions, pixelmap => { imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
console.log('createPixelMap succeeded.'); console.log('Succeeded in creating pixelmap object.');
}).catch(error => { })
console.log('createPixelMap failed.');
})
``` ```
### release ### release
...@@ -811,8 +834,6 @@ Releases this **ImageSource** instance. This API uses an asynchronous callback t ...@@ -811,8 +834,6 @@ Releases this **ImageSource** instance. This API uses an asynchronous callback t
```js ```js
imageSourceApi.release(() => { imageSourceApi.release(() => {
console.log('release succeeded.'); console.log('release succeeded.');
}).catch(error => {
console.log('release failed.');
}) })
``` ```
...@@ -834,9 +855,9 @@ Releases this **ImageSource** instance. This API uses a promise to return the re ...@@ -834,9 +855,9 @@ Releases this **ImageSource** instance. This API uses a promise to return the re
```js ```js
imageSourceApi.release().then(()=>{ imageSourceApi.release().then(()=>{
console.log('release succeeded.'); console.log('Succeeded in releasing the image source instance.');
}).catch(error => { }).catch(error => {
console.log('release failed.'); console.log('Failed to release the image source instance.');
}) })
``` ```
...@@ -891,8 +912,9 @@ Packs an image. This API uses an asynchronous callback to return the result. ...@@ -891,8 +912,9 @@ 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 => {}) const imageSourceApi = new ArrayBuffer(400);
imagePackerApi.packing(imageSourceApi, packOpts, data => {})
``` ```
### packing ### packing
...@@ -919,8 +941,9 @@ Packs an image. This API uses a promise to return the result. ...@@ -919,8 +941,9 @@ Packs an image. This API uses a promise 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) const imageSourceApi = new ArrayBuffer(400);
imagePackerApi.packing(imageSourceApi, packOpts)
.then( data => { .then( data => {
console.log('packing succeeded.'); console.log('packing succeeded.');
}).catch(error => { }).catch(error => {
...@@ -947,11 +970,12 @@ Packs an image. This API uses an asynchronous callback to return the result. ...@@ -947,11 +970,12 @@ 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(PixelMapApi, packOpts, data => { const pixelMapApi = new ArrayBuffer(400);
console.log('packing succeeded.'); imagePackerApi.packing(pixelMapApi, packOpts, data => {
console.log('Succeeded in packing the image.');
}).catch(error => { }).catch(error => {
console.log('packing failed.'); console.log('Failed to pack the image.');
}) })
``` ```
...@@ -979,12 +1003,13 @@ Packs an image. This API uses a promise to return the result. ...@@ -979,12 +1003,13 @@ Packs an image. This API uses a promise to return the result.
**Example** **Example**
```js ```js
let packOpts = { format:["image/jpeg"], quality:98 } let packOpts = { format:"image/jpeg", quality:98 }
imagePackerApi.packing(PixelMapApi, packOpts) const pixelMapApi = new ArrayBuffer(400);
imagePackerApi.packing(pixelMapApi, packOpts)
.then( data => { .then( data => {
console.log('packing succeeded.'); console.log('Succeeded in packing the image.');
}).catch(error => { }).catch(error => {
console.log('packing failed.'); console.log('Failed to pack the image..');
}) })
``` ```
...@@ -1006,9 +1031,7 @@ Releases this **ImagePacker** instance. This API uses an asynchronous callback t ...@@ -1006,9 +1031,7 @@ Releases this **ImagePacker** instance. This API uses an asynchronous callback t
```js ```js
imagePackerApi.release(()=>{ imagePackerApi.release(()=>{
console.log('release succeeded.'); console.log('Succeeded in releasing image packaging.');
}).catch(error => {
console.log('release failed.');
}) })
``` ```
...@@ -1030,9 +1053,9 @@ Releases this **ImagePacker** instance. This API uses a promise to return the re ...@@ -1030,9 +1053,9 @@ Releases this **ImagePacker** instance. This API uses a promise to return the re
```js ```js
imagePackerApi.release().then(()=>{ imagePackerApi.release().then(()=>{
console.log('release succeeded.'); console.log('Succeeded in releasing image packaging.');
}).catch((error)=>{ }).catch((error)=>{
console.log('release failed.'); console.log('Failed to release image packaging.');
}) })
``` ```
...@@ -1098,7 +1121,7 @@ Obtains a surface ID for the camera or other components. This API uses an asynch ...@@ -1098,7 +1121,7 @@ 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) { if(err) {
console.log('getReceivingSurfaceId failed.'); console.log('getReceivingSurfaceId failed.');
} else { } else {
...@@ -1513,7 +1536,7 @@ Defines image decoding options. ...@@ -1513,7 +1536,7 @@ Defines image decoding options.
| desiredSize | [Size](#size) | Yes | Yes | Expected output size. | | desiredSize | [Size](#size) | Yes | Yes | Expected output size. |
| desiredRegion | [Region](#region7) | Yes | Yes | Region to decode. | | desiredRegion | [Region](#region7) | Yes | Yes | Region to decode. |
| desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format for decoding.| | desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format for decoding.|
| index | number | Yes | Yes | Index of the image to decode. | | index | number | Yes | Yes | Index of the image to decode. |
## Region<sup>7+</sup> ## Region<sup>7+</sup>
...@@ -1536,7 +1559,7 @@ Defines the option for image packing. ...@@ -1536,7 +1559,7 @@ Defines the option for image packing.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------- | ------ | ---- | ---- | -------------- | | ------- | ------ | ---- | ---- | -------------- |
| format | string | Yes | Yes | Format of the packed image. | | format | string | Yes | Yes | Format of the packed image. |
| quality | number | Yes | Yes | Quality of the packed image.| | quality | number | Yes | Yes | Quality of the output image during JPEG encoding. The value ranges from 1 to 100.|
## GetImagePropertyOptions<sup>7+</sup> ## GetImagePropertyOptions<sup>7+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册