docs.rs failed to build image-binding-0.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
image-binding
Install
cargo add image_binding
Usage
Rust source code:
use hilog_info;
use get_pixel_map_info;
use ;
use pre_init;
use ;
ArkTS source code:
import tsfn from 'libtest.so';
import image from '@ohos.multimedia.image';
import { BusinessError } from '@ohos.base';
import hilog from '@ohos.hilog';
@Entry
@Component
struct Tsfn {
@State message: string = '';
private ctx = getContext(this);
test = async () => {
try {
// 获取resourceManager资源管理
const resourceMgr = this.ctx.resourceManager;
const fileData = await resourceMgr.getRawFileContent('test.png');
// 获取图片的ArrayBuffer
const buffer = fileData.buffer;
const imageSource = image.createImageSource(buffer);
let decodingOptions: image.DecodingOptions = {
editable: true,
desiredPixelFormat: 3,
}
const pixelMap = await imageSource.createPixelMap(decodingOptions);
tsfn.getPixelInfo(pixelMap);
} catch (e) {
hilog.info(0x0000, 'testTag', `${(e as BusinessError).message}`);
}
}
build() {
Row() {
Column({ space: 20 }) {
Button('Run TSFN').onClick(() => {
this.test();
})
}
.width('100%')
}
.height('100%')
}
}