Compare commits

...

4 Commits

Author SHA1 Message Date
聪小陈 9d66ecf34f
Pre Merge pull request !462 from 聪小陈/N/A 2025-02-20 03:00:16 +00:00
openharmony_ci c1426cd35a
!463 项目配置文件新增设备类型,样例设置混淆
Merge pull request !463 from zgf/master
2025-02-20 03:00:15 +00:00
zgf adb78853af 项目配置文件新增设备类型,样例设置混淆
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-02-19 17:39:29 +08:00
聪小陈 ca44a78092
update README_zh.md.
大写的 ImageKnifeOption 会有错误提示 '@ObjectLink' decorated 'imageKnifeOption' must be initialized through the component constructor. <ArkTSCheck>

Signed-off-by: 聪小陈 <448627663@qq.com>
2025-02-19 02:22:35 +00:00
8 changed files with 123 additions and 82 deletions

View File

@ -361,6 +361,14 @@ This project has been verified in the following version:
DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release(5.0.0.66)
## About obfuscation
- Code obfuscation, please see[Code Obfuscation](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/source-obfuscation.md)
- If you want the imageknife library not to be obfuscated during code obfuscation, you need to add corresponding exclusion rules in the obfuscation rule configuration file obfuscation-rules.txt
```
-keep
./oh_modules/@ohos/imageknife
```
## How to Contribute
If you find any problem during the use, submit an [Issue](https://gitee.com/openharmony-tpc/ImageKnife/issues) or a [PR](https://gitee.com/openharmony-tpc/ImageKnife/issues) to us.

View File

@ -56,7 +56,7 @@ await ImageKnife.getInstance().initFileCache(context, 256, 256 * 1024 * 1024)
```
ImageKnifeComponent({
ImageKnifeOption: {
imageKnifeOption: {
loadSrc: $r("app.media.app_icon"),
placeholderSrc: $r("app.media.loading"),
errorholderSrc: $r("app.media.app_icon"),
@ -69,7 +69,7 @@ ImageKnifeComponent({
```
ImageKnifeComponent({
ImageKnifeOption: {
imageKnifeOption: {
loadSrc: this.localFile,
placeholderSrc: $r("app.media.loading"),
errorholderSrc: $r("app.media.app_icon"),
@ -82,7 +82,7 @@ ImageKnifeComponent({
```
ImageKnifeComponent({
ImageKnifeOption: {
imageKnifeOption: {
loadSrc:"https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png",
placeholderSrc: $r("app.media.loading"),
errorholderSrc: $r("app.media.app_icon"),
@ -95,7 +95,7 @@ ImageKnifeComponent({
```
ImageKnifeComponent({
ImageKnifeOption: {
imageKnifeOption: {
loadSrc: "https://file.atomgit.com/uploads/user/1704857786989_8994.jpeg",
placeholderSrc: $r("app.media.loading"),
errorholderSrc: $r("app.media.app_icon"),
@ -117,7 +117,7 @@ async function custom(context: Context, src: string | PixelMap | Resource): Prom
```
ImageKnifeComponent({
ImageKnifeOption: {
imageKnifeOption: {
loadSrc:"https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png",
progressListener:(progress:number)=>{console.info("ImageKinfe:: call back progress = " + progress)}
}
@ -127,10 +127,10 @@ ImageKnifeComponent({
#### 6.支持option传入border设置边框圆角
```
ImageKnifeComponent({ ImageKnifeOption:
{
loadSrc: $r("app.media.rabbit"),
border: {radius:50}
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $r("app.media.rabbit"),
border: {radius:50}
}
}).width(100).height(100)
```
@ -138,11 +138,11 @@ ImageKnifeComponent({ ImageKnifeOption:
#### 7.支持option图片变换
```
ImageKnifeComponent({ ImageKnifeOption:
{
loadSrc: $r("app.media.rabbit"),
border: {radius:50},
transformation: new BlurTransformation(3)
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $r("app.media.rabbit"),
border: {radius:50},
transformation: new BlurTransformation(3)
}
}).width(100).height(100)
```
@ -154,12 +154,12 @@ transformations.push(new BlurTransformation(5));
transformations.push(new BrightnessTransformation(0.2));
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"),
errorholderSrc: $r("app.media.app_icon"),
objectFit: ImageFit.Contain,
border: { radius: { topLeft: 50, bottomRight: 50 } }, // 圆角设置
transformation: transformations.length > 0 ? new MultiTransTransformation(transformations) : undefined // 图形变换组
loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"),
errorholderSrc: $r("app.media.app_icon"),
objectFit: ImageFit.Contain,
border: { radius: { topLeft: 50, bottomRight: 50 } }, // 圆角设置
transformation: transformations.length > 0 ? new MultiTransTransformation(transformations) : undefined // 图形变换组
}
}).width(300)
.height(300)
@ -171,12 +171,12 @@ ImageKnifeComponent({
圆形裁剪变换示例
```
ImageKnifeComponent({ ImageKnifeOption:
{
loadSrc: $r('app.media.pngSample'),
objectFit: ImageFit.Cover,
border: { radius: 150 }
}
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $r('app.media.pngSample'),
objectFit: ImageFit.Cover,
border: { radius: 150 }
}
}).width(300)
.height(300)
```
@ -184,12 +184,12 @@ ImageKnifeComponent({ ImageKnifeOption:
圆形裁剪带边框变换示例
```
ImageKnifeComponent({ ImageKnifeOption:
{
loadSrc: $r('app.media.pngSample'),
objectFit: ImageFit.Cover,
border: { radius: 150, color: Color.Red, width: 5 }
}
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $r('app.media.pngSample'),
objectFit: ImageFit.Cover,
border: { radius: 150, color: Color.Red, width: 5 }
}
}).width(300)
.height(300)
```
@ -222,8 +222,8 @@ ImageKnifeComponent({
#### 8.监听图片加载成功与失败
```
ImageKnifeComponent({ ImageKnifeOption:
{
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $r("app.media.rabbit"),
onLoadListener:{
onLoadStart:()=>{
@ -248,61 +248,64 @@ ImageKnifeComponent({ ImageKnifeOption:
设置是否同步加载图片默认是异步加载。建议加载尺寸较小的Resource图片时将syncLoad设为true因为耗时较短在主线程上执行即可
```
ImageKnifeComponent({
imageKnifeOption:{
loadSrc:$r("app.media.pngSample"),
placeholderSrc:$r("app.media.loading")
},syncLoad:true
})
imageKnifeOption:{
loadSrc:$r("app.media.pngSample"),
placeholderSrc:$r("app.media.loading")
},
syncLoad:true
})
```
#### 10.ImageKnifeAnimatorComponent 示例
```
ImageKnifeAnimatorComponent({
imageKnifeOption: {
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
placeholderSrc:$r('app.media.loading'),
errorholderSrc:$r('app.media.failed')
},animatorOption:this.animatorOption
}).width(300).height(300).backgroundColor(Color.Orange).margin({top:30})
imageKnifeOption: {
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
placeholderSrc:$r('app.media.loading'),
errorholderSrc:$r('app.media.failed')
},
animatorOption:this.animatorOption
}).width(300).height(300).backgroundColor(Color.Orange).margin({top:30})
```
#### 11.加载图片回调信息数据 示例
```
ImageKnifeComponent({ ImageKnifeOption: = {
loadSrc: $r('app.media.pngSample'),
objectFit: ImageFit.Contain,
onLoadListener: {
onLoadStart: (req) => {
let startCallBackData = JSON.stringify(req?.imageKnifeData);
},
onLoadFailed: (res, req) => {
let failedBackData = res + ";" + JSON.stringify(req?.imageKnifeData);
},
onLoadSuccess: (data, imageData, req) => {
let successBackData = JSON.stringify(req?.imageKnifeData);
},
onLoadCancel: (res, req) => {
let cancelBackData = res + ";" + JSON.stringify(req?.imageKnifeData);
}
},
border: { radius: 50 },
onComplete: (event) => {
if (event && event.loadingStatus == 0) {
let render_success = JSON.stringify(Date.now())
}
}
}
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $r('app.media.pngSample'),
objectFit: ImageFit.Contain,
onLoadListener: {
onLoadStart: (req) => {
let startCallBackData = JSON.stringify(req?.imageKnifeData);
},
onLoadFailed: (res, req) => {
let failedBackData = res + ";" + JSON.stringify(req?.imageKnifeData);
},
onLoadSuccess: (data, imageData, req) => {
let successBackData = JSON.stringify(req?.imageKnifeData);
},
onLoadCancel: (res, req) => {
let cancelBackData = res + ";" + JSON.stringify(req?.imageKnifeData);
}
},
border: { radius: 50 },
onComplete: (event) => {
if (event && event.loadingStatus == 0) {
let render_success = JSON.stringify(Date.now())
}
}
}
}).width(100).height(100)
```
#### 12.图片降采样 示例
```
ImageKnifeComponent({
imageKnifeOption:{
loadSrc:$r("app.media.pngSample"),
placeholderSrc:$r('app.media.loading'),
errorholderSrc:$r('app.media.failed'),
downsampleOf: DownsampleStrategy.NONE
}
}).width(300).height(300)
imageKnifeOption:{
loadSrc:$r("app.media.pngSample"),
placeholderSrc:$r('app.media.loading'),
errorholderSrc:$r('app.media.failed'),
downsampleOf: DownsampleStrategy.NONE
}
}).width(300).height(300)
```
#### 13.rcp自定义网络请求
```
@ -457,6 +460,14 @@ async function custom(context: Context, src: string | PixelMap | Resource,header
在下述版本验证通过:
DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release(5.0.0.66)
## 关于混淆
- 代码混淆,请查看[代码混淆简介](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/source-obfuscation.md)
- 如果希望imageknife库在代码混淆过程中不会被混淆需要在混淆规则配置文件obfuscation-rules.txt中添加相应的排除规则
```
-keep
./oh_modules/@ohos/imageknife
```
## 贡献代码
使用过程中发现任何问题都可以提 [issue](https://gitee.com/openharmony-tpc/ImageKnife/issues)

View File

@ -15,4 +15,7 @@
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
# -keep-global-name: specifies names that you want to keep in the global scope
-keep
./oh_modules/@ohos/imageknife

View File

@ -6,7 +6,11 @@
"mainElement": "EntryAbility",
"deviceTypes": [
"default",
"tablet"
"tablet",
"tv",
"wearable",
"car",
"2in1"
],
"deliveryWithInstall": true,
"installationFree": false,

View File

@ -6,7 +6,11 @@
"mainElement": "TestAbility",
"deviceTypes": [
"default",
"tablet"
"tablet",
"tv",
"wearable",
"car",
"2in1"
],
"deliveryWithInstall": true,
"installationFree": false,

View File

@ -4,7 +4,11 @@
"type": "har",
"deviceTypes": [
"default",
"tablet"
"tablet",
"tv",
"wearable",
"car",
"2in1"
]
}
}

View File

@ -15,4 +15,7 @@
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
# -keep-global-name: specifies names that you want to keep in the global scope
-keep
./oh_modules/@ohos/imageknife

View File

@ -5,7 +5,11 @@
"description": "$string:shared_desc",
"deviceTypes": [
"default",
"tablet"
"tablet",
"tv",
"wearable",
"car",
"2in1"
],
"deliveryWithInstall": true,
"pages": "$profile:main_pages"