From 913e3672cb0c669fd46cf8bb4d995db5d137807e Mon Sep 17 00:00:00 2001 From: xu-rui-w Date: Fri, 1 Jul 2022 17:08:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E5=8F=82=E6=95=B0=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xu-rui-w --- .../reference/apis/js-apis-image.md | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 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 37385a4c6f..321aa9cb65 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -33,6 +33,7 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\ { @@ -59,6 +60,7 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: As ```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) => { }) @@ -181,6 +183,8 @@ readPixels(area: PositionArea, callback: AsyncCallback\): void **示例:** ```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, (err, pixelmap) => { if(pixelmap == undefined){ @@ -221,6 +225,7 @@ writePixels(area: PositionArea): Promise\ ```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) .then( pixelmap => { @@ -263,7 +268,7 @@ writePixels(area: PositionArea, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------------ | ---- | ------------------------------ | | area | [PositionArea](#positionarea7) | 是 | 区域,根据区域写入。 | -| callback: | AsyncCallback\ | 是 | 获取回调,失败时error会返回错误信息。 | +| callback: | AsyncCallback\ | 是 | 获取回调,失败时返回错误信息。 | **示例:** @@ -305,6 +310,8 @@ writeBufferToPixels(src: ArrayBuffer): Promise\ **示例:** ```js +const color = new ArrayBuffer(96); +let bufferArr = new Unit8Array(color); PixelMap.writeBufferToPixels(color).then(() => { console.log("Succeeded in writing data from a buffer to a PixelMap."); }).catch((err) => { @@ -330,6 +337,8 @@ writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\): void **示例:** ```js +const color = new ArrayBuffer(96); +let bufferArr = new Unit8Array(color); PixelMap.writeBufferToPixels(color, function(err) { if (err) { console.error("Failed to write data from a buffer to a PixelMap."); @@ -405,6 +414,9 @@ getBytesNumberPerRow(): number **示例:** ```js +const color = new ArrayBuffer(96); +let bufferArr = new Unit8Array(color); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(clolr, opts, (err,pixelmap) => { let rowCount = pixelmap.getBytesNumberPerRow(); }) @@ -447,6 +459,9 @@ release():Promise\ **示例:** ```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) => { pixelmap.release().then(() => { console.log('release succeeded.'); @@ -473,6 +488,9 @@ release(callback: AsyncCallback\): void **示例:** ```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) => { pixelmap.release().then(() => { console.log('release succeeded.'); @@ -922,7 +940,7 @@ packing(source: ImageSource, option: PackingOption): Promise\ **示例:** ```js -let packOpts = { format:["image/jpeg"], quality:98 } +let packOpts = { format:"image/jpeg", quality:98 } imagePackerApi.packing(ImageSourceApi, packOpts) .then( data => { console.log('packing succeeded.'); @@ -950,7 +968,7 @@ packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\ { console.log('packing succeeded.'); }).catch(error => { @@ -982,7 +1000,7 @@ packing(source: PixelMap, option: PackingOption): Promise\ **示例:** ```js -let packOpts = { format:["image/jpeg"], quality:98 } +let packOpts = { format:"image/jpeg", quality:98 } imagePackerApi.packing(PixelMapApi, packOpts) .then( data => { console.log('packing succeeded.'); @@ -1101,7 +1119,7 @@ getReceivingSurfaceId(callback: AsyncCallback\): void **示例:** ```js - receiver.getReceivingSurfaceId((err, id) => { +receiver.getReceivingSurfaceId((err, id) => { if(err) { console.log('getReceivingSurfaceId failed.'); } else { @@ -1516,7 +1534,7 @@ PixelMap的初始化选项。 | desiredSize | [Size](#size) | 是 | 是 | 期望输出大小。 | | desiredRegion | [Region](#region7) | 是 | 是 | 解码区域。 | | desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | 解码的像素格式。 | -| index | number | 是 | 是 | 解码图片序号 | +| index | number | 是 | 是 | 解码图片序号。 | ## Region7+ -- GitLab