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 4b59a38630c7f50ff516574544287b73569962ae..ae821508ae5f3b28d0d609475039af4d973883d9 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 Demo() { + await pixelmap.opacity(0.5); } ``` @@ -581,9 +580,9 @@ createAlphaPixelmap(): Promise\ **示例:** ```js -async function () { - await pixelmap.createAlphaPixelmap(); -}) +async function Demo() { + await pixelmap.createAlphaPixelmap(); +} ``` ### createAlphaPixelmap9+ @@ -631,7 +630,7 @@ scale(x: number, y: number, callback: AsyncCallback\): void **示例:** ```js -async function () { +async function Demo() { await pixelmap.scale(2.0, 1.0); } ``` @@ -660,7 +659,7 @@ scale(x: number, y: number): Promise\ **示例:** ```js -async function () { +async function Demo() { await pixelmap.scale(2.0, 1.0); } ``` @@ -684,7 +683,7 @@ translate(x: number, y: number, callback: AsyncCallback\): void **示例:** ```js -async function () { +async function Demo() { await pixelmap.translate(3.0, 1.0); } ``` @@ -713,7 +712,7 @@ translate(x: number, y: number): Promise\ **示例:** ```js -async function () { +async function Demo() { await pixelmap.translate(3.0, 1.0); } ``` @@ -736,7 +735,7 @@ rotate(angle: number, callback: AsyncCallback\): void **示例:** ```js -async function () { +async function Demo() { await pixelmap.rotate(90.0); } ``` @@ -764,7 +763,7 @@ rotate(angle: number): Promise\ **示例:** ```js -async function () { +async function Demo() { await pixelmap.rotate(90.0); } ``` @@ -788,8 +787,8 @@ flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback\): vo **示例:** ```js -async function () { - await pixelmap.flip(false, true); +async function Demo() { + await pixelmap.flip(false, true); } ``` @@ -817,8 +816,8 @@ flip(horizontal: boolean, vertical: boolean): Promise\ **示例:** ```js -async function () { - await pixelmap.flip(false, true); +async function Demo() { + await pixelmap.flip(false, true); } ``` @@ -840,8 +839,8 @@ crop(region: Region, callback: AsyncCallback\): void **示例:** ```js -async function () { - await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); +async function Demo() { + await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); } ``` @@ -868,8 +867,8 @@ crop(region: Region): Promise\ **示例:** ```js -async function () { - await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); +async function Demo() { + 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