From 9a7976e60aec1f426bea50277e219ecba85ccabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=85=B3=E9=B9=8F?= Date: Wed, 6 Sep 2023 02:45:22 +0000 Subject: [PATCH] update zh-cn/application-dev/media/image-transformation-native.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘关鹏 --- .../media/image-transformation-native.md | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/zh-cn/application-dev/media/image-transformation-native.md b/zh-cn/application-dev/media/image-transformation-native.md index 1a685f6499..67c4261142 100644 --- a/zh-cn/application-dev/media/image-transformation-native.md +++ b/zh-cn/application-dev/media/image-transformation-native.md @@ -100,7 +100,7 @@ 2. 调用Native接口,传入JS的资源对象。示例如下: - ```js + ```ts import testNapi from 'libentry.so' import image from '@ohos.multimedia.image'; @@ -108,7 +108,6 @@ @Component struct Index { @State message: string = 'IMAGE' - @State _PixelMap: image.PixelMap = undefined build() { Row() { @@ -117,21 +116,19 @@ .fontSize(50) .fontWeight(FontWeight.Bold) .onClick(() => { - const color = new ArrayBuffer(96); - let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 4, width: 6 } } + const color : ArrayBuffer = new ArrayBuffer(96); + let opts: image.InitializationOptions = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 4, width: 6 } } image.createPixelMap(color, opts) - .then( pixelmap => { - this._PixelMap = pixelmap; + .then( (pixelmap : image.PixelMap) => { + testNapi.testGetImageInfo(pixelmap); + console.info("Test GetImageInfo success"); + + testNapi.testAccessPixels(pixelmap); + console.info("Test AccessPixels success"); + + testNapi.testUnAccessPixels(pixelmap); + console.info("Test UnAccessPixels success"); }) - - testNapi.testGetImageInfo(this._PixelMap); - console.info("Test GetImageInfo success"); - - testNapi.testAccessPixels(this._PixelMap); - console.info("Test AccessPixels success"); - - testNapi.testUnAccessPixels(this._PixelMap); - console.info("Test UnAccessPixels success"); }) } .width('100%') -- GitLab