From 3be2d32d6f365a53e46257675d888000909e919c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E6=B3=BD=E6=82=9F?= Date: Fri, 2 Dec 2022 03:31:52 +0000 Subject: [PATCH] update zh-cn/application-dev/reference/apis/js-apis-image.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 冯泽悟 --- .../reference/apis/js-apis-image.md | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index c2da9e59ad..9d044e3774 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -2128,16 +2128,16 @@ queueImage(interface: Image, callback: AsyncCallback\): void ```js 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 - } + img.getComponent(4).then(component => { + 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); @@ -2172,16 +2172,16 @@ queueImage(interface: Image): Promise\ ```js 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 - } + img.getComponent(4).then(component => { + 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 => { -- GitLab