From e68c87ebe9a93756a1e98991e211c6bce7fa0c03 Mon Sep 17 00:00:00 2001 From: fengzewu Date: Wed, 28 Sep 2022 16:18:53 +0800 Subject: [PATCH] codecheck Signed-off-by: fengzewu --- .../reference/apis/js-apis-image.md | 122 +++++++++--------- 1 file changed, 60 insertions(+), 62 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 ca6435a7ae..dc66b7fe94 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -39,9 +39,11 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\ { - }) +image.createPixelMap(color, opts).then((pixelmap) => { + console.log('Succeeded in creating pixelmap.'); +}).catch(error => { + console.log('Failed to create pixelmap.'); +}) ``` ## image.createPixelMap8+ @@ -391,7 +393,6 @@ getImageInfo(): Promise\ const color = new ArrayBuffer(96); let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } } image.createPixelMap(color, opts).then(pixelmap => { - globalpixelmap = pixelmap; if (pixelmap == undefined) { console.error("Failed to obtain the image pixel map information."); } @@ -427,7 +428,6 @@ const color = new ArrayBuffer(96); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts, (err, pixelmap) => { if (pixelmap == undefined) { - globalpixelmap = pixelmap; console.error("Failed to obtain the image pixel map information."); } pixelmap.getImageInfo((err, imageInfo) => { @@ -558,9 +558,8 @@ opacity(rate: number): Promise\ **示例:** ```js -async function () { - var rate = 0.5; - await pixelmap.opacity(rate); +async function A() { + await pixelmap.opacity(0.5); } ``` @@ -581,9 +580,9 @@ createAlphaPixelmap(): Promise\ **示例:** ```js -async function () { - await pixelmap.createAlphaPixelmap(); -}) +async function A() { + await pixelmap.createAlphaPixelmap(); +} ``` ### createAlphaPixelmap9+ @@ -631,7 +630,7 @@ scale(x: number, y: number, callback: AsyncCallback\): void **示例:** ```js -async function () { +async function A() { await pixelmap.scale(2.0, 1.0); } ``` @@ -660,7 +659,7 @@ scale(x: number, y: number): Promise\ **示例:** ```js -async function () { +async function A() { await pixelmap.scale(2.0, 1.0); } ``` @@ -684,7 +683,7 @@ translate(x: number, y: number, callback: AsyncCallback\): void **示例:** ```js -async function () { +async function A() { await pixelmap.translate(3.0, 1.0); } ``` @@ -713,7 +712,7 @@ translate(x: number, y: number): Promise\ **示例:** ```js -async function () { +async function A() { await pixelmap.translate(3.0, 1.0); } ``` @@ -736,7 +735,7 @@ rotate(angle: number, callback: AsyncCallback\): void **示例:** ```js -async function () { +async function A() { await pixelmap.rotate(90.0); } ``` @@ -764,7 +763,7 @@ rotate(angle: number): Promise\ **示例:** ```js -async function () { +async function A() { await pixelmap.rotate(90.0); } ``` @@ -788,7 +787,7 @@ flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback\): vo **示例:** ```js -async function () { +async function A() { await pixelmap.flip(false, true); } ``` @@ -817,7 +816,7 @@ flip(horizontal: boolean, vertical: boolean): Promise\ **示例:** ```js -async function () { +async function A() { await pixelmap.flip(false, true); } ``` @@ -840,7 +839,7 @@ crop(region: Region, callback: AsyncCallback\): void **示例:** ```js -async function () { +async function A() { await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); } ``` @@ -868,7 +867,7 @@ crop(region: Region): Promise\ **示例:** ```js -async function () { +async function A() { await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); } ``` @@ -890,15 +889,10 @@ release():Promise\ **示例:** ```js -const color = new ArrayBuffer(96); -let bufferArr = new Uint8Array(color); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } -image.createPixelMap(color, opts, (pixelmap) => { - pixelmap.release().then(() => { - console.log('Succeeded in releasing pixelmap object.'); - }).catch(error => { - console.log('Failed to release pixelmap object.'); - }) +pixelmap.release().then(() => { + console.log('Succeeded in releasing pixelmap object.'); +}).catch(error => { + console.log('Failed to release pixelmap object.'); }) ``` @@ -919,13 +913,8 @@ release(callback: AsyncCallback\): void **示例:** ```js -const color = new ArrayBuffer(96); -let bufferArr = new Uint8Array(color); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } -image.createPixelMap(color, opts, (pixelmap) => { - pixelmap.release().then(() => { - console.log('Succeeded in releasing pixelmap object.'); - }) +pixelmap.release(() => { + console.log('Succeeded in releasing pixelmap object.'); }) ``` @@ -1344,11 +1333,10 @@ modifyImageProperty(key: string, value: string): Promise\ **示例:** ```js -imageSourceApi.modifyImageProperty("ImageWidth", "120") - .then(() => { - const w = imageSourceApi.getImageProperty("ImageWidth") - console.info('w', w); - }) +imageSourceApi.modifyImageProperty("ImageWidth", "120").then(() => { + const w = imageSourceApi.getImageProperty("ImageWidth") + console.info('w', w); +}) ``` ### modifyImageProperty9+ @@ -1400,9 +1388,9 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number) ```js const array = new ArrayBuffer(100); -imageSourceIncrementalSApi.updateData(array, false, 0, 10).then(data => { - console.info('Succeeded in updating data.'); - }) +imageSourceApi.updateData(array, false, 0, 10).then(data => { + console.info('Succeeded in updating data.'); +}) ``` @@ -1428,11 +1416,11 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, ```js const array = new ArrayBuffer(100); -imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> { - if(data !== undefined){ - console.info('Succeeded in updating data.'); - } - }) +imageSourceApi.updateData(array, false, 0, 10,(error,data )=> { + if(data !== undefined){ + console.info('Succeeded in updating data.'); + } +}) ``` ### createPixelMap7+ @@ -1616,6 +1604,7 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\ {}) ``` @@ -1644,6 +1633,7 @@ packing(source: ImageSource, option: PackingOption): Promise\ **示例:** ```js +const imageSourceApi = image.createImageSource(0); let packOpts = { format:"image/jpeg", quality:98 } imagePackerApi.packing(imageSourceApi, packOpts) .then( data => { @@ -1672,10 +1662,14 @@ packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\ { - console.log('Succeeded in packing the image.'); +const color = new ArrayBuffer(96); +let bufferArr = new Uint8Array(color); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +image.createPixelMap(color, opts).then((pixelmap) => { + let packOpts = { format:"image/jpeg", quality:98 } + imagePackerApi.packing(pixelMapApi, packOpts, data => { + console.log('Succeeded in packing the image.'); + }) }) ``` @@ -1703,14 +1697,18 @@ packing(source: PixelMap, option: PackingOption): Promise\ **示例:** ```js -let packOpts = { format:"image/jpeg", quality:98 } -const pixelMapApi = new ArrayBuffer(400); -imagePackerApi.packing(pixelMapApi, packOpts) - .then( data => { - console.log('Succeeded in packing the image.'); - }).catch(error => { - console.log('Failed to pack the image..'); - }) +const color = new ArrayBuffer(96); +let bufferArr = new Uint8Array(color); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +image.createPixelMap(color, opts).then((pixelmap) => { + let packOpts = { format:"image/jpeg", quality:98 } + imagePackerApi.packing(pixelMapApi, packOpts) + .then( data => { + console.log('Succeeded in packing the image.'); + }).catch(error => { + console.log('Failed to pack the image..'); + }) +}) ``` ### release -- GitLab