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

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

Signed-off-by: N冯泽悟 <fengzewu@huawei.com>
上级 a5bcd191
......@@ -2127,26 +2127,25 @@ queueImage(interface: Image, callback: AsyncCallback\<void>): void
**示例:**
```js
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('queueImage failed: ' + err);
creator.dequeueImage().then(img => {
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
}
console.info('queueImage succeeded');
creator.queueImage(img, (err) => {
if (err) {
console.info('queueImage failed: ' + err);
}
console.info('queueImage succeeded');
})
})
```
### queueImage<sup>9+</sup>
......@@ -2172,22 +2171,22 @@ queueImage(interface: Image): Promise\<void>
**示例:**
```js
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.info('queueImage failed: ' + error);
creator.dequeueImage().then(img => {
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.info('queueImage failed: ' + error);
})
})
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册