!5 add User-Defined transformation effect interface

Merge pull request !5 from 周黎生/master
This commit is contained in:
openharmony_ci 2022-04-14 10:05:27 +00:00 committed by Gitee
commit 6c39fb449d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
10 changed files with 52 additions and 24 deletions

View File

@ -1,12 +1,15 @@
## 1.0.2
- 支持用户自定义扩展变换接口。
## 1.0.1 ## 1.0.1
- hvigor工程结构整改 - 由gradle工程整改为hvigor工程。
## 1.0.0 ## 1.0.0
专门为OpenHarmony打造的一款图像加载缓存库致力于更高效、更轻便、更简单 专门为OpenHarmony打造的一款图像加载缓存库致力于更高效、更轻便、更简单
- 支持内存缓存使用LRUCache算法对图片数据进行内存缓存 - 支持内存缓存使用LRUCache算法对图片数据进行内存缓存
- 支持磁盘缓存,对于下载图片会保存一份至磁盘当中 - 支持磁盘缓存,对于下载图片会保存一份至磁盘当中
- 支持进行图片变换 - 支持进行图片变换
- 支持用户配置参数使用:(例如:配置是否开启第一级内存缓存,配置磁盘缓存策略,配置仅使用缓存加载数据,配置图片变换效果,配置占位图,配置加载失败占位图等) - 支持用户配置参数使用:(例如:配置是否开启第一级内存缓存,配置磁盘缓存策略,配置仅使用缓存加载数据,配置图片变换效果,配置占位图,配置加载失败占位图等)
- 推荐使用ImageKnifeComponent组件配合ImageKnifeOption参数来实现功能 - 推荐使用ImageKnifeComponent组件配合ImageKnifeOption参数来实现功能
- 支持用户自定义配置实现能力参考ImageKnifeComponent组件中对于入参ImageKnifeOption的处理 - 支持用户自定义配置实现能力参考ImageKnifeComponent组件中对于入参ImageKnifeOption的处理

View File

@ -321,4 +321,6 @@ let requestOptin = new RequestOption();
1.图片变换缓慢(待优化)。 1.图片变换缓慢(待优化)。
2.目前只支持一种图片变换效果。 2.目前只支持一种图片变换效果。
3.目前svg和gif动图不支持变换效果。

View File

@ -1,7 +1,7 @@
{ {
"app": { "app": {
"vendor": "example", "vendor": "openharmony",
"bundleName": "com.example.imageknifegiteepro", "bundleName": "cn.openharmony.imageknife",
"version": { "version": {
"code": 1000000, "code": 1000000,
"name": "1.0.0" "name": "1.0.0"
@ -51,7 +51,7 @@
"deliveryWithInstall": true, "deliveryWithInstall": true,
"moduleName": "entry" "moduleName": "entry"
}, },
"package": "com.example.entry", "package": "cn.openharmony.entry",
"srcPath": "", "srcPath": "",
"name": ".entry", "name": ".entry",
"reqPermissions": [ "reqPermissions": [
@ -63,7 +63,7 @@
"reason": "Api call", "reason": "Api call",
"usedScene": { "usedScene": {
"ability": [ "ability": [
"com.example.imageknifegiteepro.MainAbility" "cn.openharmony.imageknife.MainAbility"
], ],
"when": "always" "when": "always"
} }
@ -77,7 +77,7 @@
"usedScene": { "usedScene": {
"when": "always", "when": "always",
"ability": [ "ability": [
"com.example.imageknifegiteepro.MainAbility" "cn.openharmony.imageknife.MainAbility"
] ]
} }
}, },
@ -87,7 +87,7 @@
"usedScene": { "usedScene": {
"when": "always", "when": "always",
"ability": [ "ability": [
"com.example.imageknifegiteepro.MainAbility" "cn.openharmony.imageknife.MainAbility"
] ]
} }
} }

View File

@ -15,6 +15,8 @@
import {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeComponent} from '@ohos/imageknife'
import {ImageKnifeOption} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/imageknife'
import {RotateImageTransformation} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/imageknife'
import {GrayscaleTransformation} from '@ohos/imageknife'
import {SketchFilterTransformation} from '@ohos/imageknife'
@Entry @Entry
@Component @Component
@ -42,7 +44,8 @@ struct TestImageKnifeOptionChangedPage2 {
placeholderSrc: $r('app.media.icon_loading'), placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'), errorholderSrc: $r('app.media.icon_failed'),
margin:{left:5,top:5,right:5,bottom:5}, margin:{left:5,top:5,right:5,bottom:5},
thumbSizeMultiplier:0.1 thumbSizeMultiplier:0.1,
transformation:new RotateImageTransformation(180)
}; };
}).margin({left:5}).backgroundColor(Color.Blue) }).margin({left:5}).backgroundColor(Color.Blue)
Button("网络资源png") Button("网络资源png")
@ -53,7 +56,8 @@ struct TestImageKnifeOptionChangedPage2 {
placeholderSrc: $r('app.media.icon_loading'), placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'), errorholderSrc: $r('app.media.icon_failed'),
margin:{left:5,top:5,right:5,bottom:5}, margin:{left:5,top:5,right:5,bottom:5},
thumbSizeMultiplier:0.1 thumbSizeMultiplier:0.1,
transformations:[new RotateImageTransformation(180)]
}; };
}).margin({left:5}).backgroundColor(Color.Blue) }).margin({left:5}).backgroundColor(Color.Blue)
Button("网络资源bmp") Button("网络资源bmp")
@ -64,7 +68,8 @@ struct TestImageKnifeOptionChangedPage2 {
placeholderSrc: $r('app.media.icon_loading'), placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'), errorholderSrc: $r('app.media.icon_failed'),
margin:{left:5,top:5,right:5,bottom:5}, margin:{left:5,top:5,right:5,bottom:5},
thumbSizeMultiplier:0.1 thumbSizeMultiplier:0.1,
transformations:[new GrayscaleTransformation()]
}; };
}).margin({left:5}).backgroundColor(Color.Blue) }).margin({left:5}).backgroundColor(Color.Blue)
Button("网络资源webp") Button("网络资源webp")
@ -75,7 +80,8 @@ struct TestImageKnifeOptionChangedPage2 {
placeholderSrc: $r('app.media.icon_loading'), placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'), errorholderSrc: $r('app.media.icon_failed'),
margin:{left:5,top:5,right:5,bottom:5}, margin:{left:5,top:5,right:5,bottom:5},
thumbSizeMultiplier:0.1 thumbSizeMultiplier:0.1,
transformations:[new SketchFilterTransformation()]
}; };
}).margin({left:5}).backgroundColor(Color.Blue) }).margin({left:5}).backgroundColor(Color.Blue)
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@ohos/imageknife", "name": "@ohos/imageknife",
"version": "1.0.1", "version": "1.0.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -12,7 +12,7 @@
}, },
"main": "index.ets", "main": "index.ets",
"repository": "https://gitee.com/openharmony-tpc/ImageKnife", "repository": "https://gitee.com/openharmony-tpc/ImageKnife",
"version": "1.0.1", "version": "1.0.2",
"dependencies": { "dependencies": {
"pako": "^1.0.5" "pako": "^1.0.5"
}, },

View File

@ -1,7 +1,7 @@
{ {
"app": { "app": {
"bundleName": "com.example.imageknifegiteepro", "bundleName": "cn.openharmony.imageknife",
"vendor": "example", "vendor": "openharmony",
"version": { "version": {
"code": 1000000, "code": 1000000,
"name": "1.0.0" "name": "1.0.0"
@ -9,7 +9,7 @@
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.example.imageknife", "package": "cn.openharmony.imageknife",
"deviceType": [ "deviceType": [
"phone", "phone",
"tablet" "tablet"

View File

@ -147,6 +147,12 @@ export struct ImageKnifeComponent {
if (this.imageKnifeOption.transform) { if (this.imageKnifeOption.transform) {
this.requestAddTransform(request) this.requestAddTransform(request)
} }
if (this.imageKnifeOption.transformation) {
request.transform(this.imageKnifeOption.transformation)
}
if (this.imageKnifeOption.transformations) {
request.transforms(this.imageKnifeOption.transformations)
}
if (this.imageKnifeOption.dontAnimateFlag) { if (this.imageKnifeOption.dontAnimateFlag) {
request.dontAnimate() request.dontAnimate()
} }

View File

@ -73,6 +73,9 @@ export class ImageKnifeOption {
rotateImage?:number rotateImage?:number
} }
transformation?:BaseTransform<PixelMap>;
transformations?:Array<BaseTransform<PixelMap>>;
// 输出缓存相关内容和信息 // 输出缓存相关内容和信息
allCacheInfoCallback?: IAllCacheInfoCallback; allCacheInfoCallback?: IAllCacheInfoCallback;

View File

@ -308,6 +308,14 @@ export class RequestOption {
this.transformations.push(transformation); this.transformations.push(transformation);
return this; return this;
} }
transform(input:BaseTransform<PixelMap>){
this.transformations.push(input);
return this;
}
transforms(inputs:BaseTransform<PixelMap>[]){
this.transformations = inputs;
return this;
}
// 占位图解析成功 // 占位图解析成功