未验证 提交 9a7976e6 编写于 作者: 刘关鹏 提交者: Gitee

update zh-cn/application-dev/media/image-transformation-native.md.

Signed-off-by: N刘关鹏 <liuguanpeng1@huawei.com>
上级 f69c94f3
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
2. 调用Native接口,传入JS的资源对象。示例如下: 2. 调用Native接口,传入JS的资源对象。示例如下:
```js ```ts
import testNapi from 'libentry.so' import testNapi from 'libentry.so'
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';
...@@ -108,7 +108,6 @@ ...@@ -108,7 +108,6 @@
@Component @Component
struct Index { struct Index {
@State message: string = 'IMAGE' @State message: string = 'IMAGE'
@State _PixelMap: image.PixelMap = undefined
build() { build() {
Row() { Row() {
...@@ -117,22 +116,20 @@ ...@@ -117,22 +116,20 @@
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
.onClick(() => { .onClick(() => {
const color = new ArrayBuffer(96); const color : ArrayBuffer = new ArrayBuffer(96);
let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 4, width: 6 } } let opts: image.InitializationOptions = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts) image.createPixelMap(color, opts)
.then( pixelmap => { .then( (pixelmap : image.PixelMap) => {
this._PixelMap = pixelmap; testNapi.testGetImageInfo(pixelmap);
})
testNapi.testGetImageInfo(this._PixelMap);
console.info("Test GetImageInfo success"); console.info("Test GetImageInfo success");
testNapi.testAccessPixels(this._PixelMap); testNapi.testAccessPixels(pixelmap);
console.info("Test AccessPixels success"); console.info("Test AccessPixels success");
testNapi.testUnAccessPixels(this._PixelMap); testNapi.testUnAccessPixels(pixelmap);
console.info("Test UnAccessPixels success"); console.info("Test UnAccessPixels success");
}) })
})
} }
.width('100%') .width('100%')
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册