未验证 提交 a5bcd191 编写于 作者: 冯泽悟 提交者: Gitee

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

Signed-off-by: N冯泽悟 <fengzewu@huawei.com>
上级 0127a525
......@@ -2127,18 +2127,25 @@ queueImage(interface: Image, callback: AsyncCallback\<void>): void
**示例:**
```js
creator.dequeueImage((err, img) => {
if (err) {
console.info('dequeueImage failded.');
}
console.info('dequeueImage succeeded.');
creator.queueImage(img, (err) => {
var creator = image.createImageCreator(WIDTH, HEIGHT, FORMAT, CAPACITY);
var img = await creator.dequeueImage();
const JPEG = 4;
var component = await img.getComponent(JPEG);
//绘制图片
var bufferArr = new Uint8Array(component.byteBuffer);
for (var i = 0; i < bufferArr.length; i += 4) {
bufferArr[i] = 0; //B
bufferArr[i + 1] = 0; //G
bufferArr[i + 2] = 255; //R
bufferArr[i + 3] = 255; //A
}
creator.queueImage(img, (err) => {
if (err) {
console.info('dequeueImage failed: ' + err);
console.info('queueImage failed: ' + err);
}
console.info('dequeueImage succeeded');
})
});
console.info('queueImage succeeded');
})
```
......@@ -2165,19 +2172,24 @@ queueImage(interface: Image): Promise\<void>
**示例:**
```js
creator.dequeueImage().then(img => {
console.info('dequeueImage succeeded.');
creator.queueImage(img).then(() => {
console.info('dequeueImage succeeded.');
}).catch(error => {
console.info('dequeueImage failed: ' + error);
})
var creator = image.createImageCreator(8192, 8, 4, 8);
var img = await creator.dequeueImage();
const JPEG = 4;
var component = await img.getComponent(JPEG);
//绘制图片
var bufferArr = new Uint8Array(component.byteBuffer);
for (var i = 0; i < bufferArr.length; i += 4) {
bufferArr[i] = 0; //B
bufferArr[i + 1] = 0; //G
bufferArr[i + 2] = 255; //R
bufferArr[i + 3] = 255; //A
}
creator.queueImage(img).then(() => {
console.info('queueImage succeeded.');
}).catch(error => {
console.log('dequeueImage failed: ' + error);
console.info('queueImage failed: ' + error);
})
```
### on<sup>9+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册