| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 3 年前 | ||
| 10 个月前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 11 个月前 | ||
| 1 年前 | ||
| 11 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 11 个月前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 3 年前 |
pcx-js
简介
本软件是使用开源软件 pcx-js, 在OpenHarmony环境下,提供了PCX图像格式解码的能力。
下载安装
ohpm install pcx-js
ohpm install @types/pcx-js --save-dev
OpenHarmony ohpm 环境配置等更多内容,请参考如何安装 OpenHarmony ohpm 包
使用说明
PCX解码使用
import image from '@ohos.multimedia.image';
import util from '@ohos.util';
import PCX from 'pcx-js';
typedArrayToBuffer(array: Uint8ClampedArray): ArrayBuffer {
return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset)
}
getContext(this).resourceManager.getMediaContent($r("app.media.thimbleweed").id).then((uint8Array) => {
let pcxDecoder = new PCX(uint8Array.buffer);
// 获取到pcx图片的解码后的像素点数据 默认RGBA
let decodeData = pcxDecoder.decode();
// 转换成BGRA
this.RBGA2BGRA(decodeData.pixelArray)
// 通过image能力转换成PixelMap
image.createPixelMap(this.typedArrayToBuffer(decodeData.pixelArray), {
'size': {
'width': decodeData.width,
'height': decodeData.height
}
}).then((pixels) => {
this.p1Pixels = pixels;
})
})
接口说明
| 接口名称 | 参数 | 功能描述 |
|---|---|---|
| new PCX(buffer) | Buffer:用于解码PCX数据的Buffer | 初始化pcx对象 |
| decode | 解码接口 |
约束与限制
在下述版本验证通过:
- DevEco Studio: NEXT Beta1-5.0.3.806, SDK:API12 Release(5.0.0.66)
- DevEco Studio: 4.1Canary2(4.1.3.322),SDK: API11(4.1.0.36)
目录结构
/entry/src/
- main/ets/
- pages # 测试page页面列表
- index.ets # 测试解析PCX图片格式
单元测试用例详情见TEST.md
贡献代码
使用过程中发现任何问题都可以提 Issue 给组件,当然,也非常欢迎给组件发 PR 。
开源协议
本项目基于 MIT License ,请自由地享受和参与开源。