diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c58bf8..96ce6db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,15 @@ +## 1.0.2 +- 支持用户自定义扩展变换接口。 + ## 1.0.1 -- hvigor工程结构整改 +- 由gradle工程整改为hvigor工程。 ## 1.0.0 -专门为OpenHarmony打造的一款图像加载缓存库,致力于更高效、更轻便、更简单 -- 支持内存缓存,使用LRUCache算法,对图片数据进行内存缓存 -- 支持磁盘缓存,对于下载图片会保存一份至磁盘当中 -- 支持进行图片变换 -- 支持用户配置参数使用:(例如:配置是否开启第一级内存缓存,配置磁盘缓存策略,配置仅使用缓存加载数据,配置图片变换效果,配置占位图,配置加载失败占位图等) -- 推荐使用ImageKnifeComponent组件配合ImageKnifeOption参数来实现功能 -- 支持用户自定义配置实现能力参考ImageKnifeComponent组件中对于入参ImageKnifeOption的处理 +专门为OpenHarmony打造的一款图像加载缓存库,致力于更高效、更轻便、更简单: +- 支持内存缓存,使用LRUCache算法,对图片数据进行内存缓存。 +- 支持磁盘缓存,对于下载图片会保存一份至磁盘当中。 +- 支持进行图片变换。 +- 支持用户配置参数使用:(例如:配置是否开启第一级内存缓存,配置磁盘缓存策略,配置仅使用缓存加载数据,配置图片变换效果,配置占位图,配置加载失败占位图等)。 +- 推荐使用ImageKnifeComponent组件配合ImageKnifeOption参数来实现功能。 +- 支持用户自定义配置实现能力参考ImageKnifeComponent组件中对于入参ImageKnifeOption的处理。 diff --git a/README.md b/README.md index b464be3..6c45d7d 100644 --- a/README.md +++ b/README.md @@ -321,4 +321,6 @@ let requestOptin = new RequestOption(); 1.图片变换缓慢(待优化)。 -2.目前只支持一种图片变换效果。 \ No newline at end of file +2.目前只支持一种图片变换效果。 + +3.目前svg和gif动图不支持变换效果。 \ No newline at end of file diff --git a/entry/src/main/config.json b/entry/src/main/config.json index 77afc4e..6d3d97f 100644 --- a/entry/src/main/config.json +++ b/entry/src/main/config.json @@ -1,7 +1,7 @@ { "app": { - "vendor": "example", - "bundleName": "com.example.imageknifegiteepro", + "vendor": "openharmony", + "bundleName": "cn.openharmony.imageknife", "version": { "code": 1000000, "name": "1.0.0" @@ -51,7 +51,7 @@ "deliveryWithInstall": true, "moduleName": "entry" }, - "package": "com.example.entry", + "package": "cn.openharmony.entry", "srcPath": "", "name": ".entry", "reqPermissions": [ @@ -63,7 +63,7 @@ "reason": "Api call", "usedScene": { "ability": [ - "com.example.imageknifegiteepro.MainAbility" + "cn.openharmony.imageknife.MainAbility" ], "when": "always" } @@ -77,7 +77,7 @@ "usedScene": { "when": "always", "ability": [ - "com.example.imageknifegiteepro.MainAbility" + "cn.openharmony.imageknife.MainAbility" ] } }, @@ -87,7 +87,7 @@ "usedScene": { "when": "always", "ability": [ - "com.example.imageknifegiteepro.MainAbility" + "cn.openharmony.imageknife.MainAbility" ] } } diff --git a/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage2.ets b/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage2.ets index 5503b4b..7edb12a 100644 --- a/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage2.ets +++ b/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage2.ets @@ -15,6 +15,8 @@ import {ImageKnifeComponent} from '@ohos/imageknife' import {ImageKnifeOption} from '@ohos/imageknife' import {RotateImageTransformation} from '@ohos/imageknife' +import {GrayscaleTransformation} from '@ohos/imageknife' +import {SketchFilterTransformation} from '@ohos/imageknife' @Entry @Component @@ -42,7 +44,8 @@ struct TestImageKnifeOptionChangedPage2 { placeholderSrc: $r('app.media.icon_loading'), errorholderSrc: $r('app.media.icon_failed'), 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) Button("网络资源png") @@ -53,7 +56,8 @@ struct TestImageKnifeOptionChangedPage2 { placeholderSrc: $r('app.media.icon_loading'), errorholderSrc: $r('app.media.icon_failed'), 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) Button("网络资源bmp") @@ -64,7 +68,8 @@ struct TestImageKnifeOptionChangedPage2 { placeholderSrc: $r('app.media.icon_loading'), errorholderSrc: $r('app.media.icon_failed'), margin:{left:5,top:5,right:5,bottom:5}, - thumbSizeMultiplier:0.1 + thumbSizeMultiplier:0.1, + transformations:[new GrayscaleTransformation()] }; }).margin({left:5}).backgroundColor(Color.Blue) Button("网络资源webp") @@ -75,7 +80,8 @@ struct TestImageKnifeOptionChangedPage2 { placeholderSrc: $r('app.media.icon_loading'), errorholderSrc: $r('app.media.icon_failed'), margin:{left:5,top:5,right:5,bottom:5}, - thumbSizeMultiplier:0.1 + thumbSizeMultiplier:0.1, + transformations:[new SketchFilterTransformation()] }; }).margin({left:5}).backgroundColor(Color.Blue) } diff --git a/imageknife/package-lock.json b/imageknife/package-lock.json index 9209c18..c6a681a 100644 --- a/imageknife/package-lock.json +++ b/imageknife/package-lock.json @@ -1,6 +1,6 @@ { "name": "@ohos/imageknife", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/imageknife/package.json b/imageknife/package.json index 9569b86..342ebdb 100644 --- a/imageknife/package.json +++ b/imageknife/package.json @@ -12,7 +12,7 @@ }, "main": "index.ets", "repository": "https://gitee.com/openharmony-tpc/ImageKnife", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "pako": "^1.0.5" }, diff --git a/imageknife/src/main/config.json b/imageknife/src/main/config.json index 0d64e9a..7e6421e 100644 --- a/imageknife/src/main/config.json +++ b/imageknife/src/main/config.json @@ -1,7 +1,7 @@ { "app": { - "bundleName": "com.example.imageknifegiteepro", - "vendor": "example", + "bundleName": "cn.openharmony.imageknife", + "vendor": "openharmony", "version": { "code": 1000000, "name": "1.0.0" @@ -9,7 +9,7 @@ }, "deviceConfig": {}, "module": { - "package": "com.example.imageknife", + "package": "cn.openharmony.imageknife", "deviceType": [ "phone", "tablet" diff --git a/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets b/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets index 69a5c23..a017127 100644 --- a/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets +++ b/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets @@ -147,6 +147,12 @@ export struct ImageKnifeComponent { if (this.imageKnifeOption.transform) { 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) { request.dontAnimate() } diff --git a/imageknife/src/main/ets/components/imageknife/ImageKnifeOption.ets b/imageknife/src/main/ets/components/imageknife/ImageKnifeOption.ets index 775a212..f2e047f 100644 --- a/imageknife/src/main/ets/components/imageknife/ImageKnifeOption.ets +++ b/imageknife/src/main/ets/components/imageknife/ImageKnifeOption.ets @@ -73,6 +73,9 @@ export class ImageKnifeOption { rotateImage?:number } + transformation?:BaseTransform; + + transformations?:Array>; // 输出缓存相关内容和信息 allCacheInfoCallback?: IAllCacheInfoCallback; diff --git a/imageknife/src/main/ets/components/imageknife/RequestOption.ets b/imageknife/src/main/ets/components/imageknife/RequestOption.ets index 9304d76..7eeb2cc 100644 --- a/imageknife/src/main/ets/components/imageknife/RequestOption.ets +++ b/imageknife/src/main/ets/components/imageknife/RequestOption.ets @@ -308,6 +308,14 @@ export class RequestOption { this.transformations.push(transformation); return this; } + transform(input:BaseTransform){ + this.transformations.push(input); + return this; + } + transforms(inputs:BaseTransform[]){ + this.transformations = inputs; + return this; + } // 占位图解析成功