diff --git a/.gitignore b/.gitignore
index e3c661c..39187eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,17 +1,4 @@
-*.iml
-.gradle
-/local.properties
-/.idea/caches
-/.idea/libraries
-/.idea/modules.xml
-/.idea/workspace.xml
-/.idea/navEditor.xml
-/.idea/assetWizardSettings.xml
-.DS_Store
-/build
-/captures
-.externalNativeBuild
-/entry/.preview
-.cxx
/node_modules
-.idea
+/local.properties
+/.idea
+**/build
\ No newline at end of file
diff --git a/OAT.xml b/OAT.xml
new file mode 100644
index 0000000..3ffe033
--- /dev/null
+++ b/OAT.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/READEME.OPENSOURCE.md b/READEME.OpenSource.md
similarity index 71%
rename from READEME.OPENSOURCE.md
rename to READEME.OpenSource.md
index ed4a8b1..4eeb1d0 100644
--- a/READEME.OPENSOURCE.md
+++ b/READEME.OpenSource.md
@@ -2,21 +2,21 @@
{
"Name": "glide",
"License": "under one or more license",
- "License File": "https://github.com/bumptech/glide/blob/master/LICENSE",
+ "License File": "https://github.com/bumptech/imageknife/blob/master/LICENSE",
"Version Number": "4.13.1",
"Owner" : "bumptech"
- "Upstream URL": "https://github.com/bumptech/glide",
- "Description": "An image loading and caching library for Android focused on smooth scrolling"
+ "Upstream URL": "https://github.com/bumptech/imageknife",
+ "Description": "An image loading and caching library focused on smooth scrolling"
},
{
"Name": "glide-transformations",
"License": "Apache License 2.0",
- "License File": "https://github.com/wasabeef/glide-transformations/blob/main/LICENSE",
+ "License File": "https://github.com/wasabeef/imageknife-transformations/blob/main/LICENSE",
"Version Number": "4.3.0",
"Owner" : "wasabeef"
- "Upstream URL": "https://github.com/wasabeef/glide-transformations",
- "Description": " An Android transformation library providing a variety of image transformations for Glide. "
+ "Upstream URL": "https://github.com/wasabeef/imageknife-transformations",
+ "Description": " An transformation library providing a variety of image transformations for Glide. "
},
{
@@ -26,7 +26,7 @@
"Version Number": "2.6.0",
"Owner" : "facebook"
"Upstream URL": "https://github.com/facebook/fresco",
- "Description": " An Android library for managing images and the memory they use. "
+ "Description": " An library for managing images and the memory they use. "
},
{
@@ -56,7 +56,7 @@
"Version Number": "2.2.8",
"Owner" : " Yalantis"
"Upstream URL": "https://github.com/Yalantis/uCrop",
- "Description": " Image Cropping Library for Android "
+ "Description": " Image Cropping Library "
}
]
\ No newline at end of file
diff --git a/README.md b/README.md
index 5d15af9..3e55f0a 100644
--- a/README.md
+++ b/README.md
@@ -4,18 +4,36 @@
## 简介
+本项目基于开源库 [Glide](https://github.com/bumptech/glide) 进行OpenHarmony的自研版本
+
- 支持内存缓存,使用LRUCache算法,对图片数据进行内存缓存
-- 支持磁盘缓存,对于下载图片会保存一份至磁盘当中。
-- 支持进行图片变换。
-- 支持用户配置参数使用:(例如:配置是否开启第一级内存缓存,配置磁盘缓存策略,配置仅使用缓存加载数据,配置图片变换效果,配置占位图,配置加载失败占位图等)。
-- 推荐使用GlideImage组件配合GlideOption参数来实现功能
-- 支持用户自定义配置实现能力参考GlideImage组件中对于入参GlideOption的处理
+- 支持磁盘缓存,对于下载图片会保存一份至磁盘当中
+- 支持进行图片变换
+- 支持用户配置参数使用:(例如:配置是否开启第一级内存缓存,配置磁盘缓存策略,配置仅使用缓存加载数据,配置图片变换效果,配置占位图,配置加载失败占位图等)
+- 推荐使用ImageKnifeComponent组件配合ImageKnifeOption参数来实现功能
+- 支持用户自定义配置实现能力参考ImageKnifeComponent组件中对于入参ImageKnifeOption的处理
+
+## 下载安装
+
+1.参考安装教程 [如何安装OpenHarmony npm包](https://gitee.com/openharmony-tpc/docs/blob/master/OpenHarmony_npm_usage.md)
+
+2.安装命令如下:
+
+```
+npm install @ohos/imageknife --save
+```
+
+
+
+## 使用说明
+
+[跳转至代码示例](##'代码示例')
## 目录
```
-/entry/src/
-- main/ets/MainAbility
+/imageknife/src/
+- main/ets/components
- cache # 缓存相关内容
- diskstrategy # 缓存策略
- key # 缓存key生成策略
@@ -28,7 +46,7 @@
- LruCache.ets # 内存LRU缓存策略
- Md5.ets # MD5算法
- - glide # glide主要内容
+ - imageknife # imageknife主要内容
- compress # 压缩相关
- constants # 常量相关
- entry # 部分数据结构
@@ -36,26 +54,28 @@
- interface # 接口相关
- networkmanage # 网络相关
- pngj # pngj相关
- - requestmanage # Glide请求相关
+ - requestmanage # imageknife请求相关
- resourcemanage # 本地资源解析相关
- transform # 图片变换相关
- utils # 工具类相关
- - Glide.ets # Glide门面,app持久化类
- - GlideData.ets # 数据封装
- - GlideImage.ets # 自定义控件封装
- - GlideOption.ets # 用户传参数封装
+ - ImageKnife.ets # imageknife门面,app持久化类
+ - ImageKnifeData.ets # 数据封装
+ - ImageKnifeComponent.ets # 自定义控件封装
+ - ImageKnifeOption.ets # 用户传参数封装
- PixelMapPack.ets # PixelMap封装
- RequestOption.ets # 用户设置参数封装
+/entry/src/
+- main/ets/MainAbility
- pages # 测试page页面列表
- basicTestFeatureAbilityPage.ets # 测试元能力
- basicTestFileIOPage.ets # 测试fileio
- basicTestMediaImage.ets # 测试媒体image
- basicTestResourceManagerPage.ets # 测试本地资源解析
- - CompressPage.ets # 压缩页面
+ - compressPage.ets # 压缩页面
- frescoImageTestCasePage.ets # 测试属性动画组件切换
- - frescoLayerTestCasePage.ets # 测试GlideImage组件切换配合属性动画
- - frescoRetryTestCasePage.ets # 测试GlideImage加载失败重试
+ - frescoLayerTestCasePage.ets # 测试ImageKnifeComponent组件切换配合属性动画
+ - frescoRetryTestCasePage.ets # 测试ImageKnifeComponent加载失败重试
- index.ets # 测试页面入口
- indexFresco.ets # 二级测试页面入口
- loadNetworkTestCasePage.ets # 网络加载测试
@@ -64,17 +84,17 @@
- storageTestDiskLruCache.ets # 磁盘缓存测试
- storageTestLruCache.ets # 内存缓存测试
- testAllCacheInfoPage.ets # 所有缓存信息获取测试
- - testAllTypeGlideImagePage.ets # 所有类型图片加载测试
+ - testAllTypeImageKnifeComponentPage.ets # 所有类型图片加载测试
- testAllTypeNativeImagePage.ets # 所有类型本地图片加载测试
- testGifDontAnimatePage.ets # gif加载静态图片测试
- - testGlideOptionChangedPage.ets # GlideOption数据切换测试
- - testGlideOptionChangedPage2.ets # GlideOption数据切换测试
+ - testImageKnifeOptionChangedPage.ets # ImageKnifeOption数据切换测试
+ - testImageKnifeOptionChangedPage2.ets # ImageKnifeOption数据切换测试
- testMultiThreadWorkerPage2.ets # 多线程测试
- testPlaceholderPage.ets # 加载占位图测试
- testPreloadPage.ets # 预加载测试
- testResourceManagerPage.ets # 解析本地资源测试
- - TransformPixelMapPage.ets # 所有类型变换测试
- - transformTestCasePage.ets # 所有类型变换配合GlideImage测试
+ - transformPixelMapPage.ets # 所有类型变换测试
+ - transformTestCasePage.ets # 所有类型变换配合ImageKnifeComponent测试
- workers # 测试worker多线程
- worker1.js # worker多线程测试
@@ -84,27 +104,24 @@
### RequestOpton 用户配置参数
-| 方法名 | 入参 | 接口描述 |
-| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| load(src: string \| PixelMap \| Resource) | string \| PixelMap \| Resource | 待加载图片的资源 |
-| setImageViewSize(imageSize: { width: number, height: number }) | { width: number, height: number } | 传入显示图片组件的大小,变换的时候需要作为参考 |
-| diskCacheStrategy(strategy: DiskStrategy) | DiskStrategy | 配置磁盘缓存策略 NONE SOURCE RESULT ALL AUTOMATIC |
-| placeholder(src: PixelMap \| Resource, func?: AsyncSuccess) | src: PixelMap \| Resource, func?: AsyncSuccess | 配置占位图,其中func为数据回调函数 |
-| errorholder(src: PixelMap \| Resource, func?: AsyncSuccess) | src: PixelMap \| Resource, func?: AsyncSuccess | 配置加载失败占位图,其中func为数据回调函数 |
-| addListener(func: AsyncCallback) | func: AsyncCallback | 配置整个监听回调,数据正常加载返回,加载失败返回错误信息 |
-| thumbnail(sizeMultiplier:number, func?: AsyncSuccess) | sizeMultiplier:number, func?: AsyncSuccess | 设置缩略图比例,缩略图返回后,加载并展示缩略图 |
-| addProgressListener(func?: AsyncSuccess){ this.progressFunc = func; return this; } | func?: AsyncSuccess | 设置网络下载百分比监听,返回数据加载百分比数值 |
-| addRetryListener(func?: AsyncSuccess){ this.retryFunc = func; return this; } | func?: AsyncSuccess | 设置重试监听 |
-| addAllCacheInfoCallback(func: IAllCacheInfoCallback) | func: IAllCacheInfoCallback | 设置获取所有缓存信息监听 |
-| skipMemoryCache(skip: boolean) | skip: boolean | 配置是否跳过内存缓存 |
-| retrieveDataFromCache(flag: boolean) | flag: boolean | 配置仅从缓存中加载数据 |
-| transform(transform: BaseTransform) | transform: BaseTransform | 配置自定义变换类型 |
-| centerCrop(fd: number, out_width: number, out_height: number, callback?: AsyncTransform>) | fd: number, out_width: number, out_height: number, callback?: AsyncTransform> | 静态方法可以根据图片文件,目标显示大小,进行对应centerCrop |
-| rotateImage(fd: number, degreesToRotate: number) | fd: number, degreesToRotate: number | 静态方法可以根据图片文件,和旋转角度,进行对应rotateImaroge |
-| centerInside(fd: number, out_width: number, out_height: number, callback?: AsyncTransform>) | fd: number, out_width: number, out_height: number, callback?: AsyncTransform> | 静态方法可以根据图片文件,目标显示大小,进行对应centerInside |
-| fitCenter(fd: number, out_width: number, out_height: number , callback?: AsyncTransform>) | fd: number, out_width: number, out_height: number , callback?: AsyncTransform> | 静态方法可以根据图片文件,目标显示大小,进行对应fitCenter |
+| 方法名 | 入参 | 接口描述 |
+| ------------------------------------------------------------ | ---------------------------------------------------------- | -------------------------------------------------------- |
+| load(src: string \| PixelMap \| Resource) | string \| PixelMap \| Resource | 待加载图片的资源 |
+| setImageViewSize(imageSize: { width: number, height: number }) | { width: number, height: number } | 传入显示图片组件的大小,变换的时候需要作为参考 |
+| diskCacheStrategy(strategy: DiskStrategy) | DiskStrategy | 配置磁盘缓存策略 NONE SOURCE RESULT ALL AUTOMATIC |
+| placeholder(src: PixelMap \| Resource, func?: AsyncSuccess) | src: PixelMap \| Resource, func?: AsyncSuccess | 配置占位图,其中func为数据回调函数 |
+| errorholder(src: PixelMap \| Resource, func?: AsyncSuccess) | src: PixelMap \| Resource, func?: AsyncSuccess | 配置加载失败占位图,其中func为数据回调函数 |
+| addListener(func: AsyncCallback) | func: AsyncCallback | 配置整个监听回调,数据正常加载返回,加载失败返回错误信息 |
+| thumbnail(sizeMultiplier:number, func?: AsyncSuccess) | sizeMultiplier:number, func?: AsyncSuccess | 设置缩略图比例,缩略图返回后,加载并展示缩略图 |
+| addProgressListener(func?: AsyncSuccess){ this.progressFunc = func; return this; } | func?: AsyncSuccess | 设置网络下载百分比监听,返回数据加载百分比数值 |
+| addRetryListener(func?: AsyncSuccess){ this.retryFunc = func; return this; } | func?: AsyncSuccess | 设置重试监听 |
+| addAllCacheInfoCallback(func: IAllCacheInfoCallback) | func: IAllCacheInfoCallback | 设置获取所有缓存信息监听 |
+| skipMemoryCache(skip: boolean) | skip: boolean | 配置是否跳过内存缓存 |
+| retrieveDataFromCache(flag: boolean) | flag: boolean | 配置仅从缓存中加载数据 |
-### Glide 启动器/门面类
+同时支持[图片变换相关](##'图片变换相关')接口
+
+### ImageKnife 启动器/门面类
| 方法名 | 入参 | 接口描述 |
| ------------------------------- | ---------------------- | ---------------------------------- |
@@ -123,42 +140,47 @@
### 图片变换相关
-| 使用方法 | 类型 | 相关描述 |
-| ------------------------------------------------------------ | ---------------------------------- | -------------- |
-| request.transforms(new BlurTransformation()) | BlurTransformation | 模糊处理 |
-| request.transforms(new BrightnessFilterTransformation()) | BrightnessFilterTransformation | 亮度滤波器 |
-| request.transforms(new ContrastFilterTransformation()) | ContrastFilterTransformation | 对比度滤波器 |
-| request.transforms(new CropCircleTransformation()) | CropCircleTransformation | 圆形剪裁显示 |
-| request.transforms(new CropCircleWithBorderTransformation()) | CropCircleWithBorderTransformation | 圆环展示 |
-| request.transforms(new CropSquareTransformation()) | CropSquareTransformation | 正方形剪裁 |
-| request.transforms(new CropTransformation()) | CropTransformation | 自定义矩形剪裁 |
-| request.transforms(new GrayscaleTransformation()) | GrayscaleTransformation | 灰度级转换 |
-| request.transforms(new InvertFilterTransformation()) | InvertFilterTransformation | 反转滤波器 |
-| request.transforms(new PixelationFilterTransformation()) | PixelationFilterTransformation | 像素化滤波器 |
-| request.transforms(new RotateImageTransformation()) | RotateImageTransformation | 图片旋转 |
-| request.transforms(new RoundedCornersTransformation()) | RoundedCornersTransformation | 圆角剪裁 |
-| request.transforms(new SepiaFilterTransformation()) | SepiaFilterTransformation | 乌墨色滤波器 |
-| request.transforms(new SketchFilterTransformation()) | SketchFilterTransformation | 素描滤波器 |
+| 使用方法 | 类型 | 相关描述 |
+| ------------------------------ | ---------------------------------- | ---------------------------------------------------- |
+| request.centerCrop() | CenterCrop | 可以根据图片文件,目标显示大小,进行对应centerCrop |
+| request.centerInside() | CenterInside | 可以根据图片文件,目标显示大小,进行对应centerInside |
+| request.fitCenter() | FitCenter | 可以根据图片文件,目标显示大小,进行对应fitCenter |
+| request.blur() | BlurTransformation | 模糊处理 |
+| request.brightnessFilter() | BrightnessFilterTransformation | 亮度滤波器 |
+| request.contrastFilter() | ContrastFilterTransformation | 对比度滤波器 |
+| request.cropCircle() | CropCircleTransformation | 圆形剪裁显示 |
+| request.cropCircleWithBorder() | CropCircleWithBorderTransformation | 圆环展示 |
+| request.cropSquare() | CropSquareTransformation | 正方形剪裁 |
+| request.crop() | CropTransformation | 自定义矩形剪裁 |
+| request.grayscale() | GrayscaleTransformation | 灰度级转换 |
+| request.invertFilter() | InvertFilterTransformation | 反转滤波器 |
+| request.pixelationFilter() | PixelationFilterTransformation | 像素化滤波器 |
+| request.rotateImage() | RotateImageTransformation | 图片旋转 |
+| request.roundedCorners() | RoundedCornersTransformation | 圆角剪裁 |
+| request.sepiaFilter() | SepiaFilterTransformation | 乌墨色滤波器 |
+| request.sketchFilter() | SketchFilterTransformation | 素描滤波器 |
+
+
## 代码示例
-1.首先初始化全局Glide实例,在app.ets中调用Glide.with()进行初始化
+1.首先初始化全局ImageKnife实例,在app.ets中调用ImageKnife.with()进行初始化
```
-import {Glide} from './glide/Glide.ets'
+import {ImageKnife} from '@ohos/imageknife'
export default {
data: {
- glide: {} // Glide全局占位符
+ imageKnife: {} // ImageKnife全局占位符
},
onCreate() {
- this.data.glide = Glide.with();// Glide占位符全局初始化赋值
+ this.data.imageKnife = ImageKnife.with();// ImageKnife占位符全局初始化赋值
}
}
```
-2.在页面index.ets中使用Glide
+2.在页面index.ets中使用ImageKnife
```
@Entry
@@ -168,7 +190,7 @@ struct Index {
}
- // 页面初始化完成,生命周期回调函数中 进行调用Glide
+ // 页面初始化完成,生命周期回调函数中 进行调用ImageKnife
aboutToAppear() {
let requestOption = new RequestOption();
requestOptin.load($r('app.media.IceCream'))
@@ -176,14 +198,14 @@ struct Index {
//加载成功/失败回调监听
})
...
- Glide.call(requestOption)
+ ImageKnife.call(requestOption)
}
}
-var Glide;
+var ImageKnife;
var defaultTemp = globalThis.exports.default
if (defaultTemp != undefined) {
- Glide = defaultTemp.data.glide;
+ ImageKnife = defaultTemp.data.imageKnife;
}
```
@@ -191,15 +213,15 @@ if (defaultTemp != undefined) {
#### 推荐使用:
-使用GlideOption作为入参,配合自定义组件GlideImage使用。
+使用ImageKnifeOption作为入参,配合自定义组件ImageKnifeComponent使用。
```typescript
@Entry
@Component
struct Index {
- @State glideOption1: GlideOption =
+ @State imageKnifeOption1: ImageKnifeOption =
{
- loadSrc: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ericA1Mv66TwicuYOtbDMBcUhv1aa9RJBeAn9uURfcZD0AUGrJebAn1g2AjN0vb2E1XTET7fTuLBNmA/132",
+ loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
@@ -209,7 +231,7 @@ struct Index {
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- GlideImage({ glideOption: $glideOption1 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
}
}
.width('100%')
@@ -225,15 +247,16 @@ struct Index {
##### 步骤1:
定义自定义类
+
+```
export default class PixelMapPack{
-
pixelMap:PixelMap;
-
}
-使用@State关联PixelMapPack
+```
+使用@State关联PixelMapPack
```typescript
-@State glidePixelMapPack:PixelMapPack = new PixelMapPack();
+@State imageKnifePixelMapPack:PixelMapPack = new PixelMapPack();
width:number = 200;
height:number = 200;
```
@@ -243,7 +266,7 @@ height:number = 200;
在你的component组件中,写下一个Image组件,将基础参数(入参PixelMap,组件的宽、高)配置好
```
-Image(this.glidePixelMapPack.pixelMap)
+Image(this.imageKnifePixelMapPack.pixelMap)
.backgroundColor(Color.Grey)
.objectFit(ImageFit.Contain)
.width(this.width)
@@ -258,40 +281,59 @@ Image(this.glidePixelMapPack.pixelMap)
//配置参数
let requestOptin = new RequestOption();
//加载本地图片
- requestOptin.load($r('app.media.IceCream'))
+ requestOptin.load($r('app.media.jpgSample'))
.addListener((err,data) => {
//加载成功/失败回调监听
})
.placeholder( $r('app.media.icon_loading'), (data)=>{
// 占位图回调监听
})
- .errorholder(this.glideOption.errorholderSrc, (data)=>{
+ .errorholder( $r('app.media.icon_failed'), (data)=>{
// 失败占位图回调监听
})
- .thumbnail(this.glideOption.thumbSizeMultiplier, (data) => {
+ .thumbnail(0.3, (data) => {
// 缩略图加载成功回调
})
// 一定要把控件大小传给RequestOption,图片变换必须
- .setImageViewSize({width:this.width, height:this.height})
+ .setImageViewSize({width:200, height:200})
// 设置缓存策略
- .diskCacheStrategy(new Strategy())
+ .diskCacheStrategy(new AUTOMATIC())
.addProgressListener((percentValue: string) => {
// 图片网络加载进度条百分比回调
})
.addRetryListener((error: any) => {
// 加载失败重试监听 图片加载失败时优先展示重试图层,点击重试图层,会重新进行一次加载流程
})
- .transforms(new RoundedCornersTransformation({top:10}))
+ // 左上圆角10pixel像素点
+ .roundedCorners({top:10})
// 启动加载流程,执行结果将会返回到上面的回调接口中
- Glide.call(requestOptin);
+ ImageKnife.call(requestOptin);
```
##### 步骤4:
-更多细节设置请参考自定义Component的GlideImage实现
+更多细节设置请参考自定义Component的ImageKnifeComponent实现
## 演示
-
\ No newline at end of file
+
+
+## 兼容性
+
+支持OpenHarmony API version 8 及以上版本
+
+## 开源协议
+
+[协议详见](https://gitee.com/openharmony-tpc/ImageKnife/blob/master/LICENSE)
+
+## 贡献代码
+
+使用过程中发现任何问题都可以提[issue](https://gitee.com/openharmony-tpc/ImageKnife/issues)给我们,当然,我们也非常欢迎你给我们发[PR](https://gitee.com/openharmony-tpc/ImageKnife/issues)
+
+## 遗留问题
+
+1.图片变换缓慢(待优化)
+
+2.目前只支持一种图片变换效果
\ No newline at end of file
diff --git a/build-profile.json5 b/build-profile.json5
new file mode 100644
index 0000000..d787b0e
--- /dev/null
+++ b/build-profile.json5
@@ -0,0 +1,44 @@
+{
+ "app": {
+ "signingConfigs": [
+ {
+ "name": "default",
+ "material": {
+ "certpath": "C:\\Users\\zwx1045834\\.ohos\\config\\openharmony\\auto_ohos.cer",
+ "storePassword": "000000184CD86AF7B78D3E3B6C36B9221705137AC28BD8A341A757477E5DC27D95E6A0DFD5EB51AE",
+ "keyAlias": "debugKey",
+ "keyPassword": "00000018DAB1AB9C9DF6E7C4D35BE8EAF4323EFA49131AB39C65BA5C44DE6D3879C6B31AA70D1E14",
+ "profile": "C:\\Users\\zwx1045834\\.ohos\\config\\openharmony\\auto_ohos_default_com.example.imageknifegiteepro.p7b",
+ "signAlg": "SHA256withECDSA",
+ "storeFile": "C:\\Users\\zwx1045834\\.ohos\\config\\openharmony\\auto_ohos.p12"
+ }
+ }
+ ],
+ "compileSdkVersion": 8,
+ "compatibleSdkVersion": 8,
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "imageknife",
+ "srcPath": "./imageknife"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 17664f5..0000000
--- a/build.gradle
+++ /dev/null
@@ -1,35 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-apply plugin: 'com.huawei.ohos.app'
-
-//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
-ohos {
- compileSdkVersion 8
- supportSystem "standard"
-
-}
-
-buildscript {
- repositories {
- maven {
- url 'https://repo.huaweicloud.com/repository/maven/'
- }
- maven {
- url 'https://developer.huawei.com/repo/'
- }
- }
- dependencies {
- classpath 'com.huawei.ohos:hap:3.0.5.2'
- classpath 'com.huawei.ohos:decctest:1.2.7.2'
- }
-}
-
-allprojects {
- repositories {
- maven {
- url 'https://repo.huaweicloud.com/repository/maven/'
- }
- maven {
- url 'https://developer.huawei.com/repo/'
- }
- }
-}
diff --git a/entry/.gitignore b/entry/.gitignore
index 7d5b7a9..4f9a973 100644
--- a/entry/.gitignore
+++ b/entry/.gitignore
@@ -1,2 +1,3 @@
-/build
/node_modules
+/.preview
+/build
\ No newline at end of file
diff --git a/entry/build-profile.json5 b/entry/build-profile.json5
new file mode 100644
index 0000000..ae58d1d
--- /dev/null
+++ b/entry/build-profile.json5
@@ -0,0 +1,13 @@
+{
+ "apiType": 'faMode',
+ "buildOption": {
+ },
+ "targets": [
+ {
+ "name": "default",
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/build.gradle b/entry/build.gradle
deleted file mode 100644
index 05a33cd..0000000
--- a/entry/build.gradle
+++ /dev/null
@@ -1,21 +0,0 @@
-apply plugin: 'com.huawei.ohos.hap'
-//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
-ohos {
- compileSdkVersion 8
- defaultConfig {
- compatibleSdkVersion 8
- }
- buildTypes {
- release {
- proguardOpt {
- proguardEnabled false
- rulesFiles 'proguard-rules.pro'
- }
- }
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
- testImplementation 'junit:junit:4.13.1'
-}
diff --git a/entry/hvigorfile.js b/entry/hvigorfile.js
new file mode 100644
index 0000000..bcec4c9
--- /dev/null
+++ b/entry/hvigorfile.js
@@ -0,0 +1,2 @@
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+module.exports = require('@ohos/hvigor-ohos-plugin').legacyHapTasks
diff --git a/entry/package-lock.json b/entry/package-lock.json
new file mode 100644
index 0000000..91c2411
--- /dev/null
+++ b/entry/package-lock.json
@@ -0,0 +1,21 @@
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "@ohos/imageknife": {
+ "version": "file:../imageknife",
+ "requires": {
+ "pako": "^1.0.5"
+ },
+ "dependencies": {
+ "pako": {
+ "version": "1.0.11",
+ "resolved": "http://mirrors.tools.huawei.com/npm/pako/-/pako-1.0.11.tgz",
+ "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
+ }
+ }
+ }
+ }
+}
diff --git a/entry/package.json b/entry/package.json
new file mode 100644
index 0000000..bce3fa8
--- /dev/null
+++ b/entry/package.json
@@ -0,0 +1,14 @@
+{
+ "license": "Apache License 2.0",
+ "devDependencies": {},
+ "name": "entry",
+ "ohos": {
+ "org": "huawei",
+ "directoryLevel": "module",
+ "buildTool": "hvigor"
+ },
+ "version": "1.0.0",
+ "dependencies": {
+ "@ohos/imageknife": "file:../imageknife"
+ }
+}
diff --git a/entry/proguard-rules.pro b/entry/proguard-rules.pro
deleted file mode 100644
index f7666e4..0000000
--- a/entry/proguard-rules.pro
+++ /dev/null
@@ -1 +0,0 @@
-# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
index a0f0190..77afc4e 100644
--- a/entry/src/main/config.json
+++ b/entry/src/main/config.json
@@ -1,7 +1,7 @@
{
"app": {
- "bundleName": "com.huawei.mydemoall",
- "vendor": "huawei",
+ "vendor": "example",
+ "bundleName": "com.example.imageknifegiteepro",
"version": {
"code": 1000000,
"name": "1.0.0"
@@ -15,21 +15,11 @@
}
},
"module": {
- "package": "com.bumptech.glidejs_ohos",
- "name": ".MyApplication",
"mainAbility": ".MainAbility",
- "srcPath": "",
"deviceType": [
"phone",
- "tablet",
- "default"
+ "tablet"
],
- "distro": {
- "deliveryWithInstall": true,
- "moduleName": "entry",
- "moduleType": "entry",
- "installationFree": false
- },
"abilities": [
{
"skills": [
@@ -48,13 +38,22 @@
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
- "description": "$string:mainability_description",
+ "description": "$string:ImageKnife_OHOS",
"formsEnabled": false,
- "label": "$string:GlideJS_OHOS",
+ "label": "$string:ImageKnife_OHOS",
"type": "page",
"launchType": "standard"
}
],
+ "distro": {
+ "moduleType": "entry",
+ "installationFree": false,
+ "deliveryWithInstall": true,
+ "moduleName": "entry"
+ },
+ "package": "com.example.entry",
+ "srcPath": "",
+ "name": ".entry",
"reqPermissions": [
{
"name": "ohos.permission.READ_USER_STORAGE"
@@ -64,7 +63,7 @@
"reason": "Api call",
"usedScene": {
"ability": [
- "com.zls.glidejscache.MainAbility"
+ "com.example.imageknifegiteepro.MainAbility"
],
"when": "always"
}
@@ -78,7 +77,7 @@
"usedScene": {
"when": "always",
"ability": [
- "com.zls.glidejscache.MainAbility"
+ "com.example.imageknifegiteepro.MainAbility"
]
}
},
@@ -88,7 +87,7 @@
"usedScene": {
"when": "always",
"ability": [
- "com.zls.glidejscache.MainAbility"
+ "com.example.imageknifegiteepro.MainAbility"
]
}
}
@@ -111,27 +110,24 @@
"pages/basicTestResourceManagerPage",
"pages/storageTestLruCache",
"pages/storageTestDiskLruCache",
- "pages/testMemoryCachePage",
"pages/transformTestCasePage",
"pages/pngjTestCasePage",
- "pages/testAllTypeGlideImagePage",
+ "pages/testAllTypeImageKnifeComponentPage",
"pages/testAllTypeNativeImagePage",
"pages/loadResourceTestCasePage",
"pages/loadNetworkTestCasePage",
"pages/showErrorholderTestCasePage",
- "pages/TransformPixelMapPage",
+ "pages/transformPixelMapPage",
"pages/testGifDontAnimatePage",
"pages/testPreloadPage",
- "pages/testGlideOptionChangedPage",
- "pages/testGlideOptionChangedPage2",
- "pages/CompressPage",
+ "pages/testImageKnifeOptionChangedPage",
+ "pages/testImageKnifeOptionChangedPage2",
+ "pages/compressPage",
"pages/testAllCacheInfoPage",
"pages/testResourceManagerPage",
"pages/testMultiThreadWorkerPage2",
- "pages/testGlideOptionChangedPage",
- "pages/CropImagePage",
- "pages/networkTestCasePage",
- "pages/jpegProgressTestCasePage"
+ "pages/testImageKnifeOptionChangedPage",
+ "pages/cropImagePage"
],
"name": ".MainAbility",
"window": {
diff --git a/entry/src/main/ets/MainAbility/app.ets b/entry/src/main/ets/MainAbility/app.ets
index 2f3c856..b2d066b 100644
--- a/entry/src/main/ets/MainAbility/app.ets
+++ b/entry/src/main/ets/MainAbility/app.ets
@@ -14,17 +14,14 @@
*/
import app from '@system.app';
-import {Glide} from './glide/Glide.ets'
+import {ImageKnife} from '@ohos/imageknife'
export default {
data: {
- glide: {} // Glide
+ imageKnife: {} // ImageKnife
},
onCreate() {
- this.data.glide = Glide.with();
- app.setImageCacheCount(100);
- app.setImageRawDataCacheSize(104857600)
- app.setImageFileCacheSize(209715200)
+ this.data.imageKnife = ImageKnife.with();
},
onDestroy() {
diff --git a/entry/src/main/ets/MainAbility/glide/GlideImage.ets b/entry/src/main/ets/MainAbility/glide/GlideImage.ets
deleted file mode 100644
index b142c97..0000000
--- a/entry/src/main/ets/MainAbility/glide/GlideImage.ets
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright (C) 2021 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the 'License');
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an 'AS IS' BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {GlideOption} from '../glide/GlideOption.ets'
-import {RequestOption} from '../glide/RequestOption.ets'
-import {GlideData} from '../glide/GlideData.ets'
-import {PixelMapPack} from '../glide/PixelMapPack.ets'
-import {Base64} from '../cache/Base64.ets'
-import resourceManager from '@ohos.resourceManager';
-import image from '@ohos.multimedia.image';
-
-@Component
-export struct GlideImage {
- @Watch('watchGlideOption') @Link glideOption: GlideOption;
- @State glidePixelMapPack: PixelMapPack = new PixelMapPack();
- @State glideResource: Resource = $r('app.media.icon_loading')
- @State glideString: string = ''
- @State normalPixelMap: boolean = true;
- @State normalResource: boolean = true;
- previousData: GlideData = null;
- nowData: GlideData = null;
- @State percentVisible: Visibility = Visibility.Visible
- @State retryVisible: Visibility = Visibility.Visible
- @State imageVisible: Visibility = Visibility.Visible
- @State percent: string = '0%'
- @State percentWidth: string = '0%';
- @State percentHeight: string = '0%';
- @State retryWidth: string = '0%';
- @State retryHeight: string = '0%';
- @State imageWidth: string = '100%';
- @State imageHeight: string = '100%';
-
- hasRetry:boolean = false;
-
- build() {
- Stack() {
-
- Text(this.percent)
- .fontSize(this.glideOption.size ? Math.min(this.glideOption.size.height, this.glideOption.size.width) / 2 : 24)
- .fontWeight(FontWeight.Bold)
- .visibility(this.retryVisible)
- .width(this.percentWidth)
- .height(this.percentHeight)
-
- Image($r('app.media.icon_retry'))
- .onClick(()=>{
- this.retryClick();
- })
- .visibility(this.retryVisible)
- .width(this.retryWidth)
- .height(this.retryHeight)
-
-
-
- Image(this.normalPixelMap ? this.glidePixelMapPack.pixelMap : (this.normalResource ? this.glideResource : this.glideString))
- .objectFit(this.glideOption.imageFit ? this.glideOption.imageFit : ImageFit.Fill)
- .visibility(this.imageVisible)
- .width(this.imageWidth)
- .height(this.imageHeight)
- }
- .width(this.glideOption.size ? this.glideOption.size.width : '100%')
- .height(this.glideOption.size ? this.glideOption.size.height : '100%')
- .backgroundColor(this.glideOption.backgroundColor ? this.glideOption.backgroundColor : Color.White)
- .margin(this.glideOption.margin ? this.glideOption.margin : { left: 0, top: 0, right: 0, bottom: 0 })
- }
-
- watchGlideOption() {
- this.glideExecute();
- }
-
- retryClick(){
- this.hasRetry = true;
- this.glideExecute();
- }
-
- aboutToAppear() {
- console.log('glideImage aboutToAppear happened!')
- this.glideExecute();
- }
-
- configNecessary(request: RequestOption){
- // 为了测试重试加载 串讲完成后删除
- if(this.glideOption.loadSrc == 'https://hbimg.huabanimg.com/testRetryxxxx' && this.hasRetry){
- request.load('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp')
- .addListener((err, data) => {
- this.glideChangeSource(data)
- this.animateTo('image');
- return false;
- })
- }else {
-
- request.load(this.glideOption.loadSrc)
- .addListener((err, data) => {
- this.glideChangeSource(data)
- this.animateTo('image');
- return false;
- })
- }
-
- if (this.glideOption.size) {
- request.setImageViewSize(this.glideOption.size)
- }
- }
-
- configCacheStrategy(request: RequestOption){
- if (this.glideOption.onlyRetrieveFromCache) {
- request.retrieveDataFromCache(this.glideOption.onlyRetrieveFromCache)
- }
-
- if (this.glideOption.isCacheable) {
- request.skipMemoryCache(!this.glideOption.isCacheable)
- }
-
- if (this.glideOption.strategy) {
- request.diskCacheStrategy(this.glideOption.strategy)
- }
- if (this.glideOption.allCacheInfoCallback) {
- request.addAllCacheInfoCallback(this.glideOption.allCacheInfoCallback)
- }
- }
-
- configDisplay(request: RequestOption){
- if(this.glideOption.animateDuration >= 0){
- request.animateDuraction = this.glideOption.animateDuration;
- }
- if (this.glideOption.placeholderSrc) {
- request.placeholder(this.glideOption.placeholderSrc, (data) => {
- this.glideChangeSource(data)
- this.animateTo('image');
- })
- }
- if (this.glideOption.thumbSizeMultiplier) {
- request.thumbnail(this.glideOption.thumbSizeMultiplier, (data) => {
- this.glideChangeSource(data)
- this.animateTo('image');
- })
- }
- if (this.glideOption.errorholderSrc) {
- request.errorholder(this.glideOption.errorholderSrc, (data) => {
- this.glideChangeSource(data)
- this.animateTo('image');
- })
- }
- if (this.glideOption.transformtions) {
- request.transforms(this.glideOption.transformtions)
- }
- if (this.glideOption.dontAnimateFlag) {
- request.dontAnimate()
- }
-
-
- if (this.glideOption.displayProgress) {
- request.addProgressListener((percentValue: string) => {
- // 如果进度条百分比 未展示大小,展示其动画
- this.percent = percentValue;
- if(this.glideOption.displayProgressListener){
- this.glideOption.displayProgressListener(percentValue);
- }
- this.animateTo('progress');
- })
- }
-
- if(this.glideOption.retryLoad){
- request.addRetryListener((error: any) => {
- console.log("RetryListener callback!")
- this.animateTo('retry');
- })
- }
- }
- // glide 第一次启动和数据刷新后重新发送请求
- glideExecute() {
- let request = new RequestOption();
- this.configNecessary(request);
- this.configCacheStrategy(request);
- this.configDisplay(request);
- let svgGif = Glide.getSvgAndGifFolder();
- console.log("输出SVG和gif的缓存地址="+svgGif)
- console.log("GlideImage Ready to 'call' method! Glide is null="+(Glide == null || Glide == undefined))
- Glide.call(request);
- }
-
- glideChangeSource(data:GlideData) {
- this.glideSpecialFixed(data);
- }
-
- displayPixelMap(data:GlideData){
-
- this.normalPixelMap = true;
- this.normalResource = true;
- let pack = new PixelMapPack();
- this.glidePixelMapPack = pack;
- setTimeout(() => {
- let pixelMapPack2 = new PixelMapPack();
- pixelMapPack2.pixelMap = data.glideValue as PixelMap;
- this.glidePixelMapPack = pixelMapPack2;
- },100)
- }
-
- displayResource(data:GlideData){
- this.normalPixelMap = false;
- this.normalResource = true;
- this.glideResource = data.glideValue as Resource;
- }
-
- displayString(data:GlideData){
-
- this.normalPixelMap = false;
- this.normalResource = false;
- let firstIndex = (data.glideValue as string).indexOf(Glide.getSvgAndGifFolder());
- let suffix = (data.glideValue as string).substring(firstIndex, (data.glideValue as string).length)
-// let glideNeedStr = 'internal://app/' + suffix;
- let glideNeedStr = 'file://' + data.glideValue;
- this.glideString = glideNeedStr;
-
- }
- glideSpecialFixed(data:GlideData) {
- if (data.isPixelMap()) {
- this.displayPixelMap(data);
- }
- else if (data.isString()) {
- this.displayString(data);
- } else if (data.isResource()) {
- this.displayResource(data);
- } else {
- }
- }
-
- animateTo(name: string) {
- if (name == 'progress') {
- this.percentVisible = Visibility.Visible;
- this.imageVisible = Visibility.Hidden;
- this.retryVisible = Visibility.Hidden;
- if (this.percentWidth == '0%' || this.percentHeight == '0%') {
- animateTo({ duration: this.glideOption.animateDuration , curve: Curve.Linear }, () => {
- this.percentWidth = '100%';
- this.percentHeight = '100%';
- this.imageWidth = '0%';
- this.imageHeight = '0%';
- this.retryWidth = '0%';
- this.retryHeight = '0%';
- })
- }
- } else if (name == 'image') {
- this.imageVisible = Visibility.Visible;
- this.percentVisible = Visibility.Hidden;
- this.retryVisible = Visibility.Hidden;
- if (this.imageWidth == '0%' || this.imageHeight == '0%') {
- animateTo({ duration: this.glideOption.animateDuration, curve: Curve.Linear }, () => {
- this.imageWidth = '100%';
- this.imageHeight = '100%';
- this.percentWidth = '0%';
- this.percentHeight = '0%';
- this.retryWidth = '0%';
- this.retryHeight = '0%';
- })
- }
- } else if (name == 'retry') {
- this.retryVisible = Visibility.Visible;
- this.imageVisible = Visibility.Hidden;
- this.percentVisible = Visibility.Hidden;
- if (this.retryWidth == '0%' || this.retryHeight == '0%') {
- animateTo({ duration: this.glideOption.animateDuration, curve: Curve.Linear }, () => {
- this.imageWidth = '0%';
- this.imageHeight = '0%';
- this.percentWidth = '0%';
- this.percentHeight = '0%';
- this.retryWidth = '100%';
- this.retryHeight = '100%';
- })
- }
- }
- }
-
- aboutToDisappear() {
- }
-
- onPageShow() {
- }
-
- onPageHide() {
- }
-
- onBackPress() {
- }
-}
-
-var Glide;
-var defaultTemp = globalThis.exports.default
-if (defaultTemp != undefined) {
- Glide = defaultTemp.data.glide;
-}
diff --git a/entry/src/main/ets/MainAbility/glide/RequestOption.ets b/entry/src/main/ets/MainAbility/glide/RequestOption.ets
deleted file mode 100644
index ec8c455..0000000
--- a/entry/src/main/ets/MainAbility/glide/RequestOption.ets
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (C) 2021 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {DiskStrategy} from "../cache/diskstrategy/DiskStrategy"
-import {AsyncCallback} from "../glide/interface/asynccallback.ets"
-import {AsyncSuccess} from "../glide/interface/AsyncSuccess.ets"
-import {AllCacheInfo, IAllCacheInfoCallback} from "../glide/interface/iallcacheinfocallback.ets"
-import {AUTOMATIC} from "../cache/diskstrategy/enum/AUTOMATIC"
-import {BaseTransform} from "../glide/transform/BaseTransform.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
-import {GlideData} from "../glide/GlideData.ets"
-import fileio from '@ohos.fileio';
-import image from '@ohos.multimedia.image';
-import {CenterCrop} from '../glide/transform/pixelmap/CenterCrop.ets'
-import {CenterInside} from '../glide/transform/pixelmap/CenterInside.ets'
-import {FitCenter} from '../glide/transform/pixelmap/FitCenter.ets'
-
-export class RequestOption {
- loadSrc: string | PixelMap | Resource;
- strategy: DiskStrategy = new AUTOMATIC();
- dontAnimateFlag = false;
- placeholderSrc: PixelMap | Resource;
- placeholderFunc: AsyncSuccess;
- errorholderSrc: PixelMap | Resource;
- errorholderFunc: AsyncSuccess;
- errorholderData: GlideData;
- thumbSizeMultiplier: number;
-
- // 如果存在缩略图,则主图延时3000ms加载
- thumbDelayTime: number = 3000
- thumbholderFunc: AsyncSuccess;
- requestListeners: Array>;
-
- // 进度条
- progressFunc: AsyncSuccess;
-
- // 重试图层
- retryFunc: AsyncSuccess
-
- // 图层切换时长
- animateDuraction: number = 500;
- size: {
- width: number,
- height: number
- } = { width: -1, height: -1 };
-
- // 网络下载数据回调
- allCacheInfoCallback: IAllCacheInfoCallback;
- onlyRetrieveFromCache: boolean = false;
- isCacheable: boolean = true;
-
- // 变换相关
- transformtions: Array> = new Array();
- generateCacheKey: string = "";
- generateResourceKey: string = "";
- generateDataKey: string = "";
- private filesPath: string = ""; // data/data/包名/files目录
- private cachesPath: string = ""; // 网络下载默认存储在data/data/包名/cache/GlideNetworkFolder/目标md5.img下面
-
- // 下载原始文件地址
- downloadFilePath: string = "";
-
- // 网络文件下载统一存放
- networkCacheFolder: string = "GlideNetworkFolder"
-
-
- // 主线图片 状态变化 是否加载完成
- // 主图未加载成功 显示占位图 主图加载成功不展示占位图
- loadMainReady = false;
-
- // 失败占位图展示状态 当true 表示主图加载失败需要展示失败占位图
- loadErrorReady = false
-
- // 缩略图展示
- loadThumbnailReady = false;
- _svgAndGifFolder: string = "svgAndGifFolder"; // svg和gif的文件路径地址
- _svgAndGifCommitFile: string = "svgAndGifCommitFile"; // svg和gif提交记录
-
- constructor() {
- // 初始化全局监听
- this.requestListeners = new Array();
- }
-
- /**
- * set image Component size
- */
- setImageViewSize(imageSize: {
- width: number,
- height: number
- }) {
- this.size.width = imageSize.width;
- this.size.height = imageSize.height;
- return this;
- }
-
- getFilesPath() {
- return this.filesPath;
- }
-
- setFilesPath(path: string) {
- this.filesPath = path;
- }
-
- getCachesPath() {
- return this.cachesPath;
- }
-
- setCachesPath(path: string) {
- this.cachesPath = path;
- }
-
- load(src: string | PixelMap | Resource) {
- this.loadSrc = src;
- return this;
- }
-
- diskCacheStrategy(strategy: DiskStrategy) {
- this.strategy = strategy;
- return this;
- }
-
- dontAnimate() {
- this.dontAnimateFlag = true;
- return this;
- }
-
- // 仅支持 本地图片
- placeholder(src: PixelMap | Resource, func?: AsyncSuccess) {
- this.placeholderSrc = src;
- this.placeholderFunc = func;
- return this;
- }
-
- errorholder(src: PixelMap | Resource, func?: AsyncSuccess) {
- this.errorholderSrc = src;
- this.errorholderFunc = func;
- return this;
- }
-
- thumbnail(sizeMultiplier: number, func?: AsyncSuccess) {
- this.thumbSizeMultiplier = sizeMultiplier;
- this.thumbholderFunc = func;
- return this;
- }
-
- addProgressListener(func?: AsyncSuccess) {
- this.progressFunc = func;
- return this;
- }
-
- addRetryListener(func?: AsyncSuccess) {
- this.retryFunc = func;
- return this;
- }
-
- addListener(func: AsyncCallback) {
- this.requestListeners.push(func);
- return this;
- }
-
- addAllCacheInfoCallback(func: IAllCacheInfoCallback) {
- this.allCacheInfoCallback = func;
- return this;
- }
-
- skipMemoryCache(skip: boolean) {
- this.isCacheable = !skip;
- return this;
- }
-
- retrieveDataFromCache(flag: boolean) {
- this.onlyRetrieveFromCache = flag;
- }
-
- rotateImage(degreesToRotate: number) {
- let rotateImage = new RotateImageTransformation(degreesToRotate);
- this.transformtions.push(rotateImage);
- return this;
- }
-
- centerCrop() {
- this.transformtions.push(new CenterCrop());
- return this;
- }
- centerInside() {
- this.transformtions.push(new CenterInside());
- return this;
- }
- fitCenter() {
- this.transformtions.push(new FitCenter());
- return this;
- }
-
- transform(transform: BaseTransform) {
- this.transformtions.push(transform);
- return this;
- }
-
- transforms(transforms: BaseTransform[]) {
- this.transformtions = transforms;
- return this;
- }
-
- // 占位图解析成功
- placeholderOnComplete(glidedata: GlideData) {
- console.log("placeholderOnComplete has called!");
- console.log("Main Image is Ready:" + this.loadMainReady);
- if (!this.loadMainReady && !this.loadErrorReady && !this.loadThumbnailReady) {
- // 主图未加载成功,并且未加载失败 显示占位图 主图加载成功或者加载失败后=>不展示占位图
- this.placeholderFunc(glidedata)
- }
- }
-
- // 占位图解析失败
- placeholderOnError(error) {
- console.log("占位图解析失败 error =" + error)
- }
-
- // 缩略图解析成功
- thumbholderOnComplete(glidedata: GlideData) {
- if (!this.loadMainReady && !this.loadErrorReady) {
- //主图未加载成功,并且未加载失败 显示占位图 主图加载成功或者加载失败后=>不展示占位图
- this.thumbholderFunc(glidedata)
- }
- }
-
- // 缩略图解析失败
- thumbholderOnError(error) {
- console.log("缩略图解析失败 error =" + error)
- }
-
- // 加载失败 占位图解析成功
- errorholderOnComplete(glidedata: GlideData) {
- // 如果有错误占位图 先解析并保存在RequestOption中 等到加载失败时候进行调用
- this.errorholderData = glidedata;
- if (this.loadErrorReady) {
- this.errorholderFunc(glidedata)
- }
- }
-
- //加载失败 占位图解析失败
- errorholderOnError(error) {
- console.log("失败占位图解析失败 error =" + error)
- }
-
- loadComplete(glidedata: GlideData) {
- this.loadMainReady = true;
- // 三级缓存数据加载成功
- for (let requestListener of this.requestListeners) {
- var ret = requestListener("", glidedata);
- if (ret) {
- break;
- }
- }
- // 加载成功之后
- Glide.removeRunning(this);
- }
-
- loadError(err) {
- console.log("loadError:"+err);
- //失败占位图展示规则
- this.loadErrorReady = true;
- if (this.retryFunc) {
- // 重试图层优先于加载失败展示
- this.retryFunc(err)
- } else {
- if (this.errorholderData != null) {
- this.errorholderFunc(this.errorholderData)
- }
- }
-
- // 加载失败之后
- Glide.removeRunning(this);
- }
-}
-
-
-var Glide;
-var defaultTemp = globalThis.exports.default
-if (defaultTemp != undefined) {
- Glide = defaultTemp.data.glide;
-}
diff --git a/entry/src/main/ets/MainAbility/glide/entry/PixelEntry.ets b/entry/src/main/ets/MainAbility/glide/entry/PixelEntry.ets
deleted file mode 100644
index 72dd1c9..0000000
--- a/entry/src/main/ets/MainAbility/glide/entry/PixelEntry.ets
+++ /dev/null
@@ -1,12 +0,0 @@
-export class PixelEntry {
- a: number;
- b: number;
- r: number;
- g: number;
- f: number;
- pixel: number;
-
- public toString(): string {
- return "PixelEntry a:" + this.a + ";b:" + this.b + ";r:" + this.r + ";g:" + this.g + ";f:" + this.f;
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/networkmanage/DownloadClient.ets b/entry/src/main/ets/MainAbility/glide/networkmanage/DownloadClient.ets
deleted file mode 100644
index 4bccd1f..0000000
--- a/entry/src/main/ets/MainAbility/glide/networkmanage/DownloadClient.ets
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2021 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {IDataFetch} from "../networkmanage/IDataFetch.ets"
-import {RequestOption} from "../RequestOption.ets"
-import {Md5} from "../../cache/Md5.ets"
-import{FileUtils} from "../../cache/FileUtils.ets"
-
-import httpRequest from '@ohos.request';
-
-export class DownloadClient implements IDataFetch {
- loadData(request: RequestOption, onCompleteFunction, onErrorFunction) {
-
- let requestUrl = request.loadSrc as string;
- if (requestUrl.startsWith("http") || requestUrl.startsWith("https")) {
- let filename = Md5.hashStr(request.generateDataKey);
- let allpath = request.networkCacheFolder + "/" + filename + ".img";
- var downloadConfig = {
- url: (request.loadSrc as string),
- filePath: allpath
- };
- httpRequest.download(downloadConfig)
- .then((downloadTask) => {
- downloadTask.query((err, data) => {
- if (err) {
- onErrorFunction(err)
- return;
- }
- downloadTask.on('progress', (uploadedSize, totalSize)=>{
- let percent = Math.round(((uploadedSize*1.0)/(totalSize*1.0))*100)+"%"
- if(request.progressFunc) {
- request.progressFunc(percent);
- }
- });
- downloadTask.on('complete', () => {
- let downloadPath = request.getCachesPath() + "/" + allpath;
- request.downloadFilePath = downloadPath;
- let arraybuffer = FileUtils.getInstance()
- .readFilePic(downloadPath)
- onCompleteFunction(arraybuffer);
- FileUtils.getInstance()
- .deleteFile(downloadPath);
- })
- downloadTask.on('fail', (err) => {
- onErrorFunction("DownloadClient Download task fail. err =" + err)
- })
- })
- })
- .catch((err) => {
- onErrorFunction(err)
- })
- } else {
- onErrorFunction("DownloadClient 暂不支持除http之外的uri加载")
- }
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/networkmanage/SimulatedDownloadClient.ets b/entry/src/main/ets/MainAbility/glide/networkmanage/SimulatedDownloadClient.ets
deleted file mode 100644
index c652cdf..0000000
--- a/entry/src/main/ets/MainAbility/glide/networkmanage/SimulatedDownloadClient.ets
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2021 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {IDataFetch} from "../networkmanage/IDataFetch.ets"
-import {RequestOption} from "../RequestOption.ets"
-import {Md5} from "../../cache/Md5.ets"
-import {FileUtils} from "../../cache/FileUtils.ets"
-import {ParseResClient} from "../../glide/resourcemanage/ParseResClient"
-import resourceManager from '@ohos.resourceManager';
-
-export class SimulatedDownloadClient implements IDataFetch {
- loadData(request: RequestOption, onCompleteFunction, onErrorFunction) {
- console.log("SimulatedDownloadClient loadData");
- let requestUrl = request.loadSrc as string;
- let resource;
- //jpg
- if('https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB' == requestUrl){
- console.log("SimulatedDownloadClient jpg");
- resource = $r('app.media.jpgNet')
- }
- //png
- else if('https://img-blog.csdnimg.cn/20191215043500229.png' == requestUrl){
- console.log("SimulatedDownloadClient png");
- resource = $r('app.media.pngNet')
- }
- //bmp
- else if('https://img-blog.csdn.net/20140514114029140' == requestUrl){
- console.log("SimulatedDownloadClient bmp");
- resource = $r('app.media.bmpNet')
- }
- //webp
- else if('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp' == requestUrl){
- console.log("SimulatedDownloadClient webp");
- resource = $r('app.media.webpNet')
- }
- //svg
- else if('http://design-svc.fat.lunz.cn/StaticFiles/BP9999999772/BV9999999422/SA9999998420/30df266a-485e-411e-b178-b9fb1d8e0748.svg' == requestUrl){
- console.log("SimulatedDownloadClient svg");
- resource = $r('app.media.svgNet')
- }
- //gif
- else if('https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700'== requestUrl){
- console.log("SimulatedDownloadClient gif");
- resource = $r('app.media.gifNet')
- }else{
- new Error("SimulatedDownloadClient not support otherUrl")
- }
-
- let resClient = new ParseResClient();
- resClient.loadResource(resource,(arraybuffer)=>{
- console.log("SimulatedDownloadClient loadResource callback! ok")
- if(request.progressFunc) {
- request.progressFunc("100%")
- }
- onCompleteFunction(arraybuffer)
- },onErrorFunction)
-
-
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/pngj/PngReader.ets b/entry/src/main/ets/MainAbility/glide/pngj/PngReader.ets
deleted file mode 100644
index 4ffb053..0000000
--- a/entry/src/main/ets/MainAbility/glide/pngj/PngReader.ets
+++ /dev/null
@@ -1,18 +0,0 @@
-import {Closeable} from "/glide/pngj/io/Closeable.ets"
-import {ImageInfo} from "/glide/pngj/entry/ImageInfo.ets"
-
-export class PngReader implements Closeable {
- private static LOG_TAG: string= "PngReader";
- private static MAX_TOTAL_BYTES_READ_DEFAULT: number= 901001001;
- private static MAX_BYTES_METADATA_DEFAULT: number= 5024024;
- private static MAX_CHUNK_SIZE_SKIP: number= 2024024;
- public imgInfo: ImageInfo;
- public interlaced: boolean;
-
- constructor(shouldCloseStream: boolean) {
-
- }
-
- close(): void {
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/pngj/Pngj.ets b/entry/src/main/ets/MainAbility/glide/pngj/Pngj.ets
deleted file mode 100644
index 47e6203..0000000
--- a/entry/src/main/ets/MainAbility/glide/pngj/Pngj.ets
+++ /dev/null
@@ -1,47 +0,0 @@
-import {UPNG} from '../pngj/UPNG.js';
-import image from '@ohos.multimedia.image';
-import resourceManager from '@ohos.resourceManager';
-import featureability from '@ohos.ability.featureAbility'
-
-export class Pngj {
- readPngImageInfo(arraybuffer: ArrayBuffer, callback) {
- let imageSource = image.createImageSource(arraybuffer);
- imageSource.getImageInfo((err, value) => {
- if (err) {
- return;
- }
- callback(value);
- });
- }
-
- /**
- *
- * @param pngBuffer ArrayBuffer containing the PNG file
- * @param callback
- * returns an image object with following properties:
- * width: the width of the image
- * height: the height of the image
- * depth: number of bits per channel
- * ctype: color type of the file (Truecolor, Grayscale, Palette ...)
- * frames: additional info about frames (frame delays etc.)
- * tabs: additional chunks of the PNG file
- * data: pixel data of the image
- */
- readPngImage(pngBuffer: ArrayBuffer, callback) {
- var png = UPNG.decode(pngBuffer);
- callback(png)
- }
-
- writePngWithString(addInfo:string, pngBuffer: ArrayBuffer,callback) {
- var pngDecode = UPNG.decode(pngBuffer);
- var newPng = UPNG.encodeWithString(addInfo, UPNG.toRGBA8(pngDecode), pngDecode.width, pngDecode.height, 0)
- callback(newPng);
- }
-
- writePng(pngBuffer: ArrayBuffer,callback) {
- var pngDecode = UPNG.decode(pngBuffer);
- var newPng = UPNG.encode(UPNG.toRGBA8(pngDecode), pngDecode.width, pngDecode.height, 0)
- callback(newPng);
- }
-
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/pngj/PngjException.ets b/entry/src/main/ets/MainAbility/glide/pngj/PngjException.ets
deleted file mode 100644
index 36b37a1..0000000
--- a/entry/src/main/ets/MainAbility/glide/pngj/PngjException.ets
+++ /dev/null
@@ -1,5 +0,0 @@
-export class PngjException extends Error {
- constructor(s: string) {
- super(s)
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/pngj/interface/IBytesConsumer.ets b/entry/src/main/ets/MainAbility/glide/pngj/interface/IBytesConsumer.ets
deleted file mode 100644
index b9cb4ef..0000000
--- a/entry/src/main/ets/MainAbility/glide/pngj/interface/IBytesConsumer.ets
+++ /dev/null
@@ -1,5 +0,0 @@
-export interface IBytesConsumer {
- isDone(): boolean;
-
- consume(buf: ArrayBuffer, offset: number, len: number): number;
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/pngj/io/Closeable.ets b/entry/src/main/ets/MainAbility/glide/pngj/io/Closeable.ets
deleted file mode 100644
index 2accfe7..0000000
--- a/entry/src/main/ets/MainAbility/glide/pngj/io/Closeable.ets
+++ /dev/null
@@ -1,3 +0,0 @@
-export interface Closeable {
- close(): void;
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/pngj/misc/Sandbox.ets b/entry/src/main/ets/MainAbility/glide/pngj/misc/Sandbox.ets
deleted file mode 100644
index a5c2b7c..0000000
--- a/entry/src/main/ets/MainAbility/glide/pngj/misc/Sandbox.ets
+++ /dev/null
@@ -1,7 +0,0 @@
-export class Sandbox {
-
-
- public static convert(origFileName: string, destFileName: string) {
-
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/basicTestFeatureAbilityPage.ets b/entry/src/main/ets/MainAbility/pages/basicTestFeatureAbilityPage.ets
index ab2ba4f..3caf286 100644
--- a/entry/src/main/ets/MainAbility/pages/basicTestFeatureAbilityPage.ets
+++ b/entry/src/main/ets/MainAbility/pages/basicTestFeatureAbilityPage.ets
@@ -33,11 +33,11 @@ struct BasicTestFeatureAbilityPage {
featureAbility.getContext()
.getFilesDir()
.then((data) => {
- console.log("Glide filesPath = " + data)
+ console.log("ImageKnife filesPath = " + data)
this.filePath = data
})
.catch((error) => {
- console.error('Glide Failed to obtain the filesPath directory. Cause:' + error.message);
+ console.error('ImageKnife Failed to obtain the filesPath directory. Cause:' + error.message);
})
})
Button("featureAbility.getContext().getCacheDir()")
@@ -45,11 +45,11 @@ struct BasicTestFeatureAbilityPage {
.onClick(()=>{
featureAbility.getContext().getCacheDir()
.then((data) => {
- console.log("Glide cachesPath = " + data)
+ console.log("ImageKnife cachesPath = " + data)
this.filePath = data
})
.catch((error) => {
- console.error('Glide Failed to obtain the cachesPath directory. Cause:' + error.message);
+ console.error('ImageKnife Failed to obtain the cachesPath directory. Cause:' + error.message);
})
})
}
diff --git a/entry/src/main/ets/MainAbility/pages/basicTestFileIOPage.ets b/entry/src/main/ets/MainAbility/pages/basicTestFileIOPage.ets
index 3cf1995..3e9c7e4 100644
--- a/entry/src/main/ets/MainAbility/pages/basicTestFileIOPage.ets
+++ b/entry/src/main/ets/MainAbility/pages/basicTestFileIOPage.ets
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
-import {FileUtils} from '../cache/FileUtils.ets'
+import { FileUtils } from '@ohos/imageknife'
import resourceManager from '@ohos.resourceManager';
@Entry
@@ -22,6 +22,11 @@ struct BasicTestFileIOPage {
@Watch('watchPathChange') @State filePath: string= '查看featureAbility路径';
appFilePath = '';
appCachePath = '';
+ @State imageFile: string = ''
+ @State imageRes: Resource = $r('app.media.pngSample')
+ @State imagePixelMap: PixelMap = undefined
+ @State normalPixelMap: boolean = false;
+ @State normalResource: boolean = false;
watchPathChange() {
console.log('watchPathChange');
@@ -34,63 +39,91 @@ struct BasicTestFileIOPage {
Button('featureAbility.getContext().getFilesDir()')
.margin({ top: 10 })
.onClick(() => {
- featureAbility.getContext()
- .getFilesDir()
- .then((data) => {
- console.log('Glide filesPath = ' + data)
- this.filePath = data
- this.appFilePath = data;
+ featureAbility.getContext()
+ .getFilesDir()
+ .then((data) => {
+ console.log('ImageKnife filesPath = ' + data)
+ this.filePath = data
+ this.appFilePath = data;
+ })
+ .catch((error) => {
+ console.error('ImageKnife Failed to obtain the filesPath directory. Cause:' + error.message);
+ })
})
- .catch((error) => {
- console.error('Glide Failed to obtain the filesPath directory. Cause:' + error.message);
- })
- })
Button('featureAbility.getContext().getCacheDir()')
.margin({ top: 10 })
.onClick(() => {
- featureAbility.getContext()
- .getCacheDir()
- .then((data) => {
- console.log('Glide cachesPath = ' + data)
- this.filePath = data
- this.appCachePath = data
+ featureAbility.getContext()
+ .getCacheDir()
+ .then((data) => {
+ console.log('ImageKnife cachesPath = ' + data)
+ this.filePath = data
+ this.appCachePath = data
+ })
+ .catch((error) => {
+ console.error('ImageKnife Failed to obtain the cachesPath directory. Cause:' + error.message);
+ })
})
- .catch((error) => {
- console.error('Glide Failed to obtain the cachesPath directory. Cause:' + error.message);
- })
- })
Button('files目录创建Folder1和Folder2 验证statSync mkdirSync')
.margin({ top: 10 })
.onClick(() => {
- FileUtils.getInstance()
- .createFolder(this.appFilePath + '/Folder1');
- FileUtils.getInstance()
- .createFolder(this.appFilePath + '/Folder2');
- })
+ FileUtils.getInstance()
+ .createFolder(this.appFilePath + '/Folder1');
+ FileUtils.getInstance()
+ .createFolder(this.appFilePath + '/Folder2');
+ })
Button('将media资源存入Folder1 验证writeSync mkdirSync createStreamSync')
.margin({ top: 10 })
.onClick(() => {
- resourceManager.getResourceManager()
- .then(result => {
- result.getMedia($r('app.media.jpgSample').id, )
- .then(data => {
- console.log('basicTestFileIOPage - 本地加载资源 解析后数据data = ' + data)
- let arrayBuffer = this.typedArrayToBuffer(data);
- FileUtils.getInstance().writeFile(this.appFilePath + '/Folder1/jpgSample.jpg',arrayBuffer)
- })
- .catch(err => {
- console.log('basicTestFileIOPage - 本地加载资源err' + JSON.stringify(err));
- })
+ resourceManager.getResourceManager()
+ .then(result => {
+ result.getMedia($r('app.media.gifSample').id,)
+ .then(data => {
+ console.log('basicTestFileIOPage - 本地加载资源 解析后数据data = ' + data)
+ let arrayBuffer = this.typedArrayToBuffer(data);
+ FileUtils.getInstance().writeFile(this.appFilePath + '/Folder1/jpgSample.gif', arrayBuffer)
+ this.imageFile = 'file://' + this.appFilePath + '/Folder1/jpgSample.gif'
+ })
+ .catch(err => {
+ console.log('basicTestFileIOPage - 本地加载资源err' + JSON.stringify(err));
+ })
+ })
})
- })
Button('copy:Folder1至Folder2, 验证copyFileSync')
.margin({ top: 10 })
.onClick(() => {
- let filePath1 = this.appFilePath + '/Folder1/jpgSample.jpg';
- let filePath2 = this.appFilePath + '/Folder2/jpgSample.jpg';
- FileUtils.getInstance().createFolder(this.appFilePath + '/Folder2')
- FileUtils.getInstance().copyFile(filePath1, filePath2);
- })
+ let filePath1 = this.appFilePath + '/Folder1/jpgSample.gif';
+ let filePath2 = this.appFilePath + '/Folder2/jpgSample.gif';
+ FileUtils.getInstance().createFolder(this.appFilePath + '/Folder2')
+ FileUtils.getInstance().copyFile(filePath1, filePath2);
+ this.imageFile = 'file://' + this.appFilePath + '/Folder2/jpgSample.gif'
+ })
+ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
+ Button('显示空PixelMap')
+ .margin({ left: 10 })
+ .onClick(() => {
+ this.normalPixelMap=true;
+ this.normalResource = false;
+ })
+ Button('显示RES')
+ .margin({ left: 10 })
+ .onClick(() => {
+ this.normalPixelMap=false;
+ this.normalResource = true;
+ })
+ Button('显示String')
+ .margin({ left: 10 })
+ .onClick(() => {
+ this.normalPixelMap=false;
+ this.normalResource = false;
+ })
+ }
+
+
+ Image(this.normalPixelMap?this.imagePixelMap:(this.normalResource? this.imageRes:this.imageFile))
+ .width(200)
+ .height(200)
+ .backgroundColor(Color.Pink)
}
}
.width('100%')
diff --git a/entry/src/main/ets/MainAbility/pages/basicTestMediaImage.ets b/entry/src/main/ets/MainAbility/pages/basicTestMediaImage.ets
index d399cee..06128a6 100644
--- a/entry/src/main/ets/MainAbility/pages/basicTestMediaImage.ets
+++ b/entry/src/main/ets/MainAbility/pages/basicTestMediaImage.ets
@@ -13,12 +13,12 @@
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
-import {FileUtils} from '../cache/FileUtils.ets'
-import {FileTypeUtil} from '../glide/utils/FileTypeUtil.ets'
+import {FileUtils} from '@ohos/imageknife'
+import {FileTypeUtil} from '@ohos/imageknife'
import resourceManager from '@ohos.resourceManager';
-import {Base64} from '../cache/Base64.ets'
-import {PixelMapPack} from '../glide/PixelMapPack.ets'
-import {ParseImageUtil} from '../glide/utils/ParseImageUtil.ets'
+import {Base64} from '@ohos/imageknife'
+import {PixelMapPack} from '@ohos/imageknife'
+import {ParseImageUtil} from '@ohos/imageknife'
@Entry
@Component
@@ -92,7 +92,7 @@ struct BasicTestMediaImage {
.onClick(()=>{
resourceManager.getResourceManager()
.then(result => {
- result.getMedia($r('app.media.webpSample').id)
+ result.getMedia($r('app.media.jpgSample').id)
.then(data => {
let arrayBuffer = this.typedArrayToBuffer(data);
let parseImageUtil = new ParseImageUtil();
diff --git a/entry/src/main/ets/MainAbility/pages/basicTestResourceManagerPage.ets b/entry/src/main/ets/MainAbility/pages/basicTestResourceManagerPage.ets
index d11e1e5..3670561 100644
--- a/entry/src/main/ets/MainAbility/pages/basicTestResourceManagerPage.ets
+++ b/entry/src/main/ets/MainAbility/pages/basicTestResourceManagerPage.ets
@@ -13,10 +13,10 @@
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
-import {FileUtils} from '../cache/FileUtils.ets'
-import {FileTypeUtil} from '../glide/utils/FileTypeUtil.ets'
+import {FileUtils} from '@ohos/imageknife'
+import {FileTypeUtil} from '@ohos/imageknife'
import resourceManager from '@ohos.resourceManager';
-import {Base64} from '../cache/Base64.ets'
+import {Base64} from '@ohos/imageknife'
@Entry
@Component
diff --git a/entry/src/main/ets/MainAbility/pages/CompressPage.ets b/entry/src/main/ets/MainAbility/pages/compressPage.ets
similarity index 81%
rename from entry/src/main/ets/MainAbility/pages/CompressPage.ets
rename to entry/src/main/ets/MainAbility/pages/compressPage.ets
index fda4304..9f32a0c 100644
--- a/entry/src/main/ets/MainAbility/pages/CompressPage.ets
+++ b/entry/src/main/ets/MainAbility/pages/compressPage.ets
@@ -1,7 +1,21 @@
-import {Glide} from '../glide/Glide.ets'
-import {PixelMapPack} from '../glide/PixelMapPack.ets'
-import {OnRenameListener} from '../glide/compress/listener/OnRenameListener.ets'
-import {OnCompressListener} from '../glide/compress/listener/OnCompressListener.ets'
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {ImageKnife} from '@ohos/imageknife'
+import {PixelMapPack} from '@ohos/imageknife'
+import {OnRenameListener} from '@ohos/imageknife'
+import {OnCompressListener} from '@ohos/imageknife'
@Entry
@Component
@@ -83,7 +97,7 @@ struct CompressPage {
data.push($r('app.media.jpgSample'))
console.info("asasd start compress")
- Glide.with()
+ ImageKnife.with()
.compressBuilder()
.load(data)
.ignoreBy(100)
@@ -123,7 +137,7 @@ struct CompressPage {
}
}
console.info("asasd start compress")
- Glide.with()
+ ImageKnife.with()
.compressBuilder()
.load(data)
.ignoreBy(100)
diff --git a/entry/src/main/ets/MainAbility/pages/CropImagePage.ets b/entry/src/main/ets/MainAbility/pages/cropImagePage.ets
similarity index 92%
rename from entry/src/main/ets/MainAbility/pages/CropImagePage.ets
rename to entry/src/main/ets/MainAbility/pages/cropImagePage.ets
index ae83e2d..bb0a02f 100644
--- a/entry/src/main/ets/MainAbility/pages/CropImagePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/cropImagePage.ets
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-import {CropImage} from '../glide/crop/CropImage.ets'
-import {CropOptions} from '../glide/crop/CropOptions.ets'
-import {Crop} from '../glide/crop/Crop.ets'
-import {RecourseProvider} from '../glide/compress/provider/RecourseProvider.ets'
-import {PixelMapPack} from "../glide/PixelMapPack.ets";
+import {CropImage} from '@ohos/imageknife'
+import {CropOptions} from '@ohos/imageknife'
+import {Crop} from '@ohos/imageknife'
+import {RecourseProvider} from '@ohos/imageknife'
+import {PixelMapPack} from '@ohos/imageknife'
@Component
diff --git a/entry/src/main/ets/MainAbility/pages/frescoImageTestCasePage.ets b/entry/src/main/ets/MainAbility/pages/frescoImageTestCasePage.ets
index 3375324..ed85957 100644
--- a/entry/src/main/ets/MainAbility/pages/frescoImageTestCasePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/frescoImageTestCasePage.ets
@@ -12,10 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from "../glide/GlideImage.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
-import {RoundedCornersTransformation} from "../glide/transform/RoundedCornersTransformation.ets"
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
+import {RoundedCornersTransformation} from '@ohos/imageknife'
@Entry
@Component
@@ -24,7 +24,7 @@ struct FrescoImageTestCasePage {
@State progresshint:string = "输出加载百分比回调信息"
- @State glideOption1: GlideOption =
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ericA1Mv66TwicuYOtbDMBcUhv1aa9RJBeAn9uURfcZD0AUGrJebAn1g2AjN0vb2E1XTET7fTuLBNmA/132",
size: { width: 300, height: 300 },
@@ -32,7 +32,7 @@ struct FrescoImageTestCasePage {
errorholderSrc: $r('app.media.icon_failed'),
displayProgress: true
};
- @State glideOption2: GlideOption =
+ @State imageKnifeOption2: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/0ef60041445edcfd6b38d20e19024b2cd9281dcc3525a4-Vy8fYO_fw658/format/webp",
size: { width: 300, height: 300 },
@@ -40,7 +40,7 @@ struct FrescoImageTestCasePage {
errorholderSrc: $r('app.media.icon_failed'),
displayProgress: true
};
- @State glideOption3: GlideOption =
+ @State imageKnifeOption3: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp",
size: { width: 300, height: 300 },
@@ -48,7 +48,7 @@ struct FrescoImageTestCasePage {
errorholderSrc: $r('app.media.icon_failed'),
displayProgress: true
};
- @State glideOption4: GlideOption =
+ @State imageKnifeOption4: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB",
size: { width: 300, height: 300 },
@@ -65,10 +65,10 @@ struct FrescoImageTestCasePage {
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
-// GlideImage({ glideOption: $glideOption1 })
-// GlideImage({ glideOption: $glideOption2 })
-// GlideImage({ glideOption: $glideOption3 })
- GlideImage({ glideOption: $glideOption4 })
+// ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
+// ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption2 })
+// ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption3 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption4 })
Scroll() {
Text(this.progresshint).fontSize(15)
}.width(300).height(200)
diff --git a/entry/src/main/ets/MainAbility/pages/frescoRetryTestCasePage.ets b/entry/src/main/ets/MainAbility/pages/frescoRetryTestCasePage.ets
index 6291cfa..a251039 100644
--- a/entry/src/main/ets/MainAbility/pages/frescoRetryTestCasePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/frescoRetryTestCasePage.ets
@@ -12,15 +12,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from "../glide/GlideImage.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
-import {RoundedCornersTransformation} from "../glide/transform/RoundedCornersTransformation.ets"
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
+import {RoundedCornersTransformation} from '@ohos/imageknife'
@Entry
@Component
struct FrescoImageTestCasePage {
- @State glideOption1: GlideOption =
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ericA1Mv66TwicuYOtbDMBcUhv1aa9RJBeAn9uURfcZD0AUGrJebAn1g2AjN0vb2E1XTET7fTuLBNmA/132",
size: { width: 300, height: 300 },
@@ -30,7 +30,7 @@ struct FrescoImageTestCasePage {
animateDuration: 300,
retryLoad:true
};
- @State glideOption2: GlideOption =
+ @State imageKnifeOption2: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/0ef60041445edcfd6b38d20e19024b2cd9281dcc3525a4-Vy8fYO_fw658/format/webp",
size: { width: 300, height: 300 },
@@ -40,7 +40,7 @@ struct FrescoImageTestCasePage {
animateDuration: 300,
retryLoad:true
};
- @State glideOption3: GlideOption =
+ @State imageKnifeOption3: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp",
size: { width: 300, height: 300 },
@@ -50,7 +50,7 @@ struct FrescoImageTestCasePage {
animateDuration: 300,
retryLoad:true
};
- @State glideOption4: GlideOption =
+ @State imageKnifeOption4: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/testRetryxxxx",
size: { width: 300, height: 300 },
@@ -64,10 +64,10 @@ struct FrescoImageTestCasePage {
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
-// GlideImage({ glideOption: $glideOption1 })
-// GlideImage({ glideOption: $glideOption2 })
-// GlideImage({ glideOption: $glideOption3 })
- GlideImage({ glideOption: $glideOption4 })
+// ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
+// ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption2 })
+// ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption3 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption4 })
}
}
.width('100%')
diff --git a/entry/src/main/ets/MainAbility/pages/index.ets b/entry/src/main/ets/MainAbility/pages/index.ets
index 76cf4d2..e966fb1 100644
--- a/entry/src/main/ets/MainAbility/pages/index.ets
+++ b/entry/src/main/ets/MainAbility/pages/index.ets
@@ -13,8 +13,8 @@
* limitations under the License.
*/
import router from '@system.router';
-import {Pngj} from '../glide/pngj/Pngj'
-import {SimulatedDownloadClient} from '../glide/networkmanage/SimulatedDownloadClient'
+import {Pngj} from '@ohos/imageknife'
+
@Entry
@Component
@@ -23,12 +23,6 @@ struct Index {
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- Button(this.hint1).fontSize(15)
- .onClick(()=>{
- let simulatedDownloadClient = new SimulatedDownloadClient();
- Glide.replaceDataFetch(simulatedDownloadClient)
- this.hint1 = '已启用网络模拟加载替换网络加载'
- })
Text("OHOS基础接口测试列表").fontSize(15)
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button("测试元能力")
@@ -64,14 +58,15 @@ struct Index {
}).margin({ top: 5, left: 3 })
Button("测试图片切换")
.onClick(() => {
- console.log("测试GlideImage所有图片切换")
- router.push({ uri: "pages/testGlideOptionChangedPage" });
+ console.log("测试ImageKnifeComponent所有图片切换")
+ router.push({ uri: "pages/testImageKnifeOptionChangedPage" });
}).margin({ top: 5, left: 3 })
Button("测试thumbnail")
.onClick(() => {
- console.log("测试GlideImage thumbnail")
- router.push({ uri: "pages/testGlideOptionChangedPage2" });
+ console.log("测试ImageKnifeComponent thumbnail")
+ router.push({ uri: "pages/testImageKnifeOptionChangedPage2" });
}).margin({ top: 5, left: 3 })
+
}.width('100%')
.height(60).backgroundColor(Color.Pink)
@@ -87,11 +82,7 @@ struct Index {
console.log("测试二级内存缓存")
router.push({ uri: "pages/storageTestDiskLruCache" });
}).margin({ top: 5, left: 3 })
- Button("测试JPEG")
- .onClick(() => {
- console.log("测试JPEG")
- router.push({ uri: "pages/JpegProgressTestCasePage" });
- }).margin({ top: 5, left: 3 })
+
}.width('100%')
.height(60).backgroundColor(Color.Pink)
@@ -130,12 +121,12 @@ struct Index {
Button("测试图片变换")
.onClick(() => {
console.log("测试图片变换")
- router.push({ uri: "pages/TransformPixelMapPage" });
+ router.push({ uri: "pages/transformPixelMapPage" });
}).margin({ top: 5, left: 3 })
Button("测试图片压缩")
.onClick(() => {
console.log("测试图片压缩")
- router.push({ uri: "pages/CompressPage" });
+ router.push({ uri: "pages/compressPage" });
}).margin({ top: 5, left: 3 })
}.width('100%')
.height(60).backgroundColor(Color.Pink)
@@ -159,14 +150,10 @@ struct Index {
}).margin({ top: 15 })
Button("测试图片的裁剪")
.onClick(() => {
- console.log("pages/CropImagePage 页面跳转")
- router.push({ uri: "pages/CropImagePage" });
- }).margin({ top: 15 })
- Button("测试网络")
- .onClick(() => {
- console.log("pages/networkTestCasePage 页面跳转")
- router.push({ uri: "pages/networkTestCasePage" });
+ console.log("pages/cropImagePage 页面跳转")
+ router.push({ uri: "pages/cropImagePage" });
}).margin({ top: 15 })
+
}
}
.width('100%')
@@ -177,12 +164,12 @@ struct Index {
}
onBackPress() {
- let cache = Glide.getMemoryCache();
+ let cache = ImageKnife.getMemoryCache();
cache.print()
}
}
-var Glide;
+var ImageKnife;
var defaultTemp = globalThis.exports.default
if (defaultTemp != undefined) {
- Glide = defaultTemp.data.glide;
+ ImageKnife = defaultTemp.data.imageKnife;
}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/jpegProgressTestCasePage.ets b/entry/src/main/ets/MainAbility/pages/jpegProgressTestCasePage.ets
deleted file mode 100644
index 59cb872..0000000
--- a/entry/src/main/ets/MainAbility/pages/jpegProgressTestCasePage.ets
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2021 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {GlideImage} from "../glide/GlideImage.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {FileUtils} from "../cache/FileUtils.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
-import {RoundedCornersTransformation} from "../glide/transform/RoundedCornersTransformation.ets"
-import resourceManager from '@ohos.resourceManager';
-import image from "@ohos.multimedia.image"
-@Entry
-@Component
-struct JpegProgressTestCasePage {
-
-
- build() {
- Scroll() {
- Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- Button('点击调用渐进式解码')
- .onClick(()=> {
- resourceManager.getResourceManager()
- .then(result => {
- result.getMedia($r('app.media.jpgSample').id)
- .then(data => {
- let arrayBuffer = FileUtils.getInstance().uint8ArrayToBuffer(data);
- let imageSourceIncrementalSApi = image.createIncrementalSource(data);
- let array = [1,2,3,4,5,6,7,8,9,10];
- imageSourceIncrementalSApi.updateData(array, false,(error,data) => {
- console.log("data is null="+(data == null || data == undefined))
- console.log("array = "+array)
- console.log("data ="+data)
-
- })
- })
- })
-
- })
- Button('点击调用渐进式解码带上length')
- .onClick(()=> {
- resourceManager.getResourceManager()
- .then(result => {
- result.getMedia($r('app.media.jpgSample').id)
- .then(data => {
- let arrayBuffer = FileUtils.getInstance().uint8ArrayToBuffer(data);
- let imageSourceIncrementalSApi = image.createIncrementalSource(data);
- let array = [1,2,3,4,5,6,7,8,9,10];
- imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data) => {
- console.log("data is null="+(data == null || data == undefined))
- console.log("array = "+array)
- console.log("data ="+data)
-
- })
- })
- })
-
- })
- }
- }
- .width('100%')
- .height('100%')
- }
-}
-
diff --git a/entry/src/main/ets/MainAbility/pages/loadNetworkTestCasePage.ets b/entry/src/main/ets/MainAbility/pages/loadNetworkTestCasePage.ets
index 684406a..db7c604 100644
--- a/entry/src/main/ets/MainAbility/pages/loadNetworkTestCasePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/loadNetworkTestCasePage.ets
@@ -12,36 +12,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from "../glide/GlideImage.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
-import {RoundedCornersTransformation} from "../glide/transform/RoundedCornersTransformation.ets"
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
+import {RoundedCornersTransformation} from '@ohos/imageknife'
@Entry
@Component
struct LoadNetworkTestCasePage {
- @State glideOption1: GlideOption =
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ericA1Mv66TwicuYOtbDMBcUhv1aa9RJBeAn9uURfcZD0AUGrJebAn1g2AjN0vb2E1XTET7fTuLBNmA/132",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
- @State glideOption2: GlideOption =
+ @State imageKnifeOption2: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/0ef60041445edcfd6b38d20e19024b2cd9281dcc3525a4-Vy8fYO_fw658/format/webp",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
- @State glideOption3: GlideOption =
+ @State imageKnifeOption3: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
- @State glideOption4: GlideOption =
+ @State imageKnifeOption4: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB",
size: { width: 300, height: 300 },
@@ -52,10 +52,10 @@ struct LoadNetworkTestCasePage {
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- GlideImage({ glideOption: $glideOption1 })
- GlideImage({ glideOption: $glideOption2 })
- GlideImage({ glideOption: $glideOption3 })
- GlideImage({ glideOption: $glideOption4 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption2 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption3 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption4 })
}
}
.width('100%')
diff --git a/entry/src/main/ets/MainAbility/pages/loadResourceTestCasePage.ets b/entry/src/main/ets/MainAbility/pages/loadResourceTestCasePage.ets
index 73def41..709b71c 100644
--- a/entry/src/main/ets/MainAbility/pages/loadResourceTestCasePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/loadResourceTestCasePage.ets
@@ -12,36 +12,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from "../glide/GlideImage.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
-import {RoundedCornersTransformation} from "../glide/transform/RoundedCornersTransformation.ets"
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
+import {RoundedCornersTransformation} from '@ohos/imageknife'
@Entry
@Component
struct LoadResourceTestCasePage {
- @State glideOption1: GlideOption =
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: $r('app.media.gifSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
- @State glideOption2: GlideOption =
+ @State imageKnifeOption2: ImageKnifeOption =
{
loadSrc: $r('app.media.bmpSample'),
size: { width: 300, height: 300 },
// placeholderSrc: $r('app.media.icon_loading'),
// errorholderSrc: $r('app.media.icon_failed'),
};
- @State glideOption3: GlideOption =
+ @State imageKnifeOption3: ImageKnifeOption =
{
loadSrc: $r('app.media.pngSample'),
size: { width: 300, height: 300 },
// placeholderSrc: $r('app.media.icon_loading'),
// errorholderSrc: $r('app.media.icon_failed'),
};
- @State glideOption4: GlideOption =
+ @State imageKnifeOption4: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
@@ -52,10 +52,10 @@ struct LoadResourceTestCasePage {
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- GlideImage({ glideOption: $glideOption1 })
-// GlideImage({ glideOption: $glideOption2 })
-// GlideImage({ glideOption: $glideOption3 })
-// GlideImage({ glideOption: $glideOption4 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
+// ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption2 })
+// ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption3 })
+// ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption4 })
}
}
.width('100%')
diff --git a/entry/src/main/ets/MainAbility/pages/networkTestCasePage.ets b/entry/src/main/ets/MainAbility/pages/networkTestCasePage.ets
deleted file mode 100644
index 0d8853c..0000000
--- a/entry/src/main/ets/MainAbility/pages/networkTestCasePage.ets
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 1521 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import router from '@system.router';
-
-import request from '@ohos.requestability';
-
-@Entry
-@Component
-struct NetworkTestCasePage {
- @State hint1: string = '基础request'
-
- build() {
- Scroll() {
- Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- Button('网络上传下载1').fontSize(15)
- .margin({ top: 30 })
- .onClick(() => {
- console.log("网络上传下载1")
-
- let DownloadConfig = {
- url: 'https://mirror.bjtu.edu.cn/kernel/linux/libs/libc5/libc5.cvs.tar.gz', // Resource address.
- header: {}, // Adds an HTTP or HTTPS header to be included with the upload request.
- enableMetered: true,
- enableRoaming: true, // Allows download in a roaming network.
- description: 'a', // Sets the description of a download session.
- networkType: 1, // Sets the network type allowed for download.
- filePath: '/data/abc1.txt', // Sets the path for downloads.
- title: 'a', // Sets a download session title.
- }
-
- let downloadTask;
-
- // 使用callback形式回调返回DownloadTask实例。
- console.log("------------------start Download_Test_0100-------------------");
- try {
- console.log("Show me the log");
- request.download(DownloadConfig, (err, data) => {
- console.log("Download_Test_0100: register download issue successful, result = " + data);
- });
- } catch (error) {
- console.log("logMessage Download_Test_0100: error = " + error);
- }
- console.log("------------------end Download_Test_0100-------------------");
- })
-
- Button('网络上传下载2').fontSize(15)
- .margin({ top: 30 })
- .onClick(() => {
- console.log("网络上传下载2")
- let downloadConfig = {
- url: 'https://img-blog.csdn.net/20140514114029140',
- header: {},
- enableMetered: true,
- enableRoaming: true,
- description: 'download libc from mirror site',
- networkType: 1,
- filePath: '/data/bmpSample.bmp',
- title: 'download libc',
- }
- let downloadTask;
- // 使用callback形式回调返回DownloadTask实例。
- console.log("------------------start Download_Test_0102-------------------");
- try {
- console.log("Show me the log");
- request.download(downloadConfig, (err, data) => {
- console.log("Download_Test_0102: register download issue successful, result = " + data);
- data.on('complete',(err1,data1) =>{
- console.log("Download_Test_0700: , on complete result = "+data1);
- })
- data.on('eventType',(err1,data1,data2) =>{
- console.log("Download_Test_0200: , on progress result data1 = "+data1);
- console.log("Download_Test_0200: , on progress result data2 = "+data2);
- })
- });
- } catch (error) {
- console.log("logMessage Download_Test_0102: error = " + error);
- }
- console.log("------------------end Download_Test_0102-------------------");
- })
-
-
-
- }
- }
- .width('100%')
- .height('100%')
- }
-
- aboutToAppear() {
- }
-
- onBackPress() {
- let cache = Glide.getMemoryCache();
- cache.print()
- }
-}
-
-var Glide;
-var defaultTemp = globalThis.exports.default
-if (defaultTemp != undefined) {
- Glide = defaultTemp.data.glide;
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/pngjTestCasePage.ets b/entry/src/main/ets/MainAbility/pages/pngjTestCasePage.ets
index fdd9c57..4fa289e 100644
--- a/entry/src/main/ets/MainAbility/pages/pngjTestCasePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/pngjTestCasePage.ets
@@ -13,11 +13,11 @@
* limitations under the License.
*/
import router from '@system.router';
-import {Pngj} from '../glide/pngj/Pngj'
+import {Pngj} from '@ohos/imageknife'
import resourceManager from '@ohos.resourceManager';
-import {FileUtils} from '../cache/FileUtils.ets'
+import {FileUtils} from '@ohos/imageknife'
import featureability from '@ohos.ability.featureAbility'
-
+import ArkWorker from '@ohos.worker'
@Entry
@Component
struct PngjTestCasePage {
@@ -63,14 +63,14 @@ struct PngjTestCasePage {
Button('测试readPngImageInfo')
.onClick(() => {
let pngj = new Pngj();
- pngj.readPngImageInfo(this.pngSource, (value) => {
+ pngj.readPngImageInfo(this.pngSource, (sender, value) => {
this.hint1 = JSON.stringify(value);
})
}).margin({ top: 5, left: 10 })
Button('测试readPngImage')
.onClick(() => {
let pngj = new Pngj();
- pngj.readPngImage(this.pngSource, (value) => {
+ pngj.readPngImage(this.pngSource, (sender, value) => {
this.hint2 = 'img with=' + value.width + ' img height=' + value.height
+ ' img depth=' + value.depth + ' img ctype=' + value.ctype
console.log('png data =' + value.data);
@@ -79,7 +79,7 @@ struct PngjTestCasePage {
Button('测试writePngWithString')
.onClick(() => {
let pngj = new Pngj();
- pngj.writePngWithString('hello world', this.pngSource, (value) => {
+ pngj.writePngWithString('hello world', this.pngSource, (sender, value) => {
FileUtils.getInstance().createFileProcess(
this.rootFolder + '/pngj',
@@ -92,7 +92,55 @@ struct PngjTestCasePage {
Button('测试writePng')
.onClick(() => {
let pngj = new Pngj();
- pngj.writePng(this.pngSource, (value) => {
+ pngj.writePng(this.pngSource, (sender, value) => {
+ FileUtils.getInstance().createFileProcess(
+ this.rootFolder + '/pngj',
+ this.rootFolder + '/pngj/newPng2.png',
+ value)
+ let png2 = new Uint8Array(value)
+ this.hint4 = 'png2未写入长度' + png2.byteLength + '目录文件:' + this.rootFolder + '/pngj/newPng2.png' + '保存后使用2进制查看数据是否新增'
+ })
+ }).margin({ top: 5, left: 10 })
+ }.width('100%')
+ .height(60).backgroundColor(Color.Pink)
+ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
+ Button('测试readPngImageInfo')
+ .onClick(() => {
+ let pngj = new Pngj();
+ pngj.readPngImageInfo(this.pngSource, (sender, value) => {
+ this.hint1 = JSON.stringify(value);
+ })
+ }).margin({ top: 5, left: 10 })
+ Button('测试readPngImageAsync')
+ .onClick(() => {
+ let pngj = new Pngj();
+ let worker = new ArkWorker.Worker('workers/worker1.js', { type: 'classic', name: 'readPngImageAsync'})
+ pngj.readPngImageAsync(worker, this.pngSource, (sender, value) => {
+ this.pngSource = sender
+ this.hint2 = 'img with=' + value.width + ' img height=' + value.height
+ + ' img depth=' + value.depth + ' img ctype=' + value.ctype
+ })
+ }).margin({ top: 5, left: 10 })
+ Button('测试writePngWithStringAsync')
+ .onClick(() => {
+ let pngj = new Pngj();
+ let worker = new ArkWorker.Worker('workers/worker1.js', { type: 'classic', name: 'writePngWithStringAsync'})
+ pngj.writePngWithStringAsync(worker, 'hello world', this.pngSource, (sender, value) => {
+ this.pngSource = sender
+ FileUtils.getInstance().createFileProcess(
+ this.rootFolder + '/pngj',
+ this.rootFolder + '/pngj/newPng.png',
+ value)
+ let png1 = new Uint8Array(value)
+ this.hint3 = 'png写入后长度' + png1.byteLength + '目录文件:' + this.rootFolder + '/pngj/newPng.png' + '保存后使用2进制查看数据是否新增'
+ })
+ }).margin({ top: 5, left: 10 })
+ Button('测试writePngAsync')
+ .onClick(() => {
+ let pngj = new Pngj();
+ let worker = new ArkWorker.Worker('workers/worker1.js', { type: 'classic', name: 'writePngAsync'})
+ pngj.writePngAsync(worker, this.pngSource, (sender, value) => {
+ this.pngSource = sender
FileUtils.getInstance().createFileProcess(
this.rootFolder + '/pngj',
this.rootFolder + '/pngj/newPng2.png',
@@ -126,5 +174,3 @@ struct PngjTestCasePage {
return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset)
}
}
-
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/showErrorholderTestCasePage.ets b/entry/src/main/ets/MainAbility/pages/showErrorholderTestCasePage.ets
index 342cb46..5f86bfe 100644
--- a/entry/src/main/ets/MainAbility/pages/showErrorholderTestCasePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/showErrorholderTestCasePage.ets
@@ -12,36 +12,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from "../glide/GlideImage.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
-import {RoundedCornersTransformation} from "../glide/transform/RoundedCornersTransformation.ets"
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
+import {RoundedCornersTransformation} from '@ohos/imageknife'
@Entry
@Component
struct ShowErrorholderTestCasePage {
- @State glideOption1: GlideOption =
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: "https://thirdwx.qlogo.cn/mmopen/xxxxx",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
- @State glideOption2: GlideOption =
+ @State imageKnifeOption2: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
- @State glideOption3: GlideOption =
+ @State imageKnifeOption3: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
- @State glideOption4: GlideOption =
+ @State imageKnifeOption4: ImageKnifeOption =
{
loadSrc: "https://hbimg.huabanimg.com/xxxxx",
size: { width: 300, height: 300 },
@@ -52,10 +52,10 @@ struct ShowErrorholderTestCasePage {
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- GlideImage({ glideOption: $glideOption1 })
- GlideImage({ glideOption: $glideOption2 })
- GlideImage({ glideOption: $glideOption3 })
- GlideImage({ glideOption: $glideOption4 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption2 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption3 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption4 })
}
}
.width('100%')
diff --git a/entry/src/main/ets/MainAbility/pages/storageTestDiskLruCache.ets b/entry/src/main/ets/MainAbility/pages/storageTestDiskLruCache.ets
index 5568a99..3719cef 100644
--- a/entry/src/main/ets/MainAbility/pages/storageTestDiskLruCache.ets
+++ b/entry/src/main/ets/MainAbility/pages/storageTestDiskLruCache.ets
@@ -14,10 +14,10 @@
*/
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RequestOption} from "../glide/RequestOption.ets"
-import {GlideData} from "../glide/GlideData.ets"
-import {PixelMapPack} from "../glide/PixelMapPack.ets"
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RequestOption} from '@ohos/imageknife'
+import {ImageKnifeData} from '@ohos/imageknife'
+import {PixelMapPack} from '@ohos/imageknife'
@@ -25,46 +25,46 @@ import {PixelMapPack} from "../glide/PixelMapPack.ets"
@Entry
@Component
struct StorageTestDiskLruCache {
- @Watch('watchGlideOption') @State glideOption: GlideOption =
+ @Watch('watchImageKnifeOption') @State imageKnifeOption: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
- @State glidePixelMapPack: PixelMapPack = new PixelMapPack();
- @State glideResource: Resource = $r('app.media.icon_loading')
- @State glideString: string = ""
+ @State imageKnifePixelMapPack: PixelMapPack = new PixelMapPack();
+ @State imageKnifeResource: Resource = $r('app.media.icon_loading')
+ @State imageKnifeString: string = ""
@State normalPixelMap: boolean = false;
@State normalResource: boolean = true;
- previousData: GlideData = null;
- nowData: GlideData = null;
+ previousData: ImageKnifeData = null;
+ nowData: ImageKnifeData = null;
@State logText: string = "打印日志结果";
- watchGlideOption() {
- this.glideExecute();
+ watchImageKnifeOption() {
+ this.imageKnifeExecute();
}
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- Text("Glide测试DiskLruCache能力")
+ Text("ImageKnife测试DiskLruCache能力")
.backgroundColor(Color.Blue)
- Button("替换Glide默认DiskLruCache并设置大小1M")
+ Button("替换ImageKnife默认DiskLruCache并设置大小1M")
.onClick(() => {
- diskGlide.replaceDiskLruCache(1 * 1024 * 1024)
+ DiskImageKnife.replaceDiskLruCache(1 * 1024 * 1024)
}).margin({top:15, bottom:15})
- Button("替换Glide默认DiskLruCache并设置大小30M")
+ Button("替换ImageKnife默认DiskLruCache并设置大小30M")
.onClick(() => {
- diskGlide.replaceDiskLruCache(30 * 1024 * 1024)
+ DiskImageKnife.replaceDiskLruCache(30 * 1024 * 1024)
}).margin({top:15, bottom:15})
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button("加载jpg网络图")
.onClick(() => {
- this.glideOption = {
+ this.imageKnifeOption = {
loadSrc: "https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -75,7 +75,7 @@ struct StorageTestDiskLruCache {
}).margin({ top: 5, left: 10 })
Button("加载png网络图")
.onClick(() => {
- this.glideOption = {
+ this.imageKnifeOption = {
loadSrc: "https://img-blog.csdnimg.cn/20191215043500229.png",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -85,7 +85,7 @@ struct StorageTestDiskLruCache {
}).margin({ top: 5, left: 10 })
Button("加载webp网络图")
.onClick(() => {
- this.glideOption = {
+ this.imageKnifeOption = {
loadSrc: "https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -95,7 +95,7 @@ struct StorageTestDiskLruCache {
}).margin({ top: 5, left: 10 })
Button("加载bmp网络图")
.onClick(() => {
- this.glideOption = {
+ this.imageKnifeOption = {
loadSrc: "https://img-blog.csdn.net/20140514114029140",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -107,12 +107,12 @@ struct StorageTestDiskLruCache {
.height(60).backgroundColor(Color.Pink)
- Image(this.normalPixelMap ? this.glidePixelMapPack.pixelMap : (this.normalResource ? this.glideResource : this.glideString))
- .width(this.glideOption.size ? this.glideOption.size.width : '100%')
- .height(this.glideOption.size ? this.glideOption.size.height : '100%')
- .objectFit(this.glideOption.imageFit ? this.glideOption.imageFit : ImageFit.Fill)
- .backgroundColor(this.glideOption.backgroundColor ? this.glideOption.backgroundColor : Color.White)
- .margin(this.glideOption.margin ? this.glideOption.margin : { left: 0, top: 0, right: 0, bottom: 0 })
+ Image(this.normalPixelMap ? this.imageKnifePixelMapPack.pixelMap : (this.normalResource ? this.imageKnifeResource : this.imageKnifeString))
+ .width(this.imageKnifeOption.size ? this.imageKnifeOption.size.width : '100%')
+ .height(this.imageKnifeOption.size ? this.imageKnifeOption.size.height : '100%')
+ .objectFit(this.imageKnifeOption.imageFit ? this.imageKnifeOption.imageFit : ImageFit.Fill)
+ .backgroundColor(this.imageKnifeOption.backgroundColor ? this.imageKnifeOption.backgroundColor : Color.White)
+ .margin(this.imageKnifeOption.margin ? this.imageKnifeOption.margin : { left: 0, top: 0, right: 0, bottom: 0 })
@@ -128,59 +128,56 @@ struct StorageTestDiskLruCache {
}
-// glide 第一次启动和数据刷新后重新发送请求
- glideExecute() {
+// imageKnife 第一次启动和数据刷新后重新发送请求
+ imageKnifeExecute() {
let request = new RequestOption();
- request.load(this.glideOption.loadSrc)
+ request.load(this.imageKnifeOption.loadSrc)
.addListener((err, data) => {
- this.glideChangeSource(data)
+ this.imageKnifeChangeSource(data)
return false;
})
- if (this.glideOption.placeholderSrc) {
- request.placeholder(this.glideOption.placeholderSrc, (data) => {
- this.glideChangeSource(data)
+ if (this.imageKnifeOption.placeholderSrc) {
+ request.placeholder(this.imageKnifeOption.placeholderSrc, (data) => {
+ this.imageKnifeChangeSource(data)
})
}
- if (this.glideOption.errorholderSrc) {
- request.errorholder(this.glideOption.errorholderSrc, (data) => {
- this.glideChangeSource(data)
+ if (this.imageKnifeOption.errorholderSrc) {
+ request.errorholder(this.imageKnifeOption.errorholderSrc, (data) => {
+ this.imageKnifeChangeSource(data)
})
}
- if (this.glideOption.transformtions) {
- request.transforms(this.glideOption.transformtions)
+
+ if (this.imageKnifeOption.size) {
+ request.setImageViewSize(this.imageKnifeOption.size)
}
- if (this.glideOption.size) {
- request.setImageViewSize(this.glideOption.size)
+ if (this.imageKnifeOption.onlyRetrieveFromCache) {
+ request.retrieveDataFromCache(this.imageKnifeOption.onlyRetrieveFromCache)
}
- if (this.glideOption.onlyRetrieveFromCache) {
- request.retrieveDataFromCache(this.glideOption.onlyRetrieveFromCache)
+ if (this.imageKnifeOption.isCacheable) {
+ request.skipMemoryCache(!this.imageKnifeOption.isCacheable)
}
- if (this.glideOption.isCacheable) {
- request.skipMemoryCache(!this.glideOption.isCacheable)
+ if (this.imageKnifeOption.strategy) {
+ request.diskCacheStrategy(this.imageKnifeOption.strategy)
}
- if (this.glideOption.strategy) {
- request.diskCacheStrategy(this.glideOption.strategy)
- }
-
- if (this.glideOption.dontAnimateFlag) {
+ if (this.imageKnifeOption.dontAnimateFlag) {
request.dontAnimate()
}
- if (this.glideOption.allCacheInfoCallback) {
- request.addAllCacheInfoCallback(this.glideOption.allCacheInfoCallback)
+ if (this.imageKnifeOption.allCacheInfoCallback) {
+ request.addAllCacheInfoCallback(this.imageKnifeOption.allCacheInfoCallback)
}
- diskGlide.call(request);
+ DiskImageKnife.call(request);
}
- glideChangeSource(data:GlideData) {
- this.glideSpecialFixed(data);
+ imageKnifeChangeSource(data:ImageKnifeData) {
+ this.imageKnifeSpecialFixed(data);
- //查看mGlide中的DiskLruCache
- let disk = diskGlide.getDiskMemoryCache();
+ //查看mImageKnife中的DiskLruCache
+ let disk = DiskImageKnife.getDiskMemoryCache();
let showDisk = ''
disk.foreachDiskLruCache((value, key, map) => {
showDisk += "key=" + key + "&value=" + value;
@@ -188,115 +185,114 @@ struct StorageTestDiskLruCache {
this.logText = "日志结果:" + showDisk;
}
- glideSpecialFixed(data:GlideData) {
+ imageKnifeSpecialFixed(data:ImageKnifeData) {
if (this.nowData) {
this.previousData = this.nowData;
this.nowData = data;
if (data.isPixelMap()) {
// PixelMap
- console.log("Glide占位图输出=PixelMap")
+ console.log("ImageKnife占位图输出=PixelMap")
if (this.previousData.isSvg()) {
- console.log("Glide占位图输出=PixelMap 上一个是SVG")
+ console.log("ImageKnife占位图输出=PixelMap 上一个是SVG")
this.normalPixelMap = true;
this.normalResource = true;
let pixelMapPack1 = new PixelMapPack();
- pixelMapPack1.pixelMap = new PixelMap();
- this.glidePixelMapPack = pixelMapPack1;
+ this.imageKnifePixelMapPack = pixelMapPack1;
setTimeout(() => {
let pixelMapPack2 = new PixelMapPack();
- pixelMapPack2.pixelMap = data.glideValue as PixelMap;
- this.glidePixelMapPack = pixelMapPack2;
+ pixelMapPack2.pixelMap = data.imageKnifeValue as PixelMap;
+ this.imageKnifePixelMapPack = pixelMapPack2;
}, 100)
} else {
this.normalPixelMap = true;
this.normalResource = true;
let pixelMapPack3 = new PixelMapPack();
- pixelMapPack3.pixelMap = data.glideValue as PixelMap;
+ pixelMapPack3.pixelMap = data.imageKnifeValue as PixelMap;
- this.glidePixelMapPack = pixelMapPack3;
+ this.imageKnifePixelMapPack = pixelMapPack3;
}
}
else if (data.isString()) {
// String
- console.log("glidevalue=" + JSON.stringify(data));
- console.log("Glide占位图输出=String")
+ console.log("imageKnifevalue=" + JSON.stringify(data));
+ console.log("ImageKnife占位图输出=String")
if (this.previousData.isSvg()) {
- console.log("data.glideValue=" + JSON.stringify(data.glideValue))
- console.log("Glide占位图输出=String 拥有上一个图片类型 上一个是SVG")
+ console.log("data.imageKnifeValue=" + JSON.stringify(data.imageKnifeValue))
+ console.log("ImageKnife占位图输出=String 拥有上一个图片类型 上一个是SVG")
this.normalPixelMap = false;
this.normalResource = false;
- let firstIndex = (data.glideValue as string).indexOf(diskGlide.getSvgAndGifFolder());
+ let firstIndex = (data.imageKnifeValue as string).indexOf(DiskImageKnife.getSvgAndGifFolder());
console.log("firstIndex=" + firstIndex);
- let suffix = (data.glideValue as string).substring(firstIndex, (data.glideValue as string).length)
+ let suffix = (data.imageKnifeValue as string).substring(firstIndex, (data.imageKnifeValue as string).length)
console.log("suffix =" + suffix);
- let glideNeedStr = 'internal://app/' + suffix;
- this.glideString = glideNeedStr;
+ let imageKnifeNeedStr = 'internal://app/' + suffix;
+ this.imageKnifeString = imageKnifeNeedStr;
} else {
- console.log("data.glideValue=" + JSON.stringify(data.glideValue))
- console.log("Glide占位图输出=String 拥有上一个图片类型 上一个不是SVG")
+ console.log("data.imageKnifeValue=" + JSON.stringify(data.imageKnifeValue))
+ console.log("ImageKnife占位图输出=String 拥有上一个图片类型 上一个不是SVG")
this.normalPixelMap = false;
this.normalResource = false;
- let firstIndex = (data.glideValue as string).indexOf(diskGlide.getSvgAndGifFolder());
+ let firstIndex = (data.imageKnifeValue as string).indexOf(DiskImageKnife.getSvgAndGifFolder());
console.log("firstIndex=" + firstIndex);
- let suffix = (data.glideValue as string).substring(firstIndex, (data.glideValue as string).length)
+ let suffix = (data.imageKnifeValue as string).substring(firstIndex, (data.imageKnifeValue as string).length)
console.log("suffix =" + suffix);
- let glideNeedStr = 'internal://app/' + suffix;
- this.glideString = glideNeedStr;
+ let imageKnifeNeedStr = 'internal://app/' + suffix;
+ this.imageKnifeString = imageKnifeNeedStr;
}
} else if (data.isResource()) {
- console.log("Glide占位图输出=Resource")
+ console.log("ImageKnife占位图输出=Resource")
if (this.previousData.isSvg()) {
- console.log("Glide占位图输出=Resource 上一个是SVG")
+ console.log("ImageKnife占位图输出=Resource 上一个是SVG")
this.normalPixelMap = false;
this.normalResource = true;
- this.glideResource = data.glideValue as Resource;
+ this.imageKnifeResource = data.imageKnifeValue as Resource;
} else {
this.normalPixelMap = false;
this.normalResource = true;
- this.glideResource = data.glideValue as Resource;
+ this.imageKnifeResource = data.imageKnifeValue as Resource;
}
} else {
- console.log("Glide占位图输出=数据错误")
+ console.log("ImageKnife占位图输出=数据错误")
}
} else {
this.nowData = data;
if (data.isPixelMap()) {
// PixelMap
- console.log("Glide占位图输出=PixelMap")
+ console.log("ImageKnife占位图输出=PixelMap")
this.normalPixelMap = true;
this.normalResource = true;
let pixelMapPack4 = new PixelMapPack();
- pixelMapPack4.pixelMap = data.glideValue as PixelMap;
+ pixelMapPack4.pixelMap = data.imageKnifeValue as PixelMap;
- this.glidePixelMapPack = pixelMapPack4;
+ this.imageKnifePixelMapPack = pixelMapPack4;
}
else if (data.isString()) {
// String
- console.log("data.glideValue=" + JSON.stringify(data.glideValue))
- console.log("Glide占位图输出=String 没有上一个图片类型")
+ console.log("data.imageKnifeValue=" + JSON.stringify(data.imageKnifeValue))
+ console.log("ImageKnife占位图输出=String 没有上一个图片类型")
this.normalPixelMap = false;
this.normalResource = false;
- let firstIndex = (data.glideValue as string).indexOf(diskGlide.getSvgAndGifFolder());
+ let firstIndex = (data.imageKnifeValue as string).indexOf(DiskImageKnife.getSvgAndGifFolder());
console.log("firstIndex=" + firstIndex);
- let suffix = (data.glideValue as string).substring(firstIndex, (data.glideValue as string).length)
+ let suffix = (data.imageKnifeValue as string).substring(firstIndex, (data.imageKnifeValue as string).length)
console.log("suffix =" + suffix);
- let glideNeedStr = 'internal://app/' + suffix;
- this.glideString = glideNeedStr;
+ let imageKnifeNeedStr = 'internal://app/' + suffix;
+ this.imageKnifeString = imageKnifeNeedStr;
} else if (data.isResource()) {
- console.log("Glide占位图输出=Resource")
+ console.log("ImageKnife占位图输出=Resource")
this.normalPixelMap = false;
this.normalResource = true;
- this.glideResource = data.glideValue as Resource;
+ this.imageKnifeResource = data.imageKnifeValue as Resource;
} else {
- console.log("Glide占位图输出=数据错误")
+ console.log("ImageKnife占位图输出=数据错误")
}
}
@@ -322,4 +318,4 @@ struct StorageTestDiskLruCache {
}
}
-var diskGlide = globalThis.exports.default.data.glide
\ No newline at end of file
+var DiskImageKnife = globalThis.exports.default.data.imageKnife
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/storageTestLruCache.ets b/entry/src/main/ets/MainAbility/pages/storageTestLruCache.ets
index 12873d6..8837ad5 100644
--- a/entry/src/main/ets/MainAbility/pages/storageTestLruCache.ets
+++ b/entry/src/main/ets/MainAbility/pages/storageTestLruCache.ets
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
-import {LruCache} from '../cache/LruCache.ets'
+import {LruCache} from '@ohos/imageknife'
function getRandomInt(min, max) {
min = Math.ceil(min);
diff --git a/entry/src/main/ets/MainAbility/pages/testAllCacheInfoPage.ets b/entry/src/main/ets/MainAbility/pages/testAllCacheInfoPage.ets
index 834547b..b474d96 100644
--- a/entry/src/main/ets/MainAbility/pages/testAllCacheInfoPage.ets
+++ b/entry/src/main/ets/MainAbility/pages/testAllCacheInfoPage.ets
@@ -12,12 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {RequestOption} from "../glide/RequestOption.ets"
-import {AllCacheInfo,IAllCacheInfoCallback} from "../glide/interface/iallcacheinfocallback.ets"
-import {GlideImage} from "../glide/GlideImage.ets"
-import {PixelMapPack} from "../glide/PixelMapPack.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
+import {RequestOption} from '@ohos/imageknife'
+import {AllCacheInfo,IAllCacheInfoCallback} from '@ohos/imageknife'
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {TransformType} from '@ohos/imageknife'
+import {PixelMapPack} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
@Entry
@Component
@@ -26,48 +27,54 @@ struct TestAllCacheInfoPage {
@State networkPixelMap: PixelMapPack = new PixelMapPack();
allCacheInfoCallback1 =(allCacheInfo)=>{
let info = allCacheInfo as AllCacheInfo;
- console.log("AllCacheInfoCallback glideimage1 memory ="+JSON.stringify(info.memoryCacheInfo))
- console.log("AllCacheInfoCallback glideimage1 resource ="+JSON.stringify(info.resourceCacheInfo))
- console.log("AllCacheInfoCallback glideimage1 data ="+JSON.stringify(info.dataCacheInfo))
+ console.log("AllCacheInfoCallback imageknifecomponent1 memory ="+JSON.stringify(info.memoryCacheInfo))
+ console.log("AllCacheInfoCallback imageknifecomponent1 resource ="+JSON.stringify(info.resourceCacheInfo))
+ console.log("AllCacheInfoCallback imageknifecomponent1 data ="+JSON.stringify(info.dataCacheInfo))
this.cacheinfo3 = "memory="+JSON.stringify(info.memoryCacheInfo)+
"\n resource ="+JSON.stringify(info.resourceCacheInfo)+
"\n data ="+JSON.stringify(info.dataCacheInfo)
}
allCacheInfoCallback2 =(allCacheInfo)=>{
let info = allCacheInfo as AllCacheInfo;
- console.log("AllCacheInfoCallback glideimage2 memory ="+JSON.stringify(info.memoryCacheInfo))
- console.log("AllCacheInfoCallback glideimage2 resource ="+JSON.stringify(info.resourceCacheInfo))
- console.log("AllCacheInfoCallback glideimage2 data ="+JSON.stringify(info.dataCacheInfo))
+ console.log("AllCacheInfoCallback imageknifecomponent2 memory ="+JSON.stringify(info.memoryCacheInfo))
+ console.log("AllCacheInfoCallback imageknifecomponent2 resource ="+JSON.stringify(info.resourceCacheInfo))
+ console.log("AllCacheInfoCallback imageknifecomponent2 data ="+JSON.stringify(info.dataCacheInfo))
this.cacheinfo4 = "memory="+JSON.stringify(info.memoryCacheInfo)+
"\n resource ="+JSON.stringify(info.resourceCacheInfo)+
"\n data ="+JSON.stringify(info.dataCacheInfo)
}
- @State glideOption1: GlideOption =
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: $r('app.media.pngSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
margin:{top:15},
- transformtions: [new RotateImageTransformation(180)],
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:180
+ },
allCacheInfoCallback:this.allCacheInfoCallback1
};
- @State glideOption2: GlideOption =
+ @State imageKnifeOption2: ImageKnifeOption =
{
loadSrc: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ericA1Mv66TwicuYOtbDMBcUhv1aa9RJBeAn9uURfcZD0AUGrJebAn1g2AjN0vb2E1XTET7fTuLBNmA/132",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
margin:{top:15},
- transformtions: [new RotateImageTransformation(180)],
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:180
+ },
allCacheInfoCallback:this.allCacheInfoCallback2
};
- glideImageAngle:number = 90;
+ imageKnifeComponentAngle:number = 90;
@State cacheinfo1:string = "观察本地资源获取缓存信息输出"
@State cacheinfo2:string = "观察网络资源获取缓存信息输出"
- @State cacheinfo3:string = "观察GlideImage本地缓存输出"
- @State cacheinfo4:string = "观察GlideImage网络缓存输出"
+ @State cacheinfo3:string = "观察ImageKnifeComponent本地缓存输出"
+ @State cacheinfo4:string = "观察ImageKnifeComponent网络缓存输出"
build() {
Scroll() {
@@ -100,43 +107,49 @@ struct TestAllCacheInfoPage {
.backgroundColor(Color.Green)
.margin({ top: 15 })
- Button("GlideImage加载本地资源获取缓存信息").width(300).height(25)
+ Button("ImageKnifeComponent加载本地资源获取缓存信息").width(300).height(25)
.onClick(() => {
- this.glideImageAngle = this.glideImageAngle + 45;
- this.glideOption1 =
+ this.imageKnifeComponentAngle = this.imageKnifeComponentAngle + 45;
+ this.imageKnifeOption1 =
{
loadSrc: $r('app.media.pngSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
margin: { top: 15 },
- transformtions: [new RotateImageTransformation(this.glideImageAngle)],
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:this.imageKnifeComponentAngle
+ },
allCacheInfoCallback:this.allCacheInfoCallback1
};
}).margin({ top: 15 })
Scroll() {
Text(this.cacheinfo3).fontSize(15)
}.width(300).height(200)
- GlideImage({ glideOption: $glideOption1 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
- Button("GlideImage加载网络资源获取缓存信息").width(300).height(25)
+ Button("ImageKnifeComponent加载网络资源获取缓存信息").width(300).height(25)
.onClick(() => {
- this.glideImageAngle = this.glideImageAngle + 45;
- this.glideOption2 =
+ this.imageKnifeComponentAngle = this.imageKnifeComponentAngle + 45;
+ this.imageKnifeOption2 =
{
loadSrc: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ericA1Mv66TwicuYOtbDMBcUhv1aa9RJBeAn9uURfcZD0AUGrJebAn1g2AjN0vb2E1XTET7fTuLBNmA/132",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
margin: { top: 15 },
- transformtions: [new RotateImageTransformation(this.glideImageAngle)],
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:this.imageKnifeComponentAngle
+ },
allCacheInfoCallback:this.allCacheInfoCallback2
};
})
Scroll() {
Text(this.cacheinfo4).fontSize(15)
}.width(300).height(200)
- GlideImage({ glideOption: $glideOption2 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption2 })
}
}
@@ -149,12 +162,12 @@ struct TestAllCacheInfoPage {
}
private testAllCacheInfoNative() {
- let glideOption = new RequestOption();
- glideOption.load($r('app.media.pngSample'))
+ let imageKnifeOption = new RequestOption();
+ imageKnifeOption.load($r('app.media.pngSample'))
.setImageViewSize({width:300,height:300})
.addListener((err, data) => {
let pack = new PixelMapPack();
- pack.pixelMap = data.glideValue as PixelMap;;
+ pack.pixelMap = data.imageKnifeValue as PixelMap;;
this.nativePixelMap = pack;
return false;
}).addAllCacheInfoCallback((allCacheInfo)=>{
@@ -166,17 +179,17 @@ struct TestAllCacheInfoPage {
"\n resource ="+JSON.stringify(info.resourceCacheInfo)+
"\n data ="+JSON.stringify(info.dataCacheInfo)
})
- Glide.call(glideOption);
+ ImageKnife.call(imageKnifeOption);
}
private testAllCacheInfoNetwork() {
- let glideOption2 = new RequestOption();
- glideOption2.load("https://hbimg.huabanimg.com/0ef60041445edcfd6b38d20e19024b2cd9281dcc3525a4-Vy8fYO_fw658/format/webp")
+ let imageKnifeOption2 = new RequestOption();
+ imageKnifeOption2.load("https://hbimg.huabanimg.com/0ef60041445edcfd6b38d20e19024b2cd9281dcc3525a4-Vy8fYO_fw658/format/webp")
.addListener((err, data) => {
let pack = new PixelMapPack();
- pack.pixelMap = data.glideValue as PixelMap;
+ pack.pixelMap = data.imageKnifeValue as PixelMap;
this.networkPixelMap = pack;
- console.log("glide2 图片2 赋值!")
+ console.log("imageknife2 图片2 赋值!")
return false;
}).addAllCacheInfoCallback((allCacheInfo)=>{
let info = allCacheInfo as AllCacheInfo;
@@ -189,9 +202,9 @@ struct TestAllCacheInfoPage {
})
.setImageViewSize({width:300,height:300})
.rotateImage(180)
- Glide.call(glideOption2);
+ ImageKnife.call(imageKnifeOption2);
}
}
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
+var ImageKnife = globalThis.exports.default.data.imageKnife
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/testAllTypeGlideImagePage.ets b/entry/src/main/ets/MainAbility/pages/testAllTypeImageKnifeComponentPage.ets
similarity index 54%
rename from entry/src/main/ets/MainAbility/pages/testAllTypeGlideImagePage.ets
rename to entry/src/main/ets/MainAbility/pages/testAllTypeImageKnifeComponentPage.ets
index 191c4c2..3a8eb84 100644
--- a/entry/src/main/ets/MainAbility/pages/testAllTypeGlideImagePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/testAllTypeImageKnifeComponentPage.ets
@@ -12,62 +12,78 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from "../glide/GlideImage.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
+import {TransformType} from '@ohos/imageknife'
@Entry
@Component
-struct TestAllTypeGlideImagePage {
- @State glideOption1: GlideOption =
+struct TestAllTypeImageKnifeComponentPage {
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.Tomato'),
errorholderSrc: $r('app.media.picture1'),
- transformtions: [new RotateImageTransformation(180)]
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:180
+ }
};
- @State glideOption2: GlideOption =
+ @State imageKnifeOption2: ImageKnifeOption =
{
loadSrc: $r('app.media.pngSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.Tomato'),
errorholderSrc: $r('app.media.picture1'),
- transformtions: [new RotateImageTransformation(180)]
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:180
+ }
};
- @State glideOption3: GlideOption =
+ @State imageKnifeOption3: ImageKnifeOption =
{
- loadSrc: $r('app.media.webpSample'),
+ loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.Tomato'),
errorholderSrc: $r('app.media.picture1'),
- transformtions: [new RotateImageTransformation(180)]
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:180
+ }
};
- @State glideOption4: GlideOption =
+ @State imageKnifeOption4: ImageKnifeOption =
{
loadSrc: $r('app.media.svgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.Tomato'),
errorholderSrc: $r('app.media.picture1'),
- transformtions: [new RotateImageTransformation(180)]
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:180
+ }
};
- @State glideOption5: GlideOption =
+ @State imageKnifeOption5: ImageKnifeOption =
{
loadSrc: $r('app.media.bmpSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.Tomato'),
errorholderSrc: $r('app.media.picture1'),
- transformtions: [new RotateImageTransformation(180)]
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:180
+ }
};
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- GlideImage({ glideOption: $glideOption1 })
- GlideImage({ glideOption: $glideOption2 })
- GlideImage({ glideOption: $glideOption3 })
- GlideImage({ glideOption: $glideOption4 })
- GlideImage({ glideOption: $glideOption5 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption2 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption3 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption4 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption5 })
}
}
.width('100%')
@@ -80,4 +96,4 @@ struct TestAllTypeGlideImagePage {
}
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
+var ImageKnife = globalThis.exports.default.data.imageKnife
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/testAllTypeNativeImagePage.ets b/entry/src/main/ets/MainAbility/pages/testAllTypeNativeImagePage.ets
index c3f4633..b6188a7 100644
--- a/entry/src/main/ets/MainAbility/pages/testAllTypeNativeImagePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/testAllTypeNativeImagePage.ets
@@ -12,9 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from "../glide/GlideImage.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
@Entry
@Component
@@ -28,7 +28,7 @@ struct TestAllTypeNativeImagePage {
Image($r('app.media.pngSample'))
.width(300)
.height(300)
- Image($r('app.media.webpSample'))
+ Image($r('app.media.jpgSample'))
.width(300)
.height(300)
Image($r('app.media.svgSample'))
@@ -49,4 +49,4 @@ struct TestAllTypeNativeImagePage {
}
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
+var ImageKnife = globalThis.exports.default.data.imageKnife
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/testGifDontAnimatePage.ets b/entry/src/main/ets/MainAbility/pages/testGifDontAnimatePage.ets
index 17184d0..a6a1c2f 100644
--- a/entry/src/main/ets/MainAbility/pages/testGifDontAnimatePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/testGifDontAnimatePage.ets
@@ -12,14 +12,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from '../glide/GlideImage.ets'
-import {GlideOption} from '../glide/GlideOption.ets'
-import {RotateImageTransformation} from '../glide/transform/RotateImageTransformation.ets'
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
@Entry
@Component
struct TestGifDontAnimatePage {
- @State glideOption1: GlideOption =
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
@@ -35,7 +35,7 @@ struct TestGifDontAnimatePage {
Flex({direction:FlexDirection.Row}){
Button('本地资源gif')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: $r('app.media.gifSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -46,7 +46,7 @@ struct TestGifDontAnimatePage {
}).margin({left:15}).backgroundColor(Color.Grey)
Button('本地资源gif静态')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: $r('app.media.gifSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -61,7 +61,7 @@ struct TestGifDontAnimatePage {
Flex({direction:FlexDirection.Row}){
Button('网络资源gif')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -71,7 +71,7 @@ struct TestGifDontAnimatePage {
}).margin({left:15}).backgroundColor(Color.Grey)
Button('网络资源gif静态')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -82,7 +82,7 @@ struct TestGifDontAnimatePage {
}).margin({left:15}).backgroundColor(Color.Grey)
}
.margin({top:15})
- GlideImage({ glideOption: $glideOption1 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
}
}
@@ -96,4 +96,4 @@ struct TestGifDontAnimatePage {
}
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
+var ImageKnife = globalThis.exports.default.data.imageKnife
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/testGlideOptionChangedPage.ets b/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage.ets
similarity index 88%
rename from entry/src/main/ets/MainAbility/pages/testGlideOptionChangedPage.ets
rename to entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage.ets
index 022bae3..df15dcf 100644
--- a/entry/src/main/ets/MainAbility/pages/testGlideOptionChangedPage.ets
+++ b/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage.ets
@@ -12,14 +12,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from '../glide/GlideImage.ets'
-import {GlideOption} from '../glide/GlideOption.ets'
-import {RotateImageTransformation} from '../glide/transform/RotateImageTransformation.ets'
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
@Entry
@Component
-struct TestGlideOptionChangedPage {
- @State glideOption1: GlideOption =
+struct TestImageKnifeOptionChangedPage {
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
@@ -35,7 +35,7 @@ struct TestGlideOptionChangedPage {
Flex({direction:FlexDirection.Row}){
Button('本地资源jpg')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -46,7 +46,7 @@ struct TestGlideOptionChangedPage {
}).margin({left:5}).backgroundColor(Color.Blue)
Button('本地资源png')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: $r('app.media.pngSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -57,7 +57,7 @@ struct TestGlideOptionChangedPage {
}).margin({left:5}).backgroundColor(Color.Blue)
Button('本地资源bmp')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: $r('app.media.bmpSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -68,8 +68,8 @@ struct TestGlideOptionChangedPage {
}).margin({left:5}).backgroundColor(Color.Blue)
Button('本地资源webp')
.onClick(()=>{
- this.glideOption1 = {
- loadSrc: $r('app.media.webpSample'),
+ this.imageKnifeOption1 = {
+ loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
@@ -79,7 +79,7 @@ struct TestGlideOptionChangedPage {
}).margin({left:5}).backgroundColor(Color.Blue)
Button('本地资源svg')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: $r('app.media.svgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -90,7 +90,7 @@ struct TestGlideOptionChangedPage {
}).margin({left:5}).backgroundColor(Color.Blue)
Button('本地资源gif')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: $r('app.media.gifSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -104,7 +104,7 @@ struct TestGlideOptionChangedPage {
Flex({direction:FlexDirection.Row}){
Button('网络资源jpg')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: 'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -114,7 +114,7 @@ struct TestGlideOptionChangedPage {
}).margin({left:5}).backgroundColor(Color.Blue)
Button('网络资源png')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: 'https://img-blog.csdnimg.cn/20191215043500229.png',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -124,7 +124,7 @@ struct TestGlideOptionChangedPage {
}).margin({left:5}).backgroundColor(Color.Blue)
Button('网络资源bmp')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: 'https://img-blog.csdn.net/20140514114029140',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -134,7 +134,7 @@ struct TestGlideOptionChangedPage {
}).margin({left:5}).backgroundColor(Color.Blue)
Button('网络资源webp')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -144,7 +144,7 @@ struct TestGlideOptionChangedPage {
}).margin({left:5}).backgroundColor(Color.Blue)
Button('网络资源svg')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: 'http://design-svc.fat.lunz.cn/StaticFiles/BP9999999772/BV9999999422/SA9999998420/30df266a-485e-411e-b178-b9fb1d8e0748.svg',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -154,7 +154,7 @@ struct TestGlideOptionChangedPage {
}).margin({left:5}).backgroundColor(Color.Blue)
Button('网络资源gif')
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -167,7 +167,7 @@ struct TestGlideOptionChangedPage {
Text('下面为展示图片区域').margin({top:5})
Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){
- GlideImage({ glideOption: $glideOption1 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
}.width(400).height(400).margin({top:10}).backgroundColor(Color.Pink)
@@ -183,4 +183,3 @@ struct TestGlideOptionChangedPage {
}
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/testGlideOptionChangedPage2.ets b/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage2.ets
similarity index 86%
rename from entry/src/main/ets/MainAbility/pages/testGlideOptionChangedPage2.ets
rename to entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage2.ets
index f27ec72..5503b4b 100644
--- a/entry/src/main/ets/MainAbility/pages/testGlideOptionChangedPage2.ets
+++ b/entry/src/main/ets/MainAbility/pages/testImageKnifeOptionChangedPage2.ets
@@ -12,14 +12,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from "../glide/GlideImage.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
@Entry
@Component
-struct TestGlideOptionChangedPage2 {
- @State glideOption1: GlideOption =
+struct TestImageKnifeOptionChangedPage2 {
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
@@ -36,7 +36,7 @@ struct TestGlideOptionChangedPage2 {
Flex({direction:FlexDirection.Row}){
Button("网络资源jpg")
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: "https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -47,7 +47,7 @@ struct TestGlideOptionChangedPage2 {
}).margin({left:5}).backgroundColor(Color.Blue)
Button("网络资源png")
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: "https://img-blog.csdnimg.cn/20191215043500229.png",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -58,7 +58,7 @@ struct TestGlideOptionChangedPage2 {
}).margin({left:5}).backgroundColor(Color.Blue)
Button("网络资源bmp")
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: "https://img-blog.csdn.net/20140514114029140",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -69,7 +69,7 @@ struct TestGlideOptionChangedPage2 {
}).margin({left:5}).backgroundColor(Color.Blue)
Button("网络资源webp")
.onClick(()=>{
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: "https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -83,7 +83,7 @@ struct TestGlideOptionChangedPage2 {
Text("下面为展示图片区域").margin({top:5})
Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){
- GlideImage({ glideOption: $glideOption1 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
}.width(400).height(400).margin({top:10}).backgroundColor(Color.Pink)
@@ -99,4 +99,4 @@ struct TestGlideOptionChangedPage2 {
}
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
+var ImageKnife = globalThis.exports.default.data.imageKnife
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/testMemoryCachePage.ets b/entry/src/main/ets/MainAbility/pages/testMemoryCachePage.ets
deleted file mode 100644
index ae2fe84..0000000
--- a/entry/src/main/ets/MainAbility/pages/testMemoryCachePage.ets
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2021 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import resourceManager from '@ohos.resourceManager';
-import util from '@ohos.util';
-import {RequestOption} from "../glide/RequestOption.ets"
-//import {Glide} from '../glide/Glide'
-import{ALL} from "../cache/diskstrategy/enum/ALL"
-import{NONE} from "../cache/diskstrategy/enum/NONE"
-import {AsyncCallback} from "../glide/interface/asynccallback.ets"
-import {AsyncSuccess} from "../glide/interface/AsyncSuccess.ets"
-
-
-@Entry
-@Component
-struct TestMemoryCachePage {
- @State tomatoPixelMap: PixelMap = new PixelMap();
- @State tomatoPixelMap2: PixelMap = new PixelMap();
- @State iceCreamPixelMap: PixelMap = new PixelMap();
-
- build() {
- Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- Image(this.tomatoPixelMap)
- .width(200)
- .height(200)
- .objectFit(ImageFit.Contain)
- .backgroundColor(Color.Green)
- .onClick(() => {
- })
- Image(this.iceCreamPixelMap)
- .backgroundColor(Color.Grey)
- .objectFit(ImageFit.Contain)
- .width(200)
- .height(200)
- Image(this.tomatoPixelMap2)
- .objectFit(ImageFit.Contain)
- .backgroundColor(Color.Orange)
- .width(200)
- .height(200)
- }
- .width('100%')
- .height('100%')
- }
-
- aboutToAppear() {
- console.log("aboutToAppear()")
- this.testAllResourceLoading();
- }
-
- private testAllResourceLoading() {
-
- let glideOption = new RequestOption();
- glideOption.load($r('app.media.Tomato'))
- .addListener((err, data) => {
- console.log("glide1 图片1 赋值!")
- this.tomatoPixelMap = data.glideValue as PixelMap;
- return false;
- })
-
- Glide.call(glideOption);
-
-
- let glideOption2 = new RequestOption();
- glideOption2.load($r('app.media.IceCream'))
- .addListener((err, data) => {
- this.iceCreamPixelMap = data.glideValue as PixelMap;
- console.log("glide2 图片2 赋值!")
- return false;
- })
-
- Glide.call(glideOption2);
-
-
- let glideOption3 = new RequestOption();
- glideOption3.load($r('app.media.Tomato'))
- .addListener((err, data) => {
- this.tomatoPixelMap2 = data.glideValue as PixelMap;
- console.log("glide3 图片1 赋值!")
- return false;
- })
-
- Glide.call(glideOption3);
- }
-}
-
-
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/testPreloadPage.ets b/entry/src/main/ets/MainAbility/pages/testPreloadPage.ets
index e65c134..99e9bdc 100644
--- a/entry/src/main/ets/MainAbility/pages/testPreloadPage.ets
+++ b/entry/src/main/ets/MainAbility/pages/testPreloadPage.ets
@@ -12,15 +12,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from '../glide/GlideImage.ets'
-import {GlideOption} from '../glide/GlideOption.ets'
-import {RequestOption} from '../glide/RequestOption.ets'
-import {RotateImageTransformation} from '../glide/transform/RotateImageTransformation.ets'
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RequestOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
@Entry
@Component
struct TestPreloadPage {
- @State glideOption1: GlideOption =
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
@@ -28,7 +28,7 @@ struct TestPreloadPage {
errorholderSrc: $r('app.media.icon_failed'),
margin: { left: 15, top: 15, right: 15, bottom: 15 }
};
- @State glideOption2: GlideOption =
+ @State imageKnifeOption2: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
@@ -36,7 +36,7 @@ struct TestPreloadPage {
errorholderSrc: $r('app.media.icon_failed'),
margin: { left: 15, top: 15, right: 15, bottom: 15 }
};
- @State glideOption3: GlideOption =
+ @State imageKnifeOption3: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
@@ -45,7 +45,7 @@ struct TestPreloadPage {
margin: { left: 15, top: 15, right: 15, bottom: 15 }
};
- @State glideOption4: GlideOption =
+ @State imageKnifeOption4: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
@@ -53,7 +53,7 @@ struct TestPreloadPage {
errorholderSrc: $r('app.media.icon_failed'),
margin: { left: 15, top: 15, right: 15, bottom: 15 }
};
- @State glideOption5: GlideOption =
+ @State imageKnifeOption5: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
@@ -61,9 +61,9 @@ struct TestPreloadPage {
errorholderSrc: $r('app.media.icon_failed'),
margin: { left: 15, top: 15, right: 15, bottom: 15 }
};
- @State glideOption6: GlideOption =
+ @State imageKnifeOption6: ImageKnifeOption =
{
- loadSrc: $r('app.media.webpSample'),
+ loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
@@ -84,11 +84,11 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载本地资源gif 出现错误! err=' + err)
} else {
- console.log('预加载本地资源gif成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载本地资源gif成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
@@ -96,7 +96,7 @@ struct TestPreloadPage {
Button('本地资源gif')
.onClick(() => {
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: $r('app.media.gifSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -118,18 +118,18 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载本地资源gif静态 出现错误! err=' + err)
} else {
- console.log('预加载本地资源gif静态成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载本地资源gif静态成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
Button('本地资源gif静态')
.onClick(() => {
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: $r('app.media.gifSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -155,18 +155,18 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载网络资源gif 出现错误! err=' + err)
} else {
- console.log('预加载网络资源gif成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载网络资源gif成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
Button('网络资源gif')
.onClick(() => {
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -187,18 +187,18 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载网络资源gif静态 出现错误! err=' + err)
} else {
- console.log('预加载网络资源gif静态成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载网络资源gif静态成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
Button('网络资源gif静态')
.onClick(() => {
- this.glideOption1 = {
+ this.imageKnifeOption1 = {
loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -212,7 +212,7 @@ struct TestPreloadPage {
}
.margin({ top: 15 })
- GlideImage({ glideOption: $glideOption1 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
}
@@ -227,11 +227,11 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载本地资源svg 出现错误! err=' + err)
} else {
- console.log('预加载本地资源svg成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载本地资源svg成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
@@ -239,7 +239,7 @@ struct TestPreloadPage {
Button('本地资源svg')
.onClick(() => {
- this.glideOption2 = {
+ this.imageKnifeOption2 = {
loadSrc: $r('app.media.svgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -266,18 +266,18 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载网络资源gif 出现错误! err=' + err)
} else {
- console.log('预加载网络资源gif成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载网络资源gif成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
Button('网络资源svg')
.onClick(() => {
- this.glideOption2 = {
+ this.imageKnifeOption2 = {
loadSrc: 'http://design-svc.fat.lunz.cn/StaticFiles/BP9999999772/BV9999999422/SA9999998420/4dc8463e-8ac6-4eb4-862c-783bf486a242.svg',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -292,7 +292,7 @@ struct TestPreloadPage {
}
.margin({ top: 15 })
- GlideImage({ glideOption: $glideOption2 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption2 })
}
@@ -301,17 +301,17 @@ struct TestPreloadPage {
Button('预加载本地资源webp')
.onClick(() => {
let request = new RequestOption();
- request.load($r('app.media.webpSample'))
+ request.load($r('app.media.jpgSample'))
.setImageViewSize({ width: 300, height: 300 })
.addListener((err, data) => {
if (err && err.length > 0) {
console.log('预加载本地资源webp 出现错误! err=' + err)
} else {
- console.log('预加载本地资源webp成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载本地资源webp成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
@@ -319,8 +319,8 @@ struct TestPreloadPage {
Button('本地资源webp')
.onClick(() => {
- this.glideOption3 = {
- loadSrc: $r('app.media.webpSample'),
+ this.imageKnifeOption3 = {
+ loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
@@ -346,18 +346,18 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载网络资源webp 出现错误! err=' + err)
} else {
- console.log('预加载网络资源webp成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载网络资源webp成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
Button('网络资源webp')
.onClick(() => {
- this.glideOption3 = {
+ this.imageKnifeOption3 = {
loadSrc: 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -370,7 +370,7 @@ struct TestPreloadPage {
}
.margin({ top: 15 })
- GlideImage({ glideOption: $glideOption3 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption3 })
}
@@ -385,11 +385,11 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载本地资源bmp 出现错误! err=' + err)
} else {
- console.log('预加载本地资源bmp成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载本地资源bmp成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
@@ -397,7 +397,7 @@ struct TestPreloadPage {
Button('本地资源bmp')
.onClick(() => {
- this.glideOption4 = {
+ this.imageKnifeOption4 = {
loadSrc: $r('app.media.bmpSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -424,18 +424,18 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载网络资源bmp 出现错误! err=' + err)
} else {
- console.log('预加载网络资源bmp成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载网络资源bmp成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
Button('网络资源bmp')
.onClick(() => {
- this.glideOption4 = {
+ this.imageKnifeOption4 = {
loadSrc: 'https://img-blog.csdn.net/20140514114029140',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -448,7 +448,7 @@ struct TestPreloadPage {
}
.margin({ top: 15 })
- GlideImage({ glideOption: $glideOption4 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption4 })
}
@@ -463,11 +463,11 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载本地资源png 出现错误! err=' + err)
} else {
- console.log('预加载本地资源png成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载本地资源png成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
@@ -475,7 +475,7 @@ struct TestPreloadPage {
Button('本地资源png')
.onClick(() => {
- this.glideOption5 = {
+ this.imageKnifeOption5 = {
loadSrc: $r('app.media.pngSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -502,18 +502,18 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载网络资源bmp 出现错误! err=' + err)
} else {
- console.log('预加载网络资源bmp成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载网络资源bmp成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
Button('网络资源png')
.onClick(() => {
- this.glideOption5 = {
+ this.imageKnifeOption5 = {
loadSrc: 'https://img-blog.csdnimg.cn/20191215043500229.png',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -526,7 +526,7 @@ struct TestPreloadPage {
}
.margin({ top: 15 })
- GlideImage({ glideOption: $glideOption5 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption5 })
}
@@ -541,11 +541,11 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载本地资源jpg 出现错误! err=' + err)
} else {
- console.log('预加载本地资源jpg成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载本地资源jpg成功! imageKnifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
@@ -553,7 +553,7 @@ struct TestPreloadPage {
Button('本地资源jpg')
.onClick(() => {
- this.glideOption6 = {
+ this.imageKnifeOption6 = {
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -580,18 +580,18 @@ struct TestPreloadPage {
if (err && err.length > 0) {
console.log('预加载网络资源jpg 出现错误! err=' + err)
} else {
- console.log('预加载网络资源jpg成功! glidedata=' + JSON.stringify(data))
+ console.log('预加载网络资源jpg成功! imageknifedata=' + JSON.stringify(data))
}
return false;
})
- Glide.preload(request);
+ ImageKnife.preload(request);
})
.margin({ left: 15 })
.backgroundColor(Color.Grey)
Button('网络资源jpg')
.onClick(() => {
- this.glideOption6 = {
+ this.imageKnifeOption6 = {
loadSrc: 'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.icon_loading'),
@@ -604,7 +604,7 @@ struct TestPreloadPage {
}
.margin({ top: 15 })
- GlideImage({ glideOption: $glideOption6 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption6 })
}
}
@@ -619,4 +619,4 @@ struct TestPreloadPage {
}
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
+var ImageKnife = globalThis.exports.default.data.imageKnife
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/testResourceManagerPage.ets b/entry/src/main/ets/MainAbility/pages/testResourceManagerPage.ets
index bcc42c0..e70cb69 100644
--- a/entry/src/main/ets/MainAbility/pages/testResourceManagerPage.ets
+++ b/entry/src/main/ets/MainAbility/pages/testResourceManagerPage.ets
@@ -12,24 +12,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {RequestOption} from "../glide/RequestOption.ets"
-import{NONE} from "../cache/diskstrategy/enum/NONE"
-import {Base64} from "../cache/Base64.ets"
-import {FileTypeUtil} from "../glide/utils/FileTypeUtil.ets"
-import {GlideData} from "../glide/GlideData.ets"
+import {RequestOption} from '@ohos/imageknife'
+import{NONE} from '@ohos/imageknife'
+import {Base64} from '@ohos/imageknife'
+import {FileTypeUtil} from '@ohos/imageknife'
+import {ImageKnifeData} from '@ohos/imageknife'
import resourceManager from '@ohos.resourceManager';
@Entry
@Component
struct TestResourceManagerPage {
- @State glideData: GlideData = new GlideData();
+ @State imageKnifeData: ImageKnifeData = new ImageKnifeData();
build() {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- Text(this.glideData.glideType)
+ Text(this.imageKnifeData.imageKnifeType)
.fontSize(20)
.backgroundColor(Color.Pink)
.width(300)
@@ -50,10 +50,10 @@ struct TestResourceManagerPage {
let fileTypeUtil = new FileTypeUtil();
let typeValue = fileTypeUtil.getFileType(arrayBuffer);
console.log("typeValue data=" + typeValue)
- let newGlideData = new GlideData();
- newGlideData.glideType = typeValue
+ let newImageKnifeData = new ImageKnifeData();
+ newImageKnifeData.imageKnifeType = typeValue
- this.glideData = newGlideData;
+ this.imageKnifeData = newImageKnifeData;
})
})
@@ -69,9 +69,9 @@ struct TestResourceManagerPage {
let fileTypeUtil = new FileTypeUtil();
let typeValue = fileTypeUtil.getFileType(this.typedArrayToBuffer(data));
console.log("typeValue data=" + typeValue)
- let newGlideData = new GlideData();
- newGlideData.glideType = typeValue
- this.glideData = newGlideData;
+ let newImageKnifeData = new ImageKnifeData();
+ newImageKnifeData.imageKnifeType = typeValue
+ this.imageKnifeData = newImageKnifeData;
})
})
@@ -92,4 +92,4 @@ struct TestResourceManagerPage {
}
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
+var ImageKnife = globalThis.exports.default.data.imageKnife
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/TransformPixelMapPage.ets b/entry/src/main/ets/MainAbility/pages/transformPixelMapPage.ets
similarity index 67%
rename from entry/src/main/ets/MainAbility/pages/TransformPixelMapPage.ets
rename to entry/src/main/ets/MainAbility/pages/transformPixelMapPage.ets
index 88f4730..995e35b 100644
--- a/entry/src/main/ets/MainAbility/pages/TransformPixelMapPage.ets
+++ b/entry/src/main/ets/MainAbility/pages/transformPixelMapPage.ets
@@ -12,30 +12,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {RequestOption} from "../glide/RequestOption.ets"
-import {CropCircleTransformation} from "../glide/transform/CropCircleTransformation.ets"
-import {RoundedCornersTransformation} from "../glide/transform/RoundedCornersTransformation.ets"
-import {CropCircleWithBorderTransformation} from "../glide/transform/CropCircleWithBorderTransformation.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
-import {CropSquareTransformation} from "../glide/transform/CropSquareTransformation.ets"
-import {CropTransformation} from "../glide/transform/CropTransformation.ets"
-import {CropType} from "../glide/transform/CropTransformation"
-import {GrayscaleTransformation} from "../glide/transform/GrayscaleTransformation"
-import {BrightnessFilterTransformation} from "../glide/transform/BrightnessFilterTransformation"
-import {ContrastFilterTransformation} from "../glide/transform/ContrastFilterTransformation"
-import {InvertFilterTransformation} from "../glide/transform/InvertFilterTransformation"
-import {SepiaFilterTransformation} from "../glide/transform/SepiaFilterTransformation"
-import {SketchFilterTransformation} from "../glide/transform/SketchFilterTransformation"
-import {BlurTransformation} from "../glide/transform/BlurTransformation"
-import {PixelationFilterTransformation} from "../glide/transform/PixelationFilterTransformation"
-import {PixelMapPack} from "../glide/PixelMapPack.ets";
+import {RequestOption} from '@ohos/imageknife'
+import {CropCircleTransformation} from '@ohos/imageknife'
+import {RoundedCornersTransformation} from '@ohos/imageknife'
+import {CropCircleWithBorderTransformation} from '@ohos/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation'
+import {RotateImageTransformation} from '@ohos/imageknife'
+import {CropSquareTransformation} from '@ohos/imageknife'
+import {CropTransformation} from '@ohos/imageknife'
+import {CropType} from '@ohos/imageknife'
+import {GrayscaleTransformation} from '@ohos/imageknife'
+import {BrightnessFilterTransformation} from '@ohos/imageknife'
+import {ContrastFilterTransformation} from '@ohos/imageknife'
+import {InvertFilterTransformation} from '@ohos/imageknife'
+import {SepiaFilterTransformation} from '@ohos/imageknife'
+import {SketchFilterTransformation} from '@ohos/imageknife'
+import {BlurTransformation} from '@ohos/imageknife'
+import {PixelationFilterTransformation} from '@ohos/imageknife'
+import {MaskTransformation} from '@ohos/imageknife'
+import {SwirlFilterTransformation} from '@ohos/imageknife'
+import {PixelMapPack} from '@ohos/imageknife'
/**
* PixelMap transform 示例
*/
let mRotate: number = 0;
//let mUrl = "https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB"
-let mUrl = $r('app.media.transformBase');
+let mUrl = $r('app.media.check_big');
@Entry
@Component
@@ -58,6 +60,8 @@ struct TransformPixelMapPage {
@State mSketchPixelMap: PixelMapPack= new PixelMapPack();
@State mBlurPixelMap: PixelMapPack= new PixelMapPack();
@State mPixelPixelMap: PixelMapPack= new PixelMapPack();
+ @State mSwirlPixelMap: PixelMapPack= new PixelMapPack();
+ @State mMaskPixelMap: PixelMapPack= new PixelMapPack();
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) {
@@ -165,9 +169,8 @@ struct TransformPixelMapPage {
this.circleTransformation();
});
Image(this.mCirclePixelMap.pixelMap)
- .objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -184,9 +187,8 @@ struct TransformPixelMapPage {
this.circleBorderTransformation(5);
});
Image(this.mCircleBorderPixelMap.pixelMap)
- .objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -207,9 +209,8 @@ struct TransformPixelMapPage {
this.transformRotate(mRotate);
});
Image(this.mRotatePixelMap.pixelMap)
- .objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -227,8 +228,8 @@ struct TransformPixelMapPage {
});
Image(this.mSquarePixelMap.pixelMap)
.objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -242,7 +243,7 @@ struct TransformPixelMapPage {
.height(35)
.width(72)
.onClick(() => {
- this.clipPixelMap(25,25, CropType.TOP);
+ this.clipPixelMap(25, 25, CropType.TOP);
});
Button() {
Text($r("app.string.trans_clip_center")).fontSize(13).fontColor(Color.White)
@@ -250,7 +251,7 @@ struct TransformPixelMapPage {
.height(35)
.width(72)
.onClick(() => {
- this.clipPixelMap(25,25, CropType.CENTER);
+ this.clipPixelMap(25, 25, CropType.CENTER);
});
Button() {
Text($r("app.string.trans_clip_bottom")).fontSize(13).fontColor(Color.White)
@@ -258,7 +259,7 @@ struct TransformPixelMapPage {
.height(35)
.width(72)
.onClick(() => {
- this.clipPixelMap(25,25, CropType.BOTTOM);
+ this.clipPixelMap(25, 25, CropType.BOTTOM);
});
}.margin({ top: 10 })
@@ -294,8 +295,8 @@ struct TransformPixelMapPage {
});
Image(this.mGrayscalePixelMap.pixelMap)
.objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -312,8 +313,8 @@ struct TransformPixelMapPage {
});
Image(this.mBrightnessPixelMap.pixelMap)
.objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -330,8 +331,8 @@ struct TransformPixelMapPage {
});
Image(this.mContrastPixelMap.pixelMap)
.objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -348,8 +349,8 @@ struct TransformPixelMapPage {
});
Image(this.mInvertPixelMap.pixelMap)
.objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -367,8 +368,8 @@ struct TransformPixelMapPage {
});
Image(this.mSepiaPixelMap.pixelMap)
.objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -385,8 +386,8 @@ struct TransformPixelMapPage {
});
Image(this.mSketchPixelMap.pixelMap)
.objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -404,8 +405,8 @@ struct TransformPixelMapPage {
});
Image(this.mBlurPixelMap.pixelMap)
.objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -424,8 +425,46 @@ struct TransformPixelMapPage {
});
Image(this.mPixelPixelMap.pixelMap)
.objectFit(ImageFit.Fill)
- .width(100)
- .height(100)
+ .width(200)
+ .height(200)
+ .margin({ top: 10 })
+
+ }.margin({ top: 10 });
+
+ Column() {
+ Text("SwirlFilterTransformation").fontColor(Color.Gray).fontSize(16);
+ Button() {
+ Text("图片Swirl").fontSize(13).fontColor(Color.White)
+ }
+ .height(35)
+ .width(120)
+ .margin({ top: 10 })
+ .onClick(() => {
+ this.swirlHandlePixelMap();
+ });
+ Image(this.mSwirlPixelMap.pixelMap)
+ .objectFit(ImageFit.Fill)
+ .width(200)
+ .height(200)
+ .margin({ top: 10 })
+
+ }.margin({ top: 10 });
+
+ Column() {
+ Text("MaskTransformation").fontColor(Color.Gray).fontSize(16);
+ Button() {
+ Text("图片mask").fontSize(13).fontColor(Color.White)
+ }
+ .height(35)
+ .width(120)
+ .margin({ top: 10 })
+ .onClick(() => {
+ this.maskHandlePixelMap($r('app.media.mask_starfish'));
+ });
+ Image(this.mMaskPixelMap.pixelMap)
+ .objectFit(ImageFit.Fill)
+ .width(200)
+ .height(200)
.margin({ top: 10 })
}.margin({ top: 10 });
@@ -440,390 +479,401 @@ struct TransformPixelMapPage {
}
- /**
+/**
* centerCrop
*/
centerCrop() {
- var glideOption = new RequestOption();
- glideOption.load($r('app.media.photo5'))
- // glideOption.load(mUrl)
+ var imageKnifeOption = new RequestOption();
+ imageKnifeOption.load($r('app.media.photo5'))
+ // imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
this.mCropPixelMap = result;
setTimeout(() => {
let result2 = new PixelMapPack();
- result2.pixelMap = data.glideValue as PixelMap;
+ result2.pixelMap = data.imageKnifeValue as PixelMap;
this.mCropPixelMap = result2;
- },100)
+ }, 100)
return false;
})
.setImageViewSize({ width: vp2px(100), height: vp2px(100) })
.skipMemoryCache(true)
.centerCrop();
- Glide.call(glideOption);
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
* centerInside
*/
centerInside() {
- var glideOption = new RequestOption();
- glideOption.load($r('app.media.Back'))
- //glideOption.load(mUrl)
+ var imageKnifeOption = new RequestOption();
+ imageKnifeOption.load($r('app.media.Back'))
.addListener((err, data) => {
let result = new PixelMapPack();
this.mCropPixelMap = result;
setTimeout(() => {
let result2 = new PixelMapPack();
- result2.pixelMap = data.glideValue as PixelMap;
+ result2.pixelMap = data.imageKnifeValue as PixelMap;
this.mCropPixelMap = result2;
- },100)
+ }, 100)
return false;
})
.setImageViewSize({ width: vp2px(100), height: vp2px(100) })
.skipMemoryCache(true)
.centerInside();
- Glide.call(glideOption);
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
* centerInside
*/
fitCenter() {
- var glideOption = new RequestOption()
- glideOption.load($r('app.media.Back'))
- //glideOption.load(mUrl)
+ var imageKnifeOption = new RequestOption()
+ imageKnifeOption.load($r('app.media.Back'))
.addListener((err, data) => {
let result = new PixelMapPack();
this.mCropPixelMap = result;
setTimeout(() => {
let result2 = new PixelMapPack();
- result2.pixelMap = data.glideValue as PixelMap;
+ result2.pixelMap = data.imageKnifeValue as PixelMap;
this.mCropPixelMap = result2;
- },100)
+ }, 100)
return false;
})
.setImageViewSize({ width: vp2px(100), height: vp2px(100) })
.skipMemoryCache(true)
.fitCenter();
- Glide.call(glideOption);
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
* 圆角设置
*/
roundedCornersTransformation(top_left: number,
- bottom_left: number, top_right: number, bottom_right: number) {
+ bottom_left: number, top_right: number, bottom_right: number) {
- var glideOption = new RequestOption();
-
- //glideOption.load($r('app.media.photo5'))
- glideOption.load(mUrl)
+ var imageKnifeOption = new RequestOption();
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
this.mRoundPixelMap = result;
setTimeout(() => {
let result2 = new PixelMapPack();
- result2.pixelMap = data.glideValue as PixelMap;
+ result2.pixelMap = data.imageKnifeValue as PixelMap;
this.mRoundPixelMap = result2;
- },100)
+ }, 100)
return false;
})
.setImageViewSize({ width: vp2px(100), height: vp2px(100) })
.skipMemoryCache(true)
- .transform(new RoundedCornersTransformation({ top_left: top_left, top_right: top_right
- , bottom_left: bottom_left, bottom_right: bottom_right }))
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .roundedCorners({ top_left: top_left, top_right: top_right, bottom_left: bottom_left, bottom_right: bottom_right })
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
* 裁剪圆
*/
circleTransformation() {
- let glideOption = new RequestOption();
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ let imageKnifeOption = new RequestOption();
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mCirclePixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(new CropCircleTransformation())
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .cropCircle()
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
* 圆环裁剪
*/
circleBorderTransformation(border: number) {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var circleTransformation = new CropCircleWithBorderTransformation(border,
{ r_color: 255, g_color: 204, b_color: 204 });
- //glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mCircleBorderPixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(circleTransformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .cropCircleWithBorder(border,
+ { r_color: 255, g_color: 204, b_color: 204 })
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
* 旋转
*/
transformRotate(angled: number) {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new RotateImageTransformation(angled);
- //glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mRotatePixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(transformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .rotateImage(angled)
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
* 正方形裁剪
*/
transformSquare() {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new CropSquareTransformation();
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mSquarePixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(transformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .cropSquare()
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
* 区域裁剪
*/
clipPixelMap(width: number, height: number, cropType: CropType) {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new CropTransformation(width, height, cropType);
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
if (cropType == CropType.TOP) {
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mClipTopPixelMap = result;
} else if (cropType == CropType.CENTER) {
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mClipCenterPixelMap = result;
} else if (cropType == CropType.BOTTOM) {
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mClipBottomPixelMap = result;
}
return false;
})
.setImageViewSize({ width: width, height: height })
.skipMemoryCache(true)
- .transform(transformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .crop(width, height, cropType)
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
* 灰度
*/
grayscalePixelMap() {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new GrayscaleTransformation();
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mGrayscalePixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(transformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .grayscale()
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
*亮度b
*/
brightnessPixelMap(brightness: number) {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new BrightnessFilterTransformation(brightness);
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mBrightnessPixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(transformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .brightnessFilter(brightness)
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
*对比度
*/
contrastPixelMap(contrast: number) {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new ContrastFilterTransformation(contrast);
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mContrastPixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(transformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .contrastFilter(contrast)
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
*反转处理
*/
invertPixelMap() {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new InvertFilterTransformation();
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mInvertPixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(transformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .invertFilter()
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
*照片老旧出来(黑褐色)
*/
sepiaPixelMap() {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new SepiaFilterTransformation();
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mSepiaPixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(transformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .sepiaFilter()
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
*素描
*/
sketchPixelMap() {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new SketchFilterTransformation();
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mSketchPixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(transformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .sketchFilter()
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
*模糊
*/
blurHandlePixelMap(radius: number) {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new BlurTransformation(radius);
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mBlurPixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(transformation)
- // .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ .blur(radius)
+ ImageKnife.call(imageKnifeOption);
}
- /**
+/**
*马赛克
*/
pixelHandlePixelMap(pixel: number) {
- let glideOption = new RequestOption();
+ let imageKnifeOption = new RequestOption();
var transformation = new PixelationFilterTransformation(pixel);
- // glideOption.load($r('app.media.photo6'))
- glideOption.load(mUrl)
+ imageKnifeOption.load(mUrl)
.addListener((err, data) => {
let result = new PixelMapPack();
- result.pixelMap=data.glideValue as PixelMap;
+ result.pixelMap = data.imageKnifeValue as PixelMap;
this.mPixelPixelMap = result;
return false;
})
- .setImageViewSize({ width: vp2px(100), height: vp2px(100) })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
.skipMemoryCache(true)
- .transform(transformation)
+ .pixelationFilter(pixel)
+ ImageKnife.call(imageKnifeOption);
+
+ }
+
+/**
+ *扭曲
+ */
+ swirlHandlePixelMap() {
+ let imageKnifeOption = new RequestOption();
+ var transformation = new SwirlFilterTransformation(80);
+ imageKnifeOption.load(mUrl)
+ .addListener((err, data) => {
+ let result = new PixelMapPack();
+ result.pixelMap = data.imageKnifeValue as PixelMap;
+ this.mSwirlPixelMap = result;
+ return false;
+ })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
+ .skipMemoryCache(true)
+ .swirlFilter(80)
// .diskCacheStrategy(new NONE())
- Glide.call(glideOption);
+ ImageKnife.call(imageKnifeOption);
+
+ }
+/**
+ *遮罩
+ */
+ maskHandlePixelMap(maskResource: Resource) {
+ let imageKnifeOption = new RequestOption();
+ var transformation = new MaskTransformation(maskResource);
+ // imageKnifeOption.load($r('app.media.photo6'))
+ imageKnifeOption.load(mUrl)
+ .addListener((err, data) => {
+ let result = new PixelMapPack();
+ result.pixelMap = data.imageKnifeValue as PixelMap;
+ this.mMaskPixelMap = result;
+ return false;
+ })
+ .setImageViewSize({ width: vp2px(200), height: vp2px(200) })
+ .skipMemoryCache(true)
+ .mask(maskResource)
+ // .diskCacheStrategy(new NONE())
+ ImageKnife.call(imageKnifeOption);
}
}
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
+var ImageKnife = globalThis.exports.default.data.imageKnife
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/pages/transformTestCasePage.ets b/entry/src/main/ets/MainAbility/pages/transformTestCasePage.ets
index 150deae..5f73e41 100644
--- a/entry/src/main/ets/MainAbility/pages/transformTestCasePage.ets
+++ b/entry/src/main/ets/MainAbility/pages/transformTestCasePage.ets
@@ -12,63 +12,77 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {GlideImage} from "../glide/GlideImage.ets"
-import {GlideOption} from "../glide/GlideOption.ets"
-import {RotateImageTransformation} from "../glide/transform/RotateImageTransformation.ets"
-import {RoundedCornersTransformation} from "../glide/transform/RoundedCornersTransformation.ets"
+import {ImageKnifeComponent} from '@ohos/imageknife'
+import {ImageKnifeOption} from '@ohos/imageknife'
+import {RotateImageTransformation} from '@ohos/imageknife'
+import {RoundedCornersTransformation} from '@ohos/imageknife'
+import {TransformType} from '@ohos/imageknife'
@Entry
@Component
struct Index {
- @State glideOption1: GlideOption =
+ @State imageKnifeOption1: ImageKnifeOption =
{
loadSrc: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ericA1Mv66TwicuYOtbDMBcUhv1aa9RJBeAn9uURfcZD0AUGrJebAn1g2AjN0vb2E1XTET7fTuLBNmA/132",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.Tomato'),
errorholderSrc: $r('app.media.picture1'),
- transformtions: [new RotateImageTransformation(180)]
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:180
+ }
};
- @State glideOption2: GlideOption =
+ @State imageKnifeOption2: ImageKnifeOption =
{
loadSrc: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83ericA1Mv66TwicuYOtbDMBcUhv1aa9RJBeAn9uURfcZD0AUGrJebAn1g2AjN0vb2E1XTET7fTuLBNmA/132",
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.Tomato'),
errorholderSrc: $r('app.media.picture1'),
- transformtions: [new RoundedCornersTransformation({
- top_left: 30,
- top_right: 30,
- bottom_left: 30,
- bottom_right: 30
- })]
+ transform: {
+ transformType:TransformType.RoundedCornersTransformation,
+ roundedCorners:{
+ top_left: 30,
+ top_right: 30,
+ bottom_left: 30,
+ bottom_right: 30
+ }
+ }
+
};
- @State glideOption3: GlideOption =
+ @State imageKnifeOption3: ImageKnifeOption =
{
loadSrc: $r('app.media.pngSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.Tomato'),
errorholderSrc: $r('app.media.picture1'),
- transformtions: [new RotateImageTransformation(180)]
+ transform: {
+ transformType:TransformType.RotateImageTransformation,
+ rotateImage:180
+ }
};
- @State glideOption4: GlideOption =
+ @State imageKnifeOption4: ImageKnifeOption =
{
loadSrc: $r('app.media.jpgSample'),
size: { width: 300, height: 300 },
placeholderSrc: $r('app.media.Tomato'),
errorholderSrc: $r('app.media.picture1'),
- transformtions: [new RoundedCornersTransformation({
- top_left: 130,
- top_right: 130,
- bottom_left: 130,
- bottom_right: 130
- })]
+ transform: {
+ transformType:TransformType.RoundedCornersTransformation,
+ roundedCorners:{
+ top_left: 130,
+ top_right: 130,
+ bottom_left: 130,
+ bottom_right: 130
+ }
+ }
};
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- GlideImage({ glideOption: $glideOption1 })
- GlideImage({ glideOption: $glideOption2 })
- GlideImage({ glideOption: $glideOption3 })
- GlideImage({ glideOption: $glideOption4 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption2 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption3 })
+ ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption4 })
}
.width('100%')
.height('100%')
@@ -80,4 +94,3 @@ struct Index {
}
-var Glide = globalThis.exports.default.data.glide
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/workers/worker1.js b/entry/src/main/ets/MainAbility/workers/worker1.js
index f692c34..76dc412 100644
--- a/entry/src/main/ets/MainAbility/workers/worker1.js
+++ b/entry/src/main/ets/MainAbility/workers/worker1.js
@@ -13,25 +13,9 @@
* limitations under the License.
*/
import arkWorker from '@ohos.worker';
+import {handler} from '@ohos/imageknife/src/main/ets/components/imageknife/pngj/PngWork'
+
+arkWorker.parentPort.onmessage = handler
-arkWorker.parentPort.onmessage = function (e) {
- var data = e.data;
- switch (data.type) {
- case 'normal':
- arkWorker.parentPort.postMessage(data);
- break;
- case 'error':
- throw new Error('123');
- break;
- case 'buffer':
- let uint8Array = new Uint8Array(data.data);
- arkWorker.parentPort.postMessage(data, [data.data]);
-
- break;
- default:
-
- break
- }
-}
diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json
index 012fb52..e847707 100644
--- a/entry/src/main/resources/base/element/string.json
+++ b/entry/src/main/resources/base/element/string.json
@@ -1,8 +1,8 @@
{
"string": [
{
- "name": "GlideJS_OHOS",
- "value": "GlideJS_OHOS"
+ "name": "ImageKnife_OHOS",
+ "value": "ImageKnife_OHOS"
},
{
"name": "mainability_description",
diff --git a/entry/src/main/resources/base/media/abc.PNG b/entry/src/main/resources/base/media/abc.PNG
deleted file mode 100644
index 3e7f10f..0000000
Binary files a/entry/src/main/resources/base/media/abc.PNG and /dev/null differ
diff --git a/entry/src/main/resources/base/media/mask_starfish.png b/entry/src/main/resources/base/media/mask_starfish.png
new file mode 100644
index 0000000..3cb4bcc
Binary files /dev/null and b/entry/src/main/resources/base/media/mask_starfish.png differ
diff --git a/entry/src/main/resources/base/media/webpNet.webp b/entry/src/main/resources/base/media/webpNet.webp
deleted file mode 100644
index bcf109c..0000000
Binary files a/entry/src/main/resources/base/media/webpNet.webp and /dev/null differ
diff --git a/entry/src/main/resources/base/media/webpSample.webp b/entry/src/main/resources/base/media/webpSample.webp
deleted file mode 100644
index bcf109c..0000000
Binary files a/entry/src/main/resources/base/media/webpSample.webp and /dev/null differ
diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json
new file mode 100644
index 0000000..b97e860
--- /dev/null
+++ b/entry/src/ohosTest/config.json
@@ -0,0 +1,68 @@
+{
+ "app": {
+ "bundleName": "com.example.imageknifegiteepro",
+ "vendor": "example",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.example.entry_test",
+ "name": ".entry_test",
+ "mainAbility": ".TestAbility",
+ "srcPath": "",
+ "deviceType": [
+ "phone",
+ "tablet"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry_test",
+ "moduleType": "feature",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "visible": true,
+ "srcPath": "TestAbility",
+ "name": ".TestAbility",
+ "srcLanguage": "ets",
+ "icon": "$media:icon",
+ "description": "$string:description_TestAbility",
+ "formsEnabled": false,
+ "label": "$string:entry_TestAbility",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ],
+ "js": [
+ {
+ "mode": {
+ "syntax": "ets",
+ "type": "pageAbility"
+ },
+ "pages": [
+ "pages/index"
+ ],
+ "name": ".TestAbility",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/MainAbility/app.ets b/entry/src/ohosTest/ets/MainAbility/app.ets
deleted file mode 100644
index 8658c07..0000000
--- a/entry/src/ohosTest/ets/MainAbility/app.ets
+++ /dev/null
@@ -1,11 +0,0 @@
-export default {
- onCreate() {
- console.info('Application onCreate')
- },
- onShow() {
- console.info('Application onShow')
- },
- onDestroy() {
- console.info('Application onDestroy')
- },
-}
diff --git a/entry/src/ohosTest/ets/MainAbility/i18n/en-US.json b/entry/src/ohosTest/ets/MainAbility/i18n/en-US.json
deleted file mode 100644
index 55561b8..0000000
--- a/entry/src/ohosTest/ets/MainAbility/i18n/en-US.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "strings": {
- "hello": "Hello",
- "world": "World"
- },
- "Files": {
- }
-}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/MainAbility/i18n/zh-CN.json b/entry/src/ohosTest/ets/MainAbility/i18n/zh-CN.json
deleted file mode 100644
index cce1af0..0000000
--- a/entry/src/ohosTest/ets/MainAbility/i18n/zh-CN.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "strings": {
- "hello": "您好",
- "world": "世界"
- },
- "Files": {
- }
-}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/MainAbility/pages/index/index.ets b/entry/src/ohosTest/ets/MainAbility/pages/index/index.ets
deleted file mode 100644
index dc65e41..0000000
--- a/entry/src/ohosTest/ets/MainAbility/pages/index/index.ets
+++ /dev/null
@@ -1,51 +0,0 @@
-import {Core, ExpectExtend, InstrumentLog} from "deccjsunit/index"
-import testsuite from "../../../test/List.test.ets"
-import app from '@system.app'
-import featureAbility from "@ohos.ability.featureAbility"
-
-@Entry
-@Component
-struct MyComponent {
- aboutToAppear() {
- console.info("start run testcase!!!!")
- featureAbility.getWant()
- .then((Want) => {
- const core = Core.getInstance()
- const instrumentLog = new InstrumentLog({
- 'id': 'report', 'unity': 'true'
- })
- const expectExtend = new ExpectExtend({
- 'id': 'extend'
- })
- core.addService('expect', expectExtend)
- core.addService('report', instrumentLog)
- core.init()
- core.subscribeEvent('spec', instrumentLog)
- core.subscribeEvent('suite', instrumentLog)
- core.subscribeEvent('task', instrumentLog)
- const configService = core.getDefaultService('config')
- configService.setConfig(Want.parameters)
- testsuite()
- core.execute()
- console.info('Operation successful. Data: ' + JSON.stringify(Want));
- })
- .catch((error) => {
- console.error('Operation failed. Cause: ' + JSON.stringify(error));
- })
- }
-
- build() {
- Flex({
- direction: FlexDirection.Column,
- alignItems: ItemAlign.Center,
- justifyContent: FlexAlign.Center
- }) {
- Text('Hello World')
- .fontSize(50)
- .fontWeight(FontWeight.Bold)
- }
- .width('100%')
- .height('100%')
- }
-}
-
diff --git a/entry/src/ohosTest/ets/TestAbility/app.ets b/entry/src/ohosTest/ets/TestAbility/app.ets
new file mode 100644
index 0000000..bc4d7e2
--- /dev/null
+++ b/entry/src/ohosTest/ets/TestAbility/app.ets
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+import { Hypium } from 'hypium/index'
+import testsuite from '../test/List.test'
+
+export default {
+ onCreate() {
+ console.info('Application onCreate')
+ var abilityDelegator: any
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+ var abilityDelegatorArguments: any
+ abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ console.info('start run testcase!!!')
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
+ },
+ onDestroy() {
+ console.info('Application onDestroy')
+ },
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/TestAbility/pages/index.ets b/entry/src/ohosTest/ets/TestAbility/pages/index.ets
new file mode 100644
index 0000000..df4ccb0
--- /dev/null
+++ b/entry/src/ohosTest/ets/TestAbility/pages/index.ets
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import router from '@system.router';
+
+@Entry
+@Component
+struct Index {
+ aboutToAppear() {
+ console.info('TestAbility index aboutToAppear')
+ }
+
+ @State message: string = 'Hello World'
+ build() {
+ Row() {
+ Column() {
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ Button() {
+ Text('next page')
+ .fontSize(20)
+ .fontWeight(FontWeight.Bold)
+ }.type(ButtonType.Capsule)
+ .margin({
+ top: 20
+ })
+ .backgroundColor('#0D9FFB')
+ .width('35%')
+ .height('5%')
+ .onClick(()=>{
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+ }
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts
new file mode 100644
index 0000000..d1fb5ea
--- /dev/null
+++ b/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import TestRunner from '@ohos.application.testRunner'
+import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+
+var abilityDelegator = undefined
+var abilityDelegatorArguments = undefined
+
+function translateParamsToString(parameters) {
+ const keySet = new Set([
+ '-s class', '-s notClass', '-s suite', '-s itName',
+ '-s level', '-s testType', '-s size', '-s timeout',
+ '-s package'
+ ])
+ let targetParams = '';
+ for (const key in parameters) {
+ if (keySet.has(key)) {
+ targetParams += ' ' + key + ' ' + parameters[key]
+ }
+ }
+ return targetParams.trim()
+}
+
+async function onAbilityCreateCallback() {
+ console.log('onAbilityCreateCallback');
+}
+
+async function addAbilityMonitorCallback(err: any) {
+ console.info('addAbilityMonitorCallback : ' + JSON.stringify(err))
+}
+
+export default class OpenHarmonyTestRunner implements TestRunner {
+ constructor() {
+ }
+
+ onPrepare() {
+ console.info('OpenHarmonyTestRunner OnPrepare')
+ }
+
+ onRun() {
+ console.log('OpenHarmonyTestRunner onRun run')
+ abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+
+ let lMonitor = {
+ abilityName: testAbilityName,
+ onAbilityCreate: onAbilityCreateCallback,
+ };
+ var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
+ abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
+ var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
+ cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
+ console.info('cmd : '+cmd)
+ abilityDelegator.executeShellCommand(cmd,
+ (err: any, d: any) => {
+ console.info('executeShellCommand : err : ' + JSON.stringify(err));
+ console.info('executeShellCommand : data : ' + d.stdResult);
+ console.info('executeShellCommand : data : ' + d.exitCode);
+ })
+ console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext')
+ var context = abilityDelegator.getAppContext()
+ console.info('getAppContext : ' + JSON.stringify(context))
+ console.info('OpenHarmonyTestRunner onRun end')
+ }
+};
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/Ability.test.ets b/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000..eb9e0b6
--- /dev/null
+++ b/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', function () {
+ it('assertContain',0, function () {
+ console.info("it begin")
+ let a = 'abc'
+ let b = 'b'
+ expect(a).assertContain(b)
+ expect(a).assertEqual(a)
+ })
+ })
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/ExampleJsunit.test.ets b/entry/src/ohosTest/ets/test/ExampleJsunit.test.ets
deleted file mode 100644
index 2438a8a..0000000
--- a/entry/src/ohosTest/ets/test/ExampleJsunit.test.ets
+++ /dev/null
@@ -1,14 +0,0 @@
-import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
-import app from '@system.app'
-
-export default function exampleJsunit() {
- describe('appInfoTest', function () {
- it('app_info_test_001', 0, function () {
- var info = app.getInfo()
- expect("1.0")
- .assertEqual('1.0')
- expect(info.versionCode)
- .assertEqual('3')
- })
- })
-}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/GlideJSTest.test.ets b/entry/src/ohosTest/ets/test/GlideJSTest.test.ets
deleted file mode 100644
index 80a8be3..0000000
--- a/entry/src/ohosTest/ets/test/GlideJSTest.test.ets
+++ /dev/null
@@ -1,229 +0,0 @@
-import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
-import featureability from '@ohos.ability.featureAbility'
-import {Glide} from '../../../main/ets/default/glide/Glide.ets'
-import {GlideData} from '../../../main/ets/default/glide/GlideData.ets'
-import {LruCache} from '../../../main/ets/default/cache/LruCache'
-import {DiskLruCache} from '../../../main/ets/default/cache/DiskLruCache'
-import {AsyncCallback} from "../../../main/ets/default/glide/interface/asynccallback.ets"
-import dataStorage from '@ohos.data.storage';
-import {FileUtils} from '../../../main/ets/default/cache/FileUtils'
-import {TransformUtils} from '../../../main/ets/default/glide/transform/TransformUtils.ets'
-import resmgr from '@ohos.resourceManager'
-import {ColorUtils} from "../../../main/ets/default/glide/utils/ColorUtils.ets";
-import {DataCallBack} from "../../../main/ets/default/glide/interface/DataCallBack.ets";
-
-
-export default function glidejsRootJsunit() {
-
- describe('GlideJSTest', function () {
- let filePath = '/data/data/com.huawei.mydemoall/files'
- let cachePath = '/data/data/com.huawei.mydemoall/cache'
-
- let GlideSingleton;
- beforeAll(function () {
- GlideSingleton = Glide.with();
- });
-
- it('glidejs_test_001', 0, function () {
- expect(GlideSingleton != null && GlideSingleton != undefined).assertEqual(true)
- })
-
- // 替换MemoryCache
- it('glidejs_glide_test_001', 0, function () {
- expect(GlideSingleton.getMemoryCache()
- .maxsize).assertEqual(100)
- GlideSingleton.setMemoryCache(new LruCache(200))
- expect(GlideSingleton.getMemoryCache()
- .maxsize).assertEqual(200)
- })
-
- // 替换DiskLruCache
- it('glidejs_glide_test_002', 0, function () {
- expect(GlideSingleton.getDiskMemoryCache()
- .maxsize).assertEqual(30 * 1024 * 1024)
- GlideSingleton.setDiskMemoryCache(new DiskLruCache(40 * 1024 * 1024))
- expect(GlideSingleton.getDiskMemoryCache()
- .maxsize).assertEqual(40 * 1024 * 1024)
- })
-
- // 替换svgAndGifFolder
- it('glidejs_glide_test_003', 0, function () {
- expect(GlideSingleton.getSvgAndGifFolder()).assertEqual("svgAndGifFolder")
- GlideSingleton.setSvgAndGifFolder("renameFolder")
- expect(GlideSingleton.getSvgAndGifFolder()).assertEqual("renameFolder")
- })
-
- // 替换defaultListener
- it('glidejs_glide_test_004', 0, function () {
- expect(GlideSingleton.getDefaultListener() != null && GlideSingleton.getDefaultListener() != undefined)
- .assertEqual(false)
- GlideSingleton.setDefaultListener((err, glideData: GlideData) => {
- // watch callback
- })
- expect(GlideSingleton.getDefaultListener() != null && GlideSingleton.getDefaultListener() != undefined)
- .assertEqual(true)
- })
-
- // fileutils createFile
- it('glidejs_file_utils_test_001', 0, function () {
- let fd = FileUtils.getInstance().createFile(this.filePath + "temp1.txt")
- expect(fd > 0).assertEqual(true)
- })
-
- // fileutils clearFile
- it('glidejs_file_utils_test_002', 0, function () {
- let fd = FileUtils.getInstance().clearFile(this.filePath + "temp1.txt")
- expect(fd > 0).assertEqual(true)
- })
-
- // fileutils exist
- it('glidejs_file_utils_test_003', 0, function () {
- let result = FileUtils.getInstance().exist(this.filePath + "temp1.txt")
- expect(result).assertEqual(true)
- })
-
- // fileutils getFileSize
- it('glidejs_file_utils_test_004', 0, function () {
- let size = FileUtils.getInstance().getFileSize(this.filePath + "temp1.txt")
- expect(size).assertEqual(0)
- })
-
- // fileutils existFolder
- it('glidejs_file_utils_test_005', 0, function () {
- let result = FileUtils.getInstance().existFolder(this.filePath)
- expect(result).assertEqual(true)
- })
-
- // fileutils stringToUint8Array
- it('glidejs_file_utils_test_006', 0, function () {
- let result = FileUtils.getInstance().stringToUint8Array("A")
- expect(result[0]).assertEqual(65)
- })
-
- // fileutils stringToUint8Array
- it('glidejs_file_utils_test_007', 0, function () {
- let uint8array = FileUtils.getInstance().stringToUint8Array("A")
- let result = FileUtils.getInstance().uint8ArrayToBuffer(uint8array)
- expect(result[0]).assertEqual(65)
- })
-
- // LruCache get
- it('glidejs_lrucache_test_001', 0, function () {
- let lruCache = new LruCache(5)
- lruCache.put("1", 1);
- lruCache.put("2", 2);
- lruCache.put("3", 3);
- lruCache.put("4", 4);
- lruCache.put("5", 5);
- expect(lruCache.get("1")).assertEqual(1)
- })
-
- // LruCache resize maxsize trimToSize
- it('glidejs_lrucache_test_002', 0, function () {
- let lruCache = new LruCache(5)
- lruCache.put("1", 1);
- lruCache.put("2", 2);
- lruCache.put("3", 3);
- lruCache.put("4", 4);
- lruCache.put("5", 5);
- lruCache.get("1")
- lruCache.resize(4)
- expect(lruCache.maxSize()).assertEqual(4)
- expect(lruCache.get("2") == undefined).assertEqual(true)
- })
-
- // DiskLruCache putCacheData getCacheDataByKey
- it('glidejs_disklrucache_test_001', 0, function () {
- let diskLruCache = new DiskLruCache(40 * 1024 * 1024)
- let uint8Array = new Uint8Array([1,2,3,4])
- let arraybuffer = FileUtils.getInstance().uint8ArrayToBuffer(uint8Array);
- diskLruCache.putCacheData("1",arraybuffer,null)
- let getValue = diskLruCache.getCacheDataByKey("1")
-
- let uint8GetValue = new Uint8Array(getValue);
- expect(uint8Array[0]).assertEqual(1)
- expect(uint8Array[1]).assertEqual(2)
- expect(uint8Array[2]).assertEqual(3)
- expect(uint8Array[3]).assertEqual(4)
- })
-
- // DiskLruCache cleanCacheData
- it('glidejs_disklrucache_test_002', 0, function () {
- let diskLruCache = new DiskLruCache(40 * 1024 * 1024)
- let uint8Array = new Uint8Array([1,2,3,4])
- let arraybuffer = FileUtils.getInstance().uint8ArrayToBuffer(uint8Array);
- diskLruCache.putCacheData("1",arraybuffer,null)
- diskLruCache.cleanCacheData();
- let getValue = diskLruCache.getCacheDataByKey("1")
- expect(getValue==null).assertEqual(true)
- })
-
- // DiskLruCache getCacheFileByKey
- it('glidejs_disklrucache_test_003', 0, function () {
- let diskLruCache = new DiskLruCache(40 * 1024 * 1024)
- let uint8Array = new Uint8Array([1,2,3,4])
- let arraybuffer = FileUtils.getInstance().uint8ArrayToBuffer(uint8Array);
- diskLruCache.putCacheData("1",arraybuffer,null)
- let path = diskLruCache.getCacheFileByKey("1");
- expect(path!=null).assertEqual(true)
- })
-
- // DiskLruCache setMaxSize
- it('glidejs_disklrucache_test_004', 0, function () {
- let diskLruCache = new DiskLruCache(40 * 1024 * 1024)
- diskLruCache.setMaxSize(20 * 1024 * 1024)
- expect(diskLruCache.maxSize==(20 * 1024 * 1024)).assertEqual(true)
- })
-
-
- // DiskLruCache deleteCacheDataBykey
- it('glidejs_disklrucache_test_005', 0, function () {
- let diskLruCache = new DiskLruCache(40 * 1024 * 1024)
- let uint8Array = new Uint8Array([1,2,3,4])
- let arraybuffer = FileUtils.getInstance().uint8ArrayToBuffer(uint8Array);
- diskLruCache.putCacheData("1",arraybuffer,null)
- diskLruCache.deleteCacheDataBykey("1");
- let value = diskLruCache.getCacheDataByKey("1")
- expect(value == null).assertEqual(true)
- })
-
- //pngj
- it('glidejs_pngj_test_001', 0, function () {
- let pngj = new Pngj();
- let uint8Array = new Uint8Array([1,2,3,4])
- let inputArray = FileUtils.getInstance().uint8ArrayToBuffer(uint8Array);
- pngj.writePng(inputArray,(buffer1)=>{
- let uint8array1 = new Uint8Array(buffer1);
- let pngj1length = uint8array1.byteLength;
- pngj.writePngWithString("hello",inputArray,(buffer2)=>{
- let uint8array2 = new Uint8Array(buffer2);
- let pngj2length = uint8array2.byteLength;
- expect(pngj2length > pngj1length).assertEqual(true)
- });
- });
- })
-
-
- it('glidejs_color_test_01', 0, function () {
- let call: DataCallBack = {
- callback(data: string) {
- expect(data != null).assertEqual(true)
- }
- }
- ColorUtils.parseColor("test_color", call);
- })
-
- it('glidejs_color_test_02', 0, function () {
- expect(ColorUtils.red(1325455) == ((1325455 >> 16) & 0xFF)).assertEqual(true);
- })
- it('glidejs_color_test_03', 0, function () {
- expect(ColorUtils.blue(1325455) == (1325455 & 0xFF)).assertEqual(true);
- })
- it('glidejs_color_test_04', 0, function () {
- expect(ColorUtils.green(1325455) == ((1325455 >> 8) & 0xFF)).assertEqual(true);
- })
- it('glidejs_color_test_05', 0, function () {
- expect(ColorUtils.rgb(25, 123, 150) == (0xff000000 | (25 << 16) | (123 << 8) | 150)).assertEqual(true);
- })
- })
-}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets
index 00198c5..760f2aa 100644
--- a/entry/src/ohosTest/ets/test/List.test.ets
+++ b/entry/src/ohosTest/ets/test/List.test.ets
@@ -1,5 +1,19 @@
-import exampleJsunit from "../test/ExampleJsunit.test.ets"
-import GlideJSTest from '../test/GlideJSTest.test.ets'
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import abilityTest from './Ability.test'
+
export default function testsuite() {
- GlideJSTest()
+ abilityTest()
}
\ No newline at end of file
diff --git a/entry/src/ohosTest/resources/base/element/string.json b/entry/src/ohosTest/resources/base/element/string.json
index 1c1522b..a0901cf 100644
--- a/entry/src/ohosTest/resources/base/element/string.json
+++ b/entry/src/ohosTest/resources/base/element/string.json
@@ -1,12 +1,12 @@
{
"string": [
{
- "name": "app_name",
- "value": "GlideJSCache"
+ "name": "description_TestAbility",
+ "value": "eTS_Empty Ability"
},
{
- "name": "mainability_description",
- "value": "hap sample empty page"
+ "name": "entry_TestAbility",
+ "value": "entry_TestAbility"
}
]
-}
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
deleted file mode 100644
index be49249..0000000
--- a/gradle.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-# Project-wide Gradle settings.
-# IDE (e.g. DevEco Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-# If the Chinese output is garbled, please configure the following parameter.
-# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false.
-# more information see https://docs.gradle.org/current/userguide/performance.html
-# org.gradle.parallel=false
-# org.gradle.jvmargs=-Dfile.encoding=GBK
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 490fda8..0000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 63c817f..0000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-7.3-bin.zip
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
deleted file mode 100644
index 2fe81a7..0000000
--- a/gradlew
+++ /dev/null
@@ -1,183 +0,0 @@
-#!/usr/bin/env sh
-
-#
-# Copyright 2015 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=`expr $i + 1`
- done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
deleted file mode 100644
index 62bd9b9..0000000
--- a/gradlew.bat
+++ /dev/null
@@ -1,103 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/hvigorfile.js b/hvigorfile.js
new file mode 100644
index 0000000..cff9f0d
--- /dev/null
+++ b/hvigorfile.js
@@ -0,0 +1,2 @@
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+module.exports = require('@ohos/hvigor-ohos-plugin').legacyAppTasks
\ No newline at end of file
diff --git a/imageknife/.gitignore b/imageknife/.gitignore
new file mode 100644
index 0000000..4f9a973
--- /dev/null
+++ b/imageknife/.gitignore
@@ -0,0 +1,3 @@
+/node_modules
+/.preview
+/build
\ No newline at end of file
diff --git a/imageknife/build-profile.json5 b/imageknife/build-profile.json5
new file mode 100644
index 0000000..107d8c7
--- /dev/null
+++ b/imageknife/build-profile.json5
@@ -0,0 +1,5 @@
+{
+ "apiType": "faMode",
+ "buildOption": {
+ }
+}
diff --git a/imageknife/hvigorfile.js b/imageknife/hvigorfile.js
new file mode 100644
index 0000000..3a7c40c
--- /dev/null
+++ b/imageknife/hvigorfile.js
@@ -0,0 +1,3 @@
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+module.exports = require('@ohos/hvigor-ohos-plugin').legacyHarTasks
+
diff --git a/imageknife/index.ets b/imageknife/index.ets
new file mode 100644
index 0000000..035217e
--- /dev/null
+++ b/imageknife/index.ets
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http:// www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * cache
+ */
+
+export * from './src/main/ets/components/cache/FileUtils'
+export * from './src/main/ets/components/cache/Md5'
+export * from './src/main/ets/components/cache/Base64'
+export * from './src/main/ets/components/cache/LruCache'
+export * from './src/main/ets/components/cache/DiskLruCache'
+export * from './src/main/ets/components/cache/diskstrategy/enum/ALL'
+export * from './src/main/ets/components/cache/diskstrategy/enum/AUTOMATIC'
+export * from './src/main/ets/components/cache/diskstrategy/enum/DATA'
+export * from './src/main/ets/components/cache/diskstrategy/enum/NONE'
+export * from './src/main/ets/components/cache/diskstrategy/enum/RESOURCE'
+
+/**
+ * compress
+ */
+export * from './src/main/ets/components/imageknife/compress/CompressBuilder'
+export * from './src/main/ets/components/imageknife/compress/listener/OnCompressListener'
+export * from './src/main/ets/components/imageknife/compress/listener/OnRenameListener'
+export * from './src/main/ets/components/imageknife/compress/listener/CompressDataListener'
+export * from './src/main/ets/components/imageknife/compress/listener/CompressionPredicate'
+export * from './src/main/ets/components/imageknife/compress/provider/CompressAdapter'
+export * from './src/main/ets/components/imageknife/compress/provider/CompressProvider'
+export * from './src/main/ets/components/imageknife/compress/provider/DataStringPathProvider'
+export * from './src/main/ets/components/imageknife/compress/provider/RecourseProvider'
+
+/**
+ * crop
+ */
+export * from './src/main/ets/components/imageknife/crop/Crop'
+export * from './src/main/ets/components/imageknife/crop/CropImage'
+export * from './src/main/ets/components/imageknife/crop/CropOptions'
+
+/**
+ * transform
+ */
+export * from './src/main/ets/components/imageknife/transform/BaseTransform'
+export * from './src/main/ets/components/imageknife/transform/BlurTransformation'
+export * from './src/main/ets/components/imageknife/transform/BrightnessFilterTransformation'
+export * from './src/main/ets/components/imageknife/transform/ContrastFilterTransformation'
+export * from './src/main/ets/components/imageknife/transform/CropCircleTransformation'
+export * from './src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation'
+export * from './src/main/ets/components/imageknife/transform/CropSquareTransformation'
+export * from './src/main/ets/components/imageknife/transform/CropTransformation'
+export * from './src/main/ets/components/imageknife/transform/GrayscaleTransformation'
+export * from './src/main/ets/components/imageknife/transform/InvertFilterTransformation'
+export * from './src/main/ets/components/imageknife/transform/PixelationFilterTransformation'
+export * from './src/main/ets/components/imageknife/transform/RotateImageTransformation'
+export * from './src/main/ets/components/imageknife/transform/RoundedCornersTransformation'
+export * from './src/main/ets/components/imageknife/transform/SepiaFilterTransformation'
+export * from './src/main/ets/components/imageknife/transform/SketchFilterTransformation'
+export * from './src/main/ets/components/imageknife/transform/MaskTransformation'
+export * from './src/main/ets/components/imageknife/transform/SwirlFilterTransformation'
+export * from './src/main/ets/components/imageknife/transform/TransformUtils'
+export * from './src/main/ets/components/imageknife/transform/TransformType'
+export * from './src/main/ets/components/imageknife/transform/pixelmap/CenterCrop'
+export * from './src/main/ets/components/imageknife/transform/pixelmap/CenterInside'
+export * from './src/main/ets/components/imageknife/transform/pixelmap/FitCenter'
+
+/**
+ * pngj
+ */
+export * from './src/main/ets/components/imageknife/pngj/Pngj'
+export {handler} from './src/main/ets/components/imageknife/pngj/PngWork'
+export * from './src/main/ets/components/imageknife/pngj/UPNG'
+
+/**
+ * ImageKnife
+ */
+export * from './src/main/ets/components/imageknife/ImageKnife'
+export * from './src/main/ets/components/imageknife/RequestOption'
+export * from './src/main/ets/components/imageknife/ImageKnifeComponent'
+export * from './src/main/ets/components/imageknife/ImageKnifeOption'
+export * from './src/main/ets/components/imageknife/ImageKnifeData'
+export * from './src/main/ets/components/imageknife/PixelMapPack'
+export * from './src/main/ets/components/imageknife/interface/IAllCacheInfoCallback'
+export * from './src/main/ets/components/imageknife/interface/IParseImage'
+export * from './src/main/ets/components/imageknife/networkmanage/IDataFetch'
+export * from './src/main/ets/components/imageknife/requestmanage/ICache'
+export * from './src/main/ets/components/imageknife/utils/FileTypeUtil'
+export * from './src/main/ets/components/imageknife/utils/ParseImageUtil'
+
diff --git a/imageknife/package-lock.json b/imageknife/package-lock.json
new file mode 100644
index 0000000..9209c18
--- /dev/null
+++ b/imageknife/package-lock.json
@@ -0,0 +1,13 @@
+{
+ "name": "@ohos/imageknife",
+ "version": "1.0.1",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "pako": {
+ "version": "1.0.11",
+ "resolved": "http://mirrors.tools.huawei.com/npm/pako/-/pako-1.0.11.tgz",
+ "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
+ }
+ }
+}
diff --git a/imageknife/package.json b/imageknife/package.json
new file mode 100644
index 0000000..ed58448
--- /dev/null
+++ b/imageknife/package.json
@@ -0,0 +1,25 @@
+{
+ "types": "",
+ "keywords": [
+ "openharmony",
+ "imageknife"
+ ],
+ "author": "ohos_tpc",
+ "description": "专门为OpenHarmony打造的一款图像加载缓存库,致力于更高效、更轻便、更简单",
+ "ohos": {
+ "org": "opensource"
+ },
+ "main": "index.ets",
+ "repository": "https://gitee.com/openharmony-tpc/imageknife.git",
+ "version": "1.0.1",
+ "dependencies": {
+ "pako": "^1.0.5"
+ },
+ "tags": [
+ "openharmony",
+ "imageknife"
+ ],
+ "license": "Apache-2.0",
+ "devDependencies": {},
+ "name": "@ohos/imageknife"
+}
diff --git a/imageknife/src/main/config.json b/imageknife/src/main/config.json
new file mode 100644
index 0000000..0d64e9a
--- /dev/null
+++ b/imageknife/src/main/config.json
@@ -0,0 +1,24 @@
+{
+ "app": {
+ "bundleName": "com.example.imageknifegiteepro",
+ "vendor": "example",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.example.imageknife",
+ "deviceType": [
+ "phone",
+ "tablet"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "imageknife",
+ "moduleType": "har"
+ },
+ "uiSyntax": "ets"
+ }
+}
diff --git a/entry/src/main/ets/MainAbility/cache/Base64.ets b/imageknife/src/main/ets/components/cache/Base64.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/Base64.ets
rename to imageknife/src/main/ets/components/cache/Base64.ets
diff --git a/entry/src/main/ets/MainAbility/cache/CustomMap.ets b/imageknife/src/main/ets/components/cache/CustomMap.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/CustomMap.ets
rename to imageknife/src/main/ets/components/cache/CustomMap.ets
diff --git a/entry/src/main/ets/MainAbility/cache/DiskCacheEntry.ets b/imageknife/src/main/ets/components/cache/DiskCacheEntry.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/DiskCacheEntry.ets
rename to imageknife/src/main/ets/components/cache/DiskCacheEntry.ets
diff --git a/entry/src/main/ets/MainAbility/cache/DiskLruCache.ets b/imageknife/src/main/ets/components/cache/DiskLruCache.ets
similarity index 99%
rename from entry/src/main/ets/MainAbility/cache/DiskLruCache.ets
rename to imageknife/src/main/ets/components/cache/DiskLruCache.ets
index 5c18a30..f1e3a6c 100644
--- a/entry/src/main/ets/MainAbility/cache/DiskLruCache.ets
+++ b/imageknife/src/main/ets/components/cache/DiskLruCache.ets
@@ -18,14 +18,14 @@ import {FileReader} from './FileReader'
import {DiskCacheEntry} from './DiskCacheEntry'
import fileio from '@ohos.fileio';
import featureability from '@ohos.ability.featureAbility'
-import {Md5} from './Md5.ets'
+import {Md5} from './Md5'
export class DiskLruCache {
// 缓存数据集合
cacheMap: CustomMap = new CustomMap()
fileUtils: FileUtils = FileUtils.getInstance()
- diskCacheFolder: string = 'GlideDiskCache'
+ diskCacheFolder: string = 'ImageKnifeDiskCache'
// 缓存文件路劲地址
dirPath: string= ''
diff --git a/entry/src/main/ets/MainAbility/cache/FileReader.ets b/imageknife/src/main/ets/components/cache/FileReader.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/FileReader.ets
rename to imageknife/src/main/ets/components/cache/FileReader.ets
diff --git a/entry/src/main/ets/MainAbility/cache/FileUtils.ets b/imageknife/src/main/ets/components/cache/FileUtils.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/FileUtils.ets
rename to imageknife/src/main/ets/components/cache/FileUtils.ets
diff --git a/entry/src/main/ets/MainAbility/cache/LruCache.ets b/imageknife/src/main/ets/components/cache/LruCache.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/LruCache.ets
rename to imageknife/src/main/ets/components/cache/LruCache.ets
diff --git a/entry/src/main/ets/MainAbility/cache/Md5.ets b/imageknife/src/main/ets/components/cache/Md5.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/Md5.ets
rename to imageknife/src/main/ets/components/cache/Md5.ets
diff --git a/entry/src/main/ets/MainAbility/cache/diskstrategy/DataSrc.ets b/imageknife/src/main/ets/components/cache/diskstrategy/DataSrc.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/diskstrategy/DataSrc.ets
rename to imageknife/src/main/ets/components/cache/diskstrategy/DataSrc.ets
diff --git a/entry/src/main/ets/MainAbility/cache/diskstrategy/DiskStrategy.ets b/imageknife/src/main/ets/components/cache/diskstrategy/DiskStrategy.ets
similarity index 51%
rename from entry/src/main/ets/MainAbility/cache/diskstrategy/DiskStrategy.ets
rename to imageknife/src/main/ets/components/cache/diskstrategy/DiskStrategy.ets
index 932f078..b5b4606 100644
--- a/entry/src/main/ets/MainAbility/cache/diskstrategy/DiskStrategy.ets
+++ b/imageknife/src/main/ets/components/cache/diskstrategy/DiskStrategy.ets
@@ -16,35 +16,13 @@ import{DataSrc} from "../diskstrategy/DataSrc"
import{EncodeStrategy} from "../diskstrategy/EncodeStrategy"
export interface DiskStrategy {
- /**
- * Returns true if this request should cache the original unmodified data.
- *
- * @param dataSource Indicates where the data was originally retrieved.
- * @return boolean
- */
+
isDataCacheable(dataSource: DataSrc): boolean
- /**
- * Returns true if this request should cache the final transformed resource.
- *
- * @param isFromAlternateCacheKey {@code true} if the resource we've decoded was loaded using an
- * alternative, rather than the primary, cache key.
- * @param dataSource Indicates where the data used to decode the resource was originally
- * retrieved.
- * @param encodeStrategy The {@link EncodeStrategy} the {@link
- * com.bumptech.glide.load.ResourceEncoder} will use to encode the resource.
- * @return boolean
- */
isResourceCacheable(isFromAlternateCacheKey: boolean, dataSource: DataSrc, encodeStrategy: EncodeStrategy): boolean;
- /** Returns true if this request should attempt to decode cached resource data.
- * @return boolean
- */
decodeCachedResource(): boolean;
- /** Returns true if this request should attempt to decode cached source data.
- * @return boolean
- */
decodeCachedData(): boolean;
getName(): string;
diff --git a/entry/src/main/ets/MainAbility/cache/diskstrategy/EncodeStrategy.ets b/imageknife/src/main/ets/components/cache/diskstrategy/EncodeStrategy.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/diskstrategy/EncodeStrategy.ets
rename to imageknife/src/main/ets/components/cache/diskstrategy/EncodeStrategy.ets
diff --git a/entry/src/main/ets/MainAbility/cache/diskstrategy/enum/ALL.ets b/imageknife/src/main/ets/components/cache/diskstrategy/enum/ALL.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/diskstrategy/enum/ALL.ets
rename to imageknife/src/main/ets/components/cache/diskstrategy/enum/ALL.ets
diff --git a/entry/src/main/ets/MainAbility/cache/diskstrategy/enum/AUTOMATIC.ets b/imageknife/src/main/ets/components/cache/diskstrategy/enum/AUTOMATIC.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/diskstrategy/enum/AUTOMATIC.ets
rename to imageknife/src/main/ets/components/cache/diskstrategy/enum/AUTOMATIC.ets
diff --git a/entry/src/main/ets/MainAbility/cache/diskstrategy/enum/DATA.ets b/imageknife/src/main/ets/components/cache/diskstrategy/enum/DATA.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/diskstrategy/enum/DATA.ets
rename to imageknife/src/main/ets/components/cache/diskstrategy/enum/DATA.ets
diff --git a/entry/src/main/ets/MainAbility/cache/diskstrategy/enum/NONE.ets b/imageknife/src/main/ets/components/cache/diskstrategy/enum/NONE.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/diskstrategy/enum/NONE.ets
rename to imageknife/src/main/ets/components/cache/diskstrategy/enum/NONE.ets
diff --git a/entry/src/main/ets/MainAbility/cache/diskstrategy/enum/RESOURCE.ets b/imageknife/src/main/ets/components/cache/diskstrategy/enum/RESOURCE.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/diskstrategy/enum/RESOURCE.ets
rename to imageknife/src/main/ets/components/cache/diskstrategy/enum/RESOURCE.ets
diff --git a/entry/src/main/ets/MainAbility/cache/key/EngineKey.ets b/imageknife/src/main/ets/components/cache/key/EngineKey.ets
similarity index 68%
rename from entry/src/main/ets/MainAbility/cache/key/EngineKey.ets
rename to imageknife/src/main/ets/components/cache/key/EngineKey.ets
index c6bc708..be28a7c 100644
--- a/entry/src/main/ets/MainAbility/cache/key/EngineKey.ets
+++ b/imageknife/src/main/ets/components/cache/key/EngineKey.ets
@@ -13,7 +13,8 @@
* limitations under the License.
*/
import {Key} from "../key/Key"
-import {RequestOption} from '../../glide/RequestOption.ets'
+import {RequestOption} from '../../imageknife/RequestOption'
+import {BaseTransform} from '../../imageknife/transform/BaseTransform'
export class EngineKey implements Key {
private request: RequestOption;
@@ -27,46 +28,55 @@ export class EngineKey implements Key {
// 内存缓存 缓存生成规则:是否会影响图片内容,不影响则通用(strategy onlyRetrieveFromCache isCacheable)为通用项目
// 生成规则 加载数据原 各类参数(排除监听 排除 占位图 失败占位图)
generateCacheKey(): string{
+
let loadSrc = JSON.stringify(this.request.loadSrc);
+
let size = JSON.stringify(this.request.size);
- let transformations;
- for (let i = 0; i < this.request.transformtions.length; i++) {
- if (i == 0) {
- transformations = this.request.transformtions[i].getName() + ",";
- } else if (i == this.request.transformtions.length - 1) {
- transformations += this.request.transformtions[i].getName() + "";
- } else {
- transformations += this.request.transformtions[i].getName() + ",";
+ let transformationsStr;
+ if(this.request && this.request.transformations) {
+ for (let i = 0; i < this.request.transformations.length; i++) {
+ if (i == this.request.transformations.length - 1) {
+ transformationsStr += this.request.transformations[i].getName() + "";
+ } else {
+ transformationsStr += this.request.transformations[i].getName() + ",";
+ }
}
}
let dontAnimateFlag = JSON.stringify(this.request.dontAnimateFlag);
+
let key = "loadSrc=" + loadSrc + ";" +
"size=" + size + ";" +
- "transformations=" + transformations + ";" +
+ "transformations=" + transformationsStr + ";" +
"dontAnimateFlag=" + dontAnimateFlag + ";"
+
return key;
}
// 磁盘缓存 缓存生成规则:是否会影响图片内容,不影响则通用(strategy onlyRetrieveFromCache isCacheable)为通用项目
// 生成规则 加载数据原 各类参数(排除监听 排除 占位图 失败占位图)
generateResourceKey(): string{
+
let loadSrc = JSON.stringify(this.request.loadSrc);
+
let size = JSON.stringify(this.request.size);
- let transformations;
- for (let i = 0; i < this.request.transformtions.length; i++) {
- if (i == this.request.transformtions.length - 1) {
- transformations += this.request.transformtions[i].getName() + "";
- } else {
- transformations += this.request.transformtions[i].getName() + ",";
+ let transformationsStr;
+ if(this.request && this.request.transformations) {
+ for (let i = 0; i < this.request.transformations.length; i++) {
+ if (i == this.request.transformations.length - 1) {
+ transformationsStr += this.request.transformations[i].getName() + "";
+ } else {
+ transformationsStr += this.request.transformations[i].getName() + ",";
+ }
}
}
let dontAnimateFlag = JSON.stringify(this.request.dontAnimateFlag);
+
let key = "loadSrc=" + loadSrc + ";" +
"size=" + size + ";" +
- "transformations=" + transformations + ";" +
+ "transformations=" + transformationsStr + ";" +
"dontAnimateFlag=" + dontAnimateFlag + ";"
return key;
diff --git a/entry/src/main/ets/MainAbility/cache/key/EngineKeyFactories.ets b/imageknife/src/main/ets/components/cache/key/EngineKeyFactories.ets
similarity index 93%
rename from entry/src/main/ets/MainAbility/cache/key/EngineKeyFactories.ets
rename to imageknife/src/main/ets/components/cache/key/EngineKeyFactories.ets
index 23ec9ac..f81f0ce 100644
--- a/entry/src/main/ets/MainAbility/cache/key/EngineKeyFactories.ets
+++ b/imageknife/src/main/ets/components/cache/key/EngineKeyFactories.ets
@@ -17,8 +17,7 @@ import {EngineKey} from '../key/EngineKey'
export class EngineKeyFactories {
buildCacheKey(
request) {
- return new EngineKey(
- request).generateCacheKey();
+ return new EngineKey(request).generateCacheKey();
}
buildDataKey(
diff --git a/entry/src/main/ets/MainAbility/cache/key/Key.ets b/imageknife/src/main/ets/components/cache/key/Key.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/cache/key/Key.ets
rename to imageknife/src/main/ets/components/cache/key/Key.ets
diff --git a/entry/src/main/ets/MainAbility/glide/Glide.ets b/imageknife/src/main/ets/components/imageknife/ImageKnife.ets
similarity index 81%
rename from entry/src/main/ets/MainAbility/glide/Glide.ets
rename to imageknife/src/main/ets/components/imageknife/ImageKnife.ets
index 48291b4..198b5ee 100644
--- a/entry/src/main/ets/MainAbility/glide/Glide.ets
+++ b/imageknife/src/main/ets/components/imageknife/ImageKnife.ets
@@ -15,30 +15,26 @@
import {DiskLruCache} from "../cache/DiskLruCache"
import {LruCache} from "../cache/LruCache"
-import {EngineKey} from "../cache/key/EngineKey"
import {EngineKeyFactories} from "../cache/key/EngineKeyFactories"
-import {DiskStrategy} from "../cache/diskstrategy/DiskStrategy"
-import {ResourceTypeEts} from "../glide/constants/ResourceTypeEts.ets"
-import {RequestOption} from "../glide/RequestOption.ets"
-import {AsyncCallback} from "../glide/interface/asynccallback.ets"
-import {PlaceHolderManager} from "../glide/holder/PlaceHolderManager.ets"
-import {ErrorHolderManager} from "../glide/holder/ErrorHolderManager.ets"
-import {RequestManager} from "../glide/requestmanage/RequstManager.ets"
+import {RequestOption} from "../imageknife/RequestOption"
+import {AsyncCallback} from "../imageknife/interface/asynccallback"
+import {PlaceHolderManager} from "../imageknife/holder/PlaceHolderManager"
+import {ErrorHolderManager} from "../imageknife/holder/ErrorHolderManager"
+import {RequestManager} from "../imageknife/requestmanage/RequstManager"
import {NONE} from "../cache/diskstrategy/enum/NONE"
-import {FileTypeUtil} from '../glide/utils/FileTypeUtil.ets'
-import {DownloadClient} from '../glide/networkmanage/DownloadClient.ets'
-import {IDataFetch} from '../glide/networkmanage/IDataFetch.ets'
-import {ParseResClient} from '../glide/resourcemanage/ParseResClient.ets'
-import {IResourceFetch} from '../glide/resourcemanage/IResourceFetch.ets'
-import {GlideData} from '../glide/GlideData.ets'
-import {FileUtils} from '../cache/FileUtils.ets'
-import {FileReader} from '../cache/FileReader.ets'
-import {GlideOption} from '../glide/GlideOption.ets'
+import {FileTypeUtil} from '../imageknife/utils/FileTypeUtil'
+import {DownloadClient} from '../imageknife/networkmanage/DownloadClient'
+import {IDataFetch} from '../imageknife/networkmanage/IDataFetch'
+import {ParseResClient} from '../imageknife/resourcemanage/ParseResClient'
+import {IResourceFetch} from '../imageknife/resourcemanage/IResourceFetch'
+import {ImageKnifeData} from '../imageknife/ImageKnifeData'
+import {FileUtils} from '../cache/FileUtils'
+import {FileReader} from '../cache/FileReader'
import image from "@ohos.multimedia.image"
import featureAbility from '@ohos.ability.featureAbility';
-import {CompressBuilder} from "../glide/compress/CompressBuilder.ets"
+import {CompressBuilder} from "../imageknife/compress/CompressBuilder"
-export class Glide {
+export class ImageKnife {
private memoryCache: LruCache;
private diskMemoryCache: DiskLruCache;
private dataFetch: IDataFetch;
@@ -53,7 +49,7 @@ export class Glide {
private svgAndGifFolder: string = "svgAndGifFolder"; // svg和gif的文件路径地址
private svgAndGifCommitFile: string = "svgAndGifCommitFile" // svg和gif提交记录
- private defaultListener:AsyncCallback; // 全局监听器
+ private defaultListener:AsyncCallback; // 全局监听器
getMemoryCache(): LruCache{
return this.memoryCache;
@@ -89,7 +85,7 @@ export class Glide {
return this.defaultListener;
}
- setDefaultListener(newDefaultListener:AsyncCallback){
+ setDefaultListener(newDefaultListener:AsyncCallback){
this.defaultListener = newDefaultListener;
}
@@ -115,7 +111,7 @@ export class Glide {
this.initSvgAndGifEnvironment();
})
.catch((error) => {
- console.error('Glide Failed to obtain the filesPath directory. Cause:' + error.message);
+ console.error('ImageKnife Failed to obtain the filesPath directory. Cause:' + error.message);
})
this.runningRequest = new Array();
@@ -151,11 +147,11 @@ export class Glide {
}
- private static sInstance: Glide;
+ private static sInstance: ImageKnife;
- public static with(): Glide{
+ public static with(): ImageKnife{
if (!this.sInstance) {
- this.sInstance = new Glide();
+ this.sInstance = new ImageKnife();
}
return this.sInstance;
}
@@ -208,7 +204,6 @@ export class Glide {
// 正常加载
call(request: RequestOption) {
- console.log("Glide call")
// 添加全局监听
if(this.defaultListener) {
request.addListener(this.defaultListener)
@@ -234,21 +229,27 @@ export class Glide {
}
loadResources(request: RequestOption) {
- console.log("Glide loadResources")
- let factories = new EngineKeyFactories();
-
+ let factories;
+ let cacheKey;
+ let transferKey;
+ let dataKey;
+ factories = new EngineKeyFactories();
// 生成内存缓存key 内存 变换后磁盘
- let cacheKey = factories.buildCacheKey(request);
+
+ cacheKey = factories.buildCacheKey(request);
// 生成磁盘缓存变换后数据key 变换后数据保存在磁盘
- let transfromKey = factories.buildResourceKey(request);
+
+ transferKey = factories.buildResourceKey(request);
// 生成磁盘缓存源数据key 原始数据保存在磁盘
- let dataKey = factories.buildDataKey(request);
+
+ dataKey = factories.buildDataKey(request);
request.generateCacheKey = cacheKey;
- request.generateResourceKey = transfromKey;
+ request.generateResourceKey = transferKey;
request.generateDataKey = dataKey;
+
this.loadCacheManager(request);
}
@@ -265,10 +266,11 @@ export class Glide {
}
if (index >= 0) {
let request = this.runningRequest.splice(index, 1)[0];
- this.loadNextPennding(request);
+ this.loadNextPending(request);
}
}
+ // 执行相同key的pending队列请求
keyEqualPendingToRun(index:number){
let nextPending = this.pendingRequest.splice(index, 1)[0];
this.runningRequest.push(nextPending)
@@ -303,7 +305,7 @@ export class Glide {
// 加载下一个key的请求
- loadNextPennding(request) {
+ loadNextPending(request) {
// 首先寻找被移除key相同的request
let index = -1;
for (let i = 0; i < this.pendingRequest.length; i++) {
@@ -323,7 +325,6 @@ export class Glide {
// 启动新线程 去磁盘取 去网络取
loadCacheManager(request: RequestOption) {
- console.log("Glide loadCacheManager")
if (this.keyNotEmpty(request)) {
let hasRunningRequest = false;
for (let i = 0; i < this.runningRequest.length; i++) {
@@ -339,7 +340,6 @@ export class Glide {
this.pendingRequest.push(request);
} else {
this.runningRequest.push(request);
-
// 不存在相同key的 任务可以并行
RequestManager.execute(request, this.memoryCache, this.diskMemoryCache, this.dataFetch, this.resourceFetch)
}
@@ -374,23 +374,17 @@ export class Glide {
}
parseSource(request: RequestOption) {
- console.log("Glide parseSource")
- console.log("Glide request ="+JSON.stringify(request))
- if (request.loadSrc instanceof image.PixelMap) {
- console.log("Glide parseSource PixelMap")
- let glidedata = new GlideData();
- glidedata.glideType = GlideData.PIXELMAP
- glidedata.glideValue = request.loadSrc as PixelMap
- request.loadComplete(glidedata);
+ if ((typeof (request.loadSrc as image.PixelMap).isEditable) == 'boolean') {
+ let imageKnifeData = new ImageKnifeData();
+ imageKnifeData.imageKnifeType = ImageKnifeData.PIXELMAP
+ imageKnifeData.imageKnifeValue = request.loadSrc as PixelMap
+ request.loadComplete(imageKnifeData);
} else
if (typeof request.loadSrc == 'string') {
// 进入三级缓存模型
- console.log("Glide parseSource string")
return this.loadResources(request);
} else {
- console.log("Glide parseSource Resource")
let res = request.loadSrc as Resource;
- console.log("Glide parseSource res="+JSON.stringify(res))
if (typeof res.id != 'undefined' && typeof res.type != 'undefined') {
//进入三级缓存模型 本地资源不参与磁盘缓存
let none = new NONE();
diff --git a/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets b/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets
new file mode 100644
index 0000000..69a5c23
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/ImageKnifeComponent.ets
@@ -0,0 +1,342 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {ImageKnifeOption} from '../imageknife/ImageKnifeOption'
+import {TransformType} from '../imageknife/transform/TransformType'
+import {RequestOption} from '../imageknife/RequestOption'
+import {ImageKnifeData} from '../imageknife/ImageKnifeData'
+import {PixelMapPack} from '../imageknife/PixelMapPack'
+
+@Component
+export struct ImageKnifeComponent {
+ @Watch('watchImageKnifeOption') @Link imageKnifeOption: ImageKnifeOption;
+ @State imageKnifePixelMapPack: PixelMapPack = new PixelMapPack();
+ @State imageKnifeResource: Resource = $r('app.media.icon_loading')
+ @State imageKnifeString: string = ''
+ @State normalPixelMap: boolean = false;
+ @State normalResource: boolean = true;
+ previousData: ImageKnifeData = null;
+ nowData: ImageKnifeData = null;
+ @State percentVisible: Visibility = Visibility.Visible
+ @State retryVisible: Visibility = Visibility.Visible
+ @State imageVisible: Visibility = Visibility.Visible
+ @State percent: string = '0%'
+ @State percentWidth: string = '0%';
+ @State percentHeight: string = '0%';
+ @State retryWidth: string = '0%';
+ @State retryHeight: string = '0%';
+ @State imageWidth: string = '100%';
+ @State imageHeight: string = '100%';
+
+ hasRetry:boolean = false;
+
+ build() {
+ Stack() {
+
+ Text(this.percent)
+ .fontSize(this.imageKnifeOption.size ? Math.min(this.imageKnifeOption.size.height, this.imageKnifeOption.size.width) / 2 : 24)
+ .fontWeight(FontWeight.Bold)
+ .visibility(this.retryVisible)
+ .width(this.percentWidth)
+ .height(this.percentHeight)
+
+ Image($r('app.media.icon_retry'))
+ .onClick(()=>{
+ this.retryClick();
+ })
+ .visibility(this.retryVisible)
+ .width(this.retryWidth)
+ .height(this.retryHeight)
+
+
+
+ Image(this.normalPixelMap ? this.imageKnifePixelMapPack.pixelMap : (this.normalResource ? this.imageKnifeResource : this.imageKnifeString))
+ .objectFit(this.imageKnifeOption.imageFit ? this.imageKnifeOption.imageFit : ImageFit.Fill)
+ .visibility(this.imageVisible)
+ .width(this.imageWidth)
+ .height(this.imageHeight)
+ }
+ .width(this.imageKnifeOption.size ? this.imageKnifeOption.size.width : '100%')
+ .height(this.imageKnifeOption.size ? this.imageKnifeOption.size.height : '100%')
+ .backgroundColor(this.imageKnifeOption.backgroundColor ? this.imageKnifeOption.backgroundColor : Color.White)
+ .margin(this.imageKnifeOption.margin ? this.imageKnifeOption.margin : { left: 0, top: 0, right: 0, bottom: 0 })
+ }
+
+ watchImageKnifeOption() {
+ this.imageKnifeExecute();
+ }
+
+ retryClick(){
+ this.hasRetry = true;
+ this.imageKnifeExecute();
+ }
+
+ aboutToAppear() {
+ console.log('imageKnifeComponent aboutToAppear happened!')
+ this.imageKnifeExecute();
+ }
+
+ configNecessary(request: RequestOption){
+ request.load(this.imageKnifeOption.loadSrc)
+ .addListener((err, data) => {
+ console.log('request.load callback')
+ this.imageKnifeChangeSource(data)
+ this.animateTo('image');
+ return false;
+ })
+
+ if (this.imageKnifeOption.size) {
+ request.setImageViewSize(this.imageKnifeOption.size)
+ }
+ }
+
+ configCacheStrategy(request: RequestOption){
+ if (this.imageKnifeOption.onlyRetrieveFromCache) {
+ request.retrieveDataFromCache(this.imageKnifeOption.onlyRetrieveFromCache)
+ }
+
+ if (this.imageKnifeOption.isCacheable) {
+ request.skipMemoryCache(!this.imageKnifeOption.isCacheable)
+ }
+
+ if (this.imageKnifeOption.strategy) {
+ request.diskCacheStrategy(this.imageKnifeOption.strategy)
+ }
+ if (this.imageKnifeOption.allCacheInfoCallback) {
+ request.addAllCacheInfoCallback(this.imageKnifeOption.allCacheInfoCallback)
+ }
+ }
+
+ configDisplay(request: RequestOption){
+ if(this.imageKnifeOption.animateDuration >= 0){
+ request.animateDuration = this.imageKnifeOption.animateDuration;
+ }
+ if (this.imageKnifeOption.placeholderSrc) {
+ request.placeholder(this.imageKnifeOption.placeholderSrc, (data) => {
+ console.log('request.placeholder callback')
+ this.imageKnifeChangeSource(data)
+ this.animateTo('image');
+ })
+ }
+ if (this.imageKnifeOption.thumbSizeMultiplier) {
+ request.thumbnail(this.imageKnifeOption.thumbSizeMultiplier, (data) => {
+ console.log('request.thumbnail callback')
+ this.imageKnifeChangeSource(data)
+ this.animateTo('image');
+ })
+ }
+ if (this.imageKnifeOption.errorholderSrc) {
+ request.errorholder(this.imageKnifeOption.errorholderSrc, (data) => {
+ console.log('request.errorholder callback')
+ this.imageKnifeChangeSource(data)
+ this.animateTo('image');
+ })
+ }
+ if (this.imageKnifeOption.transform) {
+ this.requestAddTransform(request)
+ }
+ if (this.imageKnifeOption.dontAnimateFlag) {
+ request.dontAnimate()
+ }
+
+
+ if (this.imageKnifeOption.displayProgress) {
+ request.addProgressListener((percentValue: string) => {
+ // 如果进度条百分比 未展示大小,展示其动画
+ this.percent = percentValue;
+ if(this.imageKnifeOption.displayProgressListener){
+ this.imageKnifeOption.displayProgressListener(percentValue);
+ }
+ this.animateTo('progress');
+ })
+ }
+
+ if(this.imageKnifeOption.retryLoad){
+ request.addRetryListener((error: any) => {
+ console.log("RetryListener callback!")
+ this.animateTo('retry');
+ })
+ }
+ }
+ // imageknife 第一次启动和数据刷新后重新发送请求
+ imageKnifeExecute() {
+
+ if(ImageKnife){
+ }else{
+ ImageKnife = globalThis.exports.default.data.imageKnife;
+ }
+
+ if(ImageKnife){
+ }else{
+ console.log('ImageKnife Singleton Initialization Not Completed!')
+ }
+
+ let request = new RequestOption();
+ this.configNecessary(request);
+ this.configCacheStrategy(request);
+ this.configDisplay(request);
+
+ ImageKnife.call(request);
+ }
+
+ imageKnifeChangeSource(data:ImageKnifeData) {
+ this.imageKnifeSpecialFixed(data);
+ }
+
+ displayPixelMap(data:ImageKnifeData){
+ console.log('displayPixelMap start')
+ let pixelMapPack2 = new PixelMapPack();
+ pixelMapPack2.pixelMap = data.imageKnifeValue as PixelMap;
+ this.imageKnifePixelMapPack = pixelMapPack2;
+ this.normalPixelMap = true;
+ this.normalResource = true;
+ console.log('displayPixelMap end')
+ }
+
+ displayResource(data:ImageKnifeData){
+ console.log('displayResource start')
+ this.imageKnifeResource = data.imageKnifeValue as Resource;
+ this.normalPixelMap = false;
+ this.normalResource = true;
+ console.log('displayResource end')
+ }
+
+ displayString(data:ImageKnifeData){
+ console.log('displayString start')
+ let imageKnifeNeedStr = 'file://' + data.imageKnifeValue;
+ console.log('imageKnifeNeedStr='+imageKnifeNeedStr)
+ this.imageKnifeString = imageKnifeNeedStr;
+ this.normalPixelMap = false;
+ this.normalResource = false;
+ console.log('displayString end')
+ }
+ imageKnifeSpecialFixed(data:ImageKnifeData) {
+ if (data.isPixelMap()) {
+ this.displayPixelMap(data);
+ }
+ else if (data.isString()) {
+ this.displayString(data);
+ } else if (data.isResource()) {
+ this.displayResource(data);
+ } else {
+ }
+ }
+
+ animateTo(name: string) {
+ if (name == 'progress') {
+ this.percentVisible = Visibility.Visible;
+ this.imageVisible = Visibility.Hidden;
+ this.retryVisible = Visibility.Hidden;
+ if (this.percentWidth == '0%' || this.percentHeight == '0%') {
+ animateTo({ duration: this.imageKnifeOption.animateDuration , curve: Curve.Linear }, () => {
+ this.percentWidth = '100%';
+ this.percentHeight = '100%';
+ this.imageWidth = '0%';
+ this.imageHeight = '0%';
+ this.retryWidth = '0%';
+ this.retryHeight = '0%';
+ })
+ }
+ } else if (name == 'image') {
+ this.imageVisible = Visibility.Visible;
+ this.percentVisible = Visibility.Hidden;
+ this.retryVisible = Visibility.Hidden;
+ if (this.imageWidth == '0%' || this.imageHeight == '0%') {
+ animateTo({ duration: this.imageKnifeOption.animateDuration, curve: Curve.Linear }, () => {
+ this.imageWidth = '100%';
+ this.imageHeight = '100%';
+ this.percentWidth = '0%';
+ this.percentHeight = '0%';
+ this.retryWidth = '0%';
+ this.retryHeight = '0%';
+ })
+ }
+ } else if (name == 'retry') {
+ this.retryVisible = Visibility.Visible;
+ this.imageVisible = Visibility.Hidden;
+ this.percentVisible = Visibility.Hidden;
+ if (this.retryWidth == '0%' || this.retryHeight == '0%') {
+ animateTo({ duration: this.imageKnifeOption.animateDuration, curve: Curve.Linear }, () => {
+ this.imageWidth = '0%';
+ this.imageHeight = '0%';
+ this.percentWidth = '0%';
+ this.percentHeight = '0%';
+ this.retryWidth = '100%';
+ this.retryHeight = '100%';
+ })
+ }
+ }
+ }
+
+ requestAddTransform(request:RequestOption){
+ if(TransformType.BlurTransformation == this.imageKnifeOption.transform.transformType){
+ request.blur(this.imageKnifeOption.transform.blur)
+ }else if(TransformType.BrightnessFilterTransformation == this.imageKnifeOption.transform.transformType){
+ request.brightnessFilter(this.imageKnifeOption.transform.brightnessFilter)
+ }else if(TransformType.ContrastFilterTransformation == this.imageKnifeOption.transform.transformType){
+ request.contrastFilter(this.imageKnifeOption.transform.contrastFilter)
+ }else if(TransformType.CropCircleTransformation == this.imageKnifeOption.transform.transformType){
+ request.cropCircle()
+ }else if(TransformType.CropCircleWithBorderTransformation == this.imageKnifeOption.transform.transformType){
+ request.cropCircleWithBorder(this.imageKnifeOption.transform.cropCircleWithBorder.border, this.imageKnifeOption.transform.cropCircleWithBorder.obj)
+ }else if(TransformType.CropSquareTransformation == this.imageKnifeOption.transform.transformType){
+ request.cropSquare()
+ }else if(TransformType.CropTransformation == this.imageKnifeOption.transform.transformType){
+ request.crop(this.imageKnifeOption.transform.crop.width,this.imageKnifeOption.transform.crop.height,this.imageKnifeOption.transform.crop.cropType)
+ }else if(TransformType.GrayscaleTransformation == this.imageKnifeOption.transform.transformType){
+ request.grayscale()
+ }else if(TransformType.InvertFilterTransformation == this.imageKnifeOption.transform.transformType){
+ request.invertFilter()
+ }else if(TransformType.MaskTransformation == this.imageKnifeOption.transform.transformType){
+ request.mask(this.imageKnifeOption.transform.mask)
+ }else if(TransformType.PixelationFilterTransformation == this.imageKnifeOption.transform.transformType){
+ request.pixelationFilter(this.imageKnifeOption.transform.pixelationFilter)
+ }else if(TransformType.RotateImageTransformation == this.imageKnifeOption.transform.transformType){
+ request.rotateImage(this.imageKnifeOption.transform.rotateImage)
+ }else if(TransformType.RoundedCornersTransformation == this.imageKnifeOption.transform.transformType){
+ request.roundedCorners(this.imageKnifeOption.transform.roundedCorners)
+ }else if(TransformType.SepiaFilterTransformation == this.imageKnifeOption.transform.transformType){
+ request.sepiaFilter()
+ }else if(TransformType.SketchFilterTransformation == this.imageKnifeOption.transform.transformType){
+ request.sketchFilter()
+ }else if(TransformType.SwirlFilterTransformation == this.imageKnifeOption.transform.transformType){
+ request.swirlFilter(this.imageKnifeOption.transform.swirlFilter)
+ }else if(TransformType.CenterCrop == this.imageKnifeOption.transform.transformType){
+ request.centerCrop()
+ }else if(TransformType.CenterInside == this.imageKnifeOption.transform.transformType){
+ request.centerInside()
+ }else if(TransformType.FitCenter == this.imageKnifeOption.transform.transformType){
+ request.fitCenter()
+ }
+ }
+
+ aboutToDisappear() {
+ }
+
+ onPageShow() {
+ }
+
+ onPageHide() {
+ }
+
+ onBackPress() {
+ }
+}
+
+var ImageKnife;
+var defaultTemp = globalThis.exports.default
+if (defaultTemp != undefined) {
+ ImageKnife = defaultTemp.data.imageKnife;
+}
diff --git a/entry/src/main/ets/MainAbility/glide/GlideData.ets b/imageknife/src/main/ets/components/imageknife/ImageKnifeData.ets
similarity index 64%
rename from entry/src/main/ets/MainAbility/glide/GlideData.ets
rename to imageknife/src/main/ets/components/imageknife/ImageKnifeData.ets
index 73cb56c..cd0a4aa 100644
--- a/entry/src/main/ets/MainAbility/glide/GlideData.ets
+++ b/imageknife/src/main/ets/components/imageknife/ImageKnifeData.ets
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-export class GlideData {
+export class ImageKnifeData {
static PIXELMAP = 'PixelMap'
static STRING = 'string'
@@ -27,43 +27,43 @@ export class GlideData {
static WEBP = 'webp';
- glideType:string = '';
- glideValue:PixelMap|string|Resource;
- glideSourceType:string = ''
+ imageKnifeType:string = '';
+ imageKnifeValue:PixelMap|string|Resource;
+ imageKnifeSourceType:string = ''
isSvg():boolean{
- return GlideData.SVG == this.glideSourceType;
+ return ImageKnifeData.SVG == this.imageKnifeSourceType;
}
isGif():boolean{
- return GlideData.GIF == this.glideSourceType;
+ return ImageKnifeData.GIF == this.imageKnifeSourceType;
}
isJpg():boolean{
- return GlideData.JPG == this.glideSourceType;
+ return ImageKnifeData.JPG == this.imageKnifeSourceType;
}
isPng():boolean{
- return GlideData.PNG == this.glideSourceType;
+ return ImageKnifeData.PNG == this.imageKnifeSourceType;
}
isBmp():boolean{
- return GlideData.BMP == this.glideSourceType;
+ return ImageKnifeData.BMP == this.imageKnifeSourceType;
}
isWebp():boolean{
- return GlideData.WEBP == this.glideSourceType;
+ return ImageKnifeData.WEBP == this.imageKnifeSourceType;
}
isString():boolean{
- return GlideData.STRING == this.glideType;
+ return ImageKnifeData.STRING == this.imageKnifeType;
}
isPixelMap():boolean{
- return GlideData.PIXELMAP == this.glideType;
+ return ImageKnifeData.PIXELMAP == this.imageKnifeType;
}
isResource():boolean{
- return GlideData.RESOURCE == this.glideType;
+ return ImageKnifeData.RESOURCE == this.imageKnifeType;
}
diff --git a/entry/src/main/ets/MainAbility/glide/GlideOption.ets b/imageknife/src/main/ets/components/imageknife/ImageKnifeOption.ets
similarity index 65%
rename from entry/src/main/ets/MainAbility/glide/GlideOption.ets
rename to imageknife/src/main/ets/components/imageknife/ImageKnifeOption.ets
index 39bc1de..775a212 100644
--- a/entry/src/main/ets/MainAbility/glide/GlideOption.ets
+++ b/imageknife/src/main/ets/components/imageknife/ImageKnifeOption.ets
@@ -13,12 +13,14 @@
* limitations under the License.
*/
-import {AUTOMATIC} from "../cache/diskstrategy/enum/AUTOMATIC.ets"
-import {DiskStrategy} from "../cache/diskstrategy/DiskStrategy.ets"
-import {BaseTransform} from "../glide/transform/BaseTransform.ets"
-import {AllCacheInfo, IAllCacheInfoCallback} from "../glide/interface/iallcacheinfocallback.ets"
+import {AUTOMATIC} from "../cache/diskstrategy/enum/AUTOMATIC"
+import {DiskStrategy} from "../cache/diskstrategy/DiskStrategy"
+import {BaseTransform} from "../imageknife/transform/BaseTransform"
+import {TransformType} from "../imageknife/transform/TransformType"
+import {CropType} from "../imageknife/transform/CropTransformation"
+import {AllCacheInfo, IAllCacheInfoCallback} from "../imageknife/interface/IAllCacheInfoCallback"
-export class GlideOption {
+export class ImageKnifeOption {
// 主图资源
loadSrc: string | PixelMap | Resource;
@@ -57,7 +59,20 @@ export class GlideOption {
isCacheable?: boolean = true;
// 变换相关
- transformtions?: Array> = new Array();
+ transform?:{
+ transformType:number,
+ blur?:number,
+ roundedCorners?:{ top_left: number, top_right: number, bottom_left: number, bottom_right: number }
+ cropCircleWithBorder?:{border:number, obj:{ r_color: number, g_color: number, b_color: number }}
+ crop?:{width: number, height: number, cropType: CropType}
+ brightnessFilter?:number,
+ contrastFilter?:number,
+ pixelationFilter?:number,
+ swirlFilter?:number,
+ mask?:Resource,
+ rotateImage?:number
+ }
+
// 输出缓存相关内容和信息
allCacheInfoCallback?: IAllCacheInfoCallback;
diff --git a/entry/src/main/ets/MainAbility/glide/PixelMapPack.ets b/imageknife/src/main/ets/components/imageknife/PixelMapPack.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/PixelMapPack.ets
rename to imageknife/src/main/ets/components/imageknife/PixelMapPack.ets
diff --git a/imageknife/src/main/ets/components/imageknife/RequestOption.ets b/imageknife/src/main/ets/components/imageknife/RequestOption.ets
new file mode 100644
index 0000000..9304d76
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/RequestOption.ets
@@ -0,0 +1,412 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {DiskStrategy} from "../cache/diskstrategy/DiskStrategy"
+import {AsyncCallback} from "../imageknife/interface/asynccallback"
+import {AsyncSuccess} from "../imageknife/interface/AsyncSuccess"
+import {IAllCacheInfoCallback} from "../imageknife/interface/IAllCacheInfoCallback"
+import {AUTOMATIC} from "../cache/diskstrategy/enum/AUTOMATIC"
+import {BaseTransform} from "../imageknife/transform/BaseTransform"
+import {RotateImageTransformation} from "../imageknife/transform/RotateImageTransformation"
+import {ImageKnifeData} from "../imageknife/ImageKnifeData"
+import {CenterCrop} from '../imageknife/transform/pixelmap/CenterCrop'
+import {CenterInside} from '../imageknife/transform/pixelmap/CenterInside'
+import {FitCenter} from '../imageknife/transform/pixelmap/FitCenter'
+import {RoundedCornersTransformation} from '../imageknife/transform/RoundedCornersTransformation'
+
+import {CropCircleTransformation} from '../imageknife/transform/CropCircleTransformation'
+
+import {CropCircleWithBorderTransformation} from '../imageknife/transform/CropCircleWithBorderTransformation'
+import {CropSquareTransformation} from '../imageknife/transform/CropSquareTransformation'
+import {CropTransformation} from '../imageknife/transform/CropTransformation'
+import {CropType} from '../imageknife/transform/CropTransformation'
+import {GrayscaleTransformation} from '../imageknife/transform/GrayscaleTransformation'
+import {BrightnessFilterTransformation} from '../imageknife/transform/BrightnessFilterTransformation'
+import {ContrastFilterTransformation} from '../imageknife/transform/ContrastFilterTransformation'
+import {InvertFilterTransformation} from '../imageknife/transform/InvertFilterTransformation'
+import {SepiaFilterTransformation} from '../imageknife/transform/SepiaFilterTransformation'
+import {SketchFilterTransformation} from '../imageknife/transform/SketchFilterTransformation'
+import {BlurTransformation} from '../imageknife/transform/BlurTransformation'
+import {PixelationFilterTransformation} from '../imageknife/transform/PixelationFilterTransformation'
+import {MaskTransformation} from '../imageknife/transform/MaskTransformation'
+import {SwirlFilterTransformation} from '../imageknife/transform/SwirlFilterTransformation'
+
+
+export class RequestOption {
+ loadSrc: string | PixelMap | Resource;
+ strategy: DiskStrategy = new AUTOMATIC();
+ dontAnimateFlag = false;
+ placeholderSrc: PixelMap | Resource;
+ placeholderFunc: AsyncSuccess;
+ errorholderSrc: PixelMap | Resource;
+ errorholderFunc: AsyncSuccess;
+ errorholderData: ImageKnifeData;
+ thumbSizeMultiplier: number;
+
+ // 如果存在缩略图,则主图延时3000ms加载
+ thumbDelayTime: number = 3000
+ thumbHolderFunc: AsyncSuccess;
+ requestListeners: Array>;
+
+ // 进度条
+ progressFunc: AsyncSuccess;
+
+ // 重试图层
+ retryFunc: AsyncSuccess
+
+ // 图层切换时长
+ animateDuration: number = 500;
+ size: {
+ width: number,
+ height: number
+ } = { width: -1, height: -1 };
+
+ // 网络下载数据回调
+ allCacheInfoCallback: IAllCacheInfoCallback;
+ onlyRetrieveFromCache: boolean = false;
+ isCacheable: boolean = true;
+
+ // 变换相关
+ transformations: Array> = new Array();
+ generateCacheKey: string = "";
+ generateResourceKey: string = "";
+ generateDataKey: string = "";
+ private filesPath: string = ""; // data/data/包名/files目录
+ private cachesPath: string = ""; // 网络下载默认存储在data/data/包名/cache/ImageKnifeNetworkFolder/目标md5.img下面
+
+ // 下载原始文件地址
+ downloadFilePath: string = "";
+
+ // 网络文件下载统一存放
+ networkCacheFolder: string = "ImageKnifeNetworkFolder"
+
+
+ // 主线图片 状态变化 是否加载完成
+ // 主图未加载成功 显示占位图 主图加载成功不展示占位图
+ loadMainReady = false;
+
+ // 失败占位图展示状态 当true 表示主图加载失败需要展示失败占位图
+ loadErrorReady = false
+
+ // 缩略图展示
+ loadThumbnailReady = false;
+ _svgAndGifFolder: string = "svgAndGifFolder"; // svg和gif的文件路径地址
+ _svgAndGifCommitFile: string = "svgAndGifCommitFile"; // svg和gif提交记录
+
+ constructor() {
+ // 初始化全局监听
+ this.requestListeners = new Array();
+ }
+
+ /**
+ * set image Component size
+ */
+ setImageViewSize(imageSize: {
+ width: number,
+ height: number
+ }) {
+ this.size.width = imageSize.width;
+ this.size.height = imageSize.height;
+ return this;
+ }
+
+ getFilesPath() {
+ return this.filesPath;
+ }
+
+ setFilesPath(path: string) {
+ this.filesPath = path;
+ }
+
+ getCachesPath() {
+ return this.cachesPath;
+ }
+
+ setCachesPath(path: string) {
+ this.cachesPath = path;
+ }
+
+ load(src: string | PixelMap | Resource) {
+ this.loadSrc = src;
+ return this;
+ }
+
+ diskCacheStrategy(strategy: DiskStrategy) {
+ this.strategy = strategy;
+ return this;
+ }
+
+ dontAnimate() {
+ this.dontAnimateFlag = true;
+ return this;
+ }
+
+ // 仅支持 本地图片
+ placeholder(src: PixelMap | Resource, func?: AsyncSuccess) {
+ this.placeholderSrc = src;
+ this.placeholderFunc = func;
+ return this;
+ }
+
+ errorholder(src: PixelMap | Resource, func?: AsyncSuccess) {
+ this.errorholderSrc = src;
+ this.errorholderFunc = func;
+ return this;
+ }
+
+ thumbnail(sizeMultiplier: number, func?: AsyncSuccess) {
+ this.thumbSizeMultiplier = sizeMultiplier;
+ this.thumbHolderFunc = func;
+ return this;
+ }
+
+ addProgressListener(func?: AsyncSuccess) {
+ this.progressFunc = func;
+ return this;
+ }
+
+ addRetryListener(func?: AsyncSuccess) {
+ this.retryFunc = func;
+ return this;
+ }
+
+ addListener(func: AsyncCallback) {
+ this.requestListeners.push(func);
+ return this;
+ }
+
+ addAllCacheInfoCallback(func: IAllCacheInfoCallback) {
+ this.allCacheInfoCallback = func;
+ return this;
+ }
+
+ skipMemoryCache(skip: boolean) {
+ this.isCacheable = !skip;
+ return this;
+ }
+
+ retrieveDataFromCache(flag: boolean) {
+ this.onlyRetrieveFromCache = flag;
+ }
+
+ rotateImage(degreesToRotate: number) {
+ let rotateImage = new RotateImageTransformation(degreesToRotate);
+ this.transformations.push(rotateImage);
+ return this;
+ }
+
+ centerCrop() {
+ this.transformations.push(new CenterCrop());
+ return this;
+ }
+ centerInside() {
+ this.transformations.push(new CenterInside());
+ return this;
+ }
+ fitCenter() {
+ this.transformations.push(new FitCenter());
+ return this;
+ }
+
+ roundedCorners(obj:{ top_left: number, top_right: number, bottom_left: number, bottom_right: number }){
+ let transformation = new RoundedCornersTransformation({top_left: obj.top_left, top_right: obj.top_right, bottom_left: obj.bottom_left, bottom_right: obj.bottom_right})
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ cropCircle(){
+ let transformation = new CropCircleTransformation()
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ cropCircleWithBorder(border:number, obj:{ r_color: number, g_color: number, b_color: number }){
+ let transformation = new CropCircleWithBorderTransformation(border,obj)
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ cropSquare(){
+ let transformation = new CropSquareTransformation()
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ crop(width: number, height: number, cropType: CropType){
+ let transformation = new CropTransformation(width, height, cropType)
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ grayscale(){
+ let transformation = new GrayscaleTransformation()
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ brightnessFilter(brightness:number){
+ let transformation = new BrightnessFilterTransformation(brightness)
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ contrastFilter(contrast:number){
+ let transformation = new ContrastFilterTransformation(contrast)
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ invertFilter(){
+ let transformation = new InvertFilterTransformation()
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ sepiaFilter(){
+ let transformation = new SepiaFilterTransformation()
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ sketchFilter(){
+ let transformation = new SketchFilterTransformation()
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ blur(radius: number){
+ let transformation = new BlurTransformation(radius)
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ pixelationFilter(pixel: number){
+ let transformation = new PixelationFilterTransformation(pixel)
+ this.transformations.push(transformation);
+ return this;
+ }
+
+ swirlFilter(degree: number){
+ let transformation = new SwirlFilterTransformation(degree)
+ this.transformations.push(transformation);
+ return this;
+ }
+ mask(maskResource: Resource){
+ let transformation = new MaskTransformation(maskResource)
+ this.transformations.push(transformation);
+ return this;
+ }
+
+
+ // 占位图解析成功
+ placeholderOnComplete(imageKnifeData: ImageKnifeData) {
+ console.log("placeholderOnComplete has called!");
+ console.log("Main Image is Ready:" + this.loadMainReady);
+ if (!this.loadMainReady && !this.loadErrorReady && !this.loadThumbnailReady) {
+ // 主图未加载成功,并且未加载失败 显示占位图 主图加载成功或者加载失败后=>不展示占位图
+ this.placeholderFunc(imageKnifeData)
+ }
+ }
+
+ // 占位图解析失败
+ placeholderOnError(error) {
+ console.log("占位图解析失败 error =" + error)
+ }
+
+ // 缩略图解析成功
+ thumbholderOnComplete(imageKnifeData: ImageKnifeData) {
+ if (!this.loadMainReady && !this.loadErrorReady) {
+ //主图未加载成功,并且未加载失败 显示占位图 主图加载成功或者加载失败后=>不展示占位图
+ this.thumbHolderFunc(imageKnifeData)
+ }
+ }
+
+ // 缩略图解析失败
+ thumbholderOnError(error) {
+ console.log("缩略图解析失败 error =" + error)
+ }
+
+ // 加载失败 占位图解析成功
+ errorholderOnComplete(imageKnifeData: ImageKnifeData) {
+ // 如果有错误占位图 先解析并保存在RequestOption中 等到加载失败时候进行调用
+ this.errorholderData = imageKnifeData;
+ if (this.loadErrorReady) {
+ this.errorholderFunc(imageKnifeData)
+ }
+ }
+
+ //加载失败 占位图解析失败
+ errorholderOnError(error) {
+ console.log("失败占位图解析失败 error =" + error)
+ }
+
+ loadComplete(imageKnifeData: ImageKnifeData) {
+ this.loadMainReady = true;
+ // 三级缓存数据加载成功
+ for (let requestListener of this.requestListeners) {
+ var ret = requestListener("", imageKnifeData);
+ if (ret) {
+ break;
+ }
+ }
+
+ if(ImageKnife){
+ }else{
+ ImageKnife = globalThis.exports.default.data.imageKnife;
+ }
+
+ if(ImageKnife){
+ }else{
+ console.log('ImageKnife Singleton Initialization Not Completed!')
+ }
+
+ // 加载成功之后
+ ImageKnife.removeRunning(this);
+ }
+
+ loadError(err) {
+ console.log("loadError:"+err);
+ //失败占位图展示规则
+ this.loadErrorReady = true;
+ if (this.retryFunc) {
+ // 重试图层优先于加载失败展示
+ this.retryFunc(err)
+ } else {
+ if (this.errorholderData != null) {
+ this.errorholderFunc(this.errorholderData)
+ }
+ }
+
+ // 加载失败之后
+ if(ImageKnife){
+ }else{
+ ImageKnife = globalThis.exports.default.data.imageKnife;
+ }
+
+ if(ImageKnife){
+ }else{
+ console.log('ImageKnife Singleton Initialization Not Completed!')
+ }
+
+ ImageKnife.removeRunning(this);
+ }
+}
+
+
+var ImageKnife;
+var defaultTemp = globalThis.exports.default
+if (defaultTemp != undefined) {
+ ImageKnife = defaultTemp.data.imageKnife;
+}
diff --git a/entry/src/main/ets/MainAbility/glide/compress/CompressBuilder.ets b/imageknife/src/main/ets/components/imageknife/compress/CompressBuilder.ets
similarity index 98%
rename from entry/src/main/ets/MainAbility/glide/compress/CompressBuilder.ets
rename to imageknife/src/main/ets/components/imageknife/compress/CompressBuilder.ets
index 7fbda9d..08e7796 100644
--- a/entry/src/main/ets/MainAbility/glide/compress/CompressBuilder.ets
+++ b/imageknife/src/main/ets/components/imageknife/compress/CompressBuilder.ets
@@ -13,15 +13,15 @@
* limitations under the License.
*/
-import {OnRenameListener} from '../compress/listener/OnRenameListener.ets'
-import {OnCompressListener} from '../compress/listener/OnCompressListener.ets'
-import {CompressionPredicate} from '../compress/listener/CompressionPredicate.ets'
+import {OnRenameListener} from '../compress/listener/OnRenameListener'
+import {OnCompressListener} from '../compress/listener/OnCompressListener'
+import {CompressionPredicate} from '../compress/listener/CompressionPredicate'
import fileio from '@ohos.fileio';
-import {CompressAdapter} from '../compress/provider/CompressAdapter.ets'
-import {DataStringPathProvider} from '../compress/provider/DataStringPathProvider.ets'
-import {RecourseProvider} from '../compress/provider/RecourseProvider.ets'
+import {CompressAdapter} from '../compress/provider/CompressAdapter'
+import {DataStringPathProvider} from '../compress/provider/DataStringPathProvider'
+import {RecourseProvider} from '../compress/provider/RecourseProvider'
import featureability from '@ohos.ability.featureAbility'
-import {Engine} from '../compress/Engine.ets'
+import {Engine} from '../compress/Engine'
export class CompressBuilder {
private _mTargetDir: string;
diff --git a/entry/src/main/ets/MainAbility/glide/compress/Engine.ets b/imageknife/src/main/ets/components/imageknife/compress/Engine.ets
similarity index 95%
rename from entry/src/main/ets/MainAbility/glide/compress/Engine.ets
rename to imageknife/src/main/ets/components/imageknife/compress/Engine.ets
index e0ccfbf..432216b 100644
--- a/entry/src/main/ets/MainAbility/glide/compress/Engine.ets
+++ b/imageknife/src/main/ets/components/imageknife/compress/Engine.ets
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-import {OnCompressListener} from '../compress/listener/OnCompressListener.ets'
-import {CompressionPredicate} from '../compress/listener/CompressionPredicate.ets'
-import {CompressAdapter} from "../compress/provider/CompressAdapter.ets"
-import {DataStringPathProvider} from '../compress/provider/DataStringPathProvider.ets'
-import {RecourseProvider} from '../compress/provider/RecourseProvider.ets'
+import {OnCompressListener} from '../compress/listener/OnCompressListener'
+import {CompressionPredicate} from '../compress/listener/CompressionPredicate'
+import {CompressAdapter} from "../compress/provider/CompressAdapter"
+import {DataStringPathProvider} from '../compress/provider/DataStringPathProvider'
+import {RecourseProvider} from '../compress/provider/RecourseProvider'
import {FileUtils} from '../../cache/FileUtils'
import image from "@ohos.multimedia.image"
import fileio from '@ohos.fileio';
@@ -84,7 +84,7 @@ export class Engine {
return;
}
- var imageResource = image.createImageSource(buffer);
+ var imageResource = image.createImageSource(buffer as any);
imageResource.getImageInfo()
.then(info => {
var height = info.size.height;
@@ -123,7 +123,7 @@ export class Engine {
if (!this.checkNeedCompress(buffer)) {
return;
}
- var imageResource = image.createImageSource(buffer);
+ var imageResource = image.createImageSource(buffer as any);
imageResource.getImageInfo()
.then(info => {
var height = info.size.height;
@@ -134,7 +134,7 @@ export class Engine {
quality: computeSize,
}
var imagePacker = image.createImagePacker();
- imagePacker.packing(imageResource, packer, (err,compressBuffer)=>{
+ imagePacker.packing(imageResource, packer as any, (err,compressBuffer)=>{
if(err){
this.mCompressListener.onError("resource packing fail,because error:" + err);
}
@@ -165,7 +165,7 @@ export class Engine {
}
private handResult(buffer: ArrayBuffer, path: string) {
- var imageRes = image.createImageSource(buffer);
+ var imageRes = image.createImageSource(buffer as any);
let a={
editable: true,
}
diff --git a/entry/src/main/ets/MainAbility/glide/compress/listener/CompressDataListener.ets b/imageknife/src/main/ets/components/imageknife/compress/listener/CompressDataListener.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/compress/listener/CompressDataListener.ets
rename to imageknife/src/main/ets/components/imageknife/compress/listener/CompressDataListener.ets
diff --git a/entry/src/main/ets/MainAbility/glide/compress/listener/CompressionPredicate.ets b/imageknife/src/main/ets/components/imageknife/compress/listener/CompressionPredicate.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/compress/listener/CompressionPredicate.ets
rename to imageknife/src/main/ets/components/imageknife/compress/listener/CompressionPredicate.ets
diff --git a/entry/src/main/ets/MainAbility/glide/compress/listener/OnCompressListener.ets b/imageknife/src/main/ets/components/imageknife/compress/listener/OnCompressListener.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/compress/listener/OnCompressListener.ets
rename to imageknife/src/main/ets/components/imageknife/compress/listener/OnCompressListener.ets
diff --git a/entry/src/main/ets/MainAbility/glide/compress/listener/OnRenameListener.ets b/imageknife/src/main/ets/components/imageknife/compress/listener/OnRenameListener.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/compress/listener/OnRenameListener.ets
rename to imageknife/src/main/ets/components/imageknife/compress/listener/OnRenameListener.ets
diff --git a/entry/src/main/ets/MainAbility/glide/compress/provider/CompressAdapter.ets b/imageknife/src/main/ets/components/imageknife/compress/provider/CompressAdapter.ets
similarity index 95%
rename from entry/src/main/ets/MainAbility/glide/compress/provider/CompressAdapter.ets
rename to imageknife/src/main/ets/components/imageknife/compress/provider/CompressAdapter.ets
index 3c481bc..ff7a7e9 100644
--- a/entry/src/main/ets/MainAbility/glide/compress/provider/CompressAdapter.ets
+++ b/imageknife/src/main/ets/components/imageknife/compress/provider/CompressAdapter.ets
@@ -13,8 +13,8 @@
* limitations under the License.
*/
-import {CompressProvider} from "../provider/CompressProvider.ets"
-import {CompressDataListener} from "../listener/CompressDataListener.ets"
+import {CompressProvider} from "../provider/CompressProvider"
+import {CompressDataListener} from "../listener/CompressDataListener"
export abstract class CompressAdapter implements CompressProvider {
mData: ArrayBuffer;
diff --git a/entry/src/main/ets/MainAbility/glide/compress/provider/CompressProvider.ets b/imageknife/src/main/ets/components/imageknife/compress/provider/CompressProvider.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/compress/provider/CompressProvider.ets
rename to imageknife/src/main/ets/components/imageknife/compress/provider/CompressProvider.ets
diff --git a/entry/src/main/ets/MainAbility/glide/compress/provider/DataStringPathProvider.ets b/imageknife/src/main/ets/components/imageknife/compress/provider/DataStringPathProvider.ets
similarity index 94%
rename from entry/src/main/ets/MainAbility/glide/compress/provider/DataStringPathProvider.ets
rename to imageknife/src/main/ets/components/imageknife/compress/provider/DataStringPathProvider.ets
index e40b67a..7d75c0e 100644
--- a/entry/src/main/ets/MainAbility/glide/compress/provider/DataStringPathProvider.ets
+++ b/imageknife/src/main/ets/components/imageknife/compress/provider/DataStringPathProvider.ets
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-import {CompressAdapter, PixelMapFormat} from '../provider/CompressAdapter.ets'
-import {CompressDataListener} from '../listener/CompressDataListener.ets'
-import {FileUtils} from '../../../cache/FileUtils.ets'
+import {CompressAdapter, PixelMapFormat} from '../provider/CompressAdapter'
+import {CompressDataListener} from '../listener/CompressDataListener'
+import {FileUtils} from '../../../cache/FileUtils'
export class DataStringPathProvider extends CompressAdapter {
constructor(s: string) {
diff --git a/entry/src/main/ets/MainAbility/glide/compress/provider/RecourseProvider.ets b/imageknife/src/main/ets/components/imageknife/compress/provider/RecourseProvider.ets
similarity index 97%
rename from entry/src/main/ets/MainAbility/glide/compress/provider/RecourseProvider.ets
rename to imageknife/src/main/ets/components/imageknife/compress/provider/RecourseProvider.ets
index ff5f6aa..eb0cc03 100644
--- a/entry/src/main/ets/MainAbility/glide/compress/provider/RecourseProvider.ets
+++ b/imageknife/src/main/ets/components/imageknife/compress/provider/RecourseProvider.ets
@@ -13,10 +13,10 @@
* limitations under the License.
*/
-import {CompressAdapter, PixelMapFormat} from "../provider/CompressAdapter.ets"
+import {CompressAdapter, PixelMapFormat} from "../provider/CompressAdapter"
import resmgr from '@ohos.resourceManager'
-import {CompressDataListener} from "../listener/CompressDataListener.ets"
-import {FileTypeUtil} from '../../../glide/utils/FileTypeUtil.ets'
+import {CompressDataListener} from "../listener/CompressDataListener"
+import {FileTypeUtil} from '../../../imageknife/utils/FileTypeUtil'
export class RecourseProvider extends CompressAdapter {
private static CHARS: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
diff --git a/entry/src/main/ets/MainAbility/glide/constants/Constants.ets b/imageknife/src/main/ets/components/imageknife/constants/Constants.ets
similarity index 92%
rename from entry/src/main/ets/MainAbility/glide/constants/Constants.ets
rename to imageknife/src/main/ets/components/imageknife/constants/Constants.ets
index 15c575f..e9a5b77 100644
--- a/entry/src/main/ets/MainAbility/glide/constants/Constants.ets
+++ b/imageknife/src/main/ets/components/imageknife/constants/Constants.ets
@@ -14,5 +14,5 @@
*/
export class Constants {
- public static PROJECT_TAG: string= "Glide_js"
+ public static PROJECT_TAG: string= "ImageKnife_js"
}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/constants/ResourceTypeEts.ets b/imageknife/src/main/ets/components/imageknife/constants/ResourceTypeEts.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/constants/ResourceTypeEts.ets
rename to imageknife/src/main/ets/components/imageknife/constants/ResourceTypeEts.ets
diff --git a/entry/src/main/ets/MainAbility/glide/crop/Crop.ets b/imageknife/src/main/ets/components/imageknife/crop/Crop.ets
similarity index 94%
rename from entry/src/main/ets/MainAbility/glide/crop/Crop.ets
rename to imageknife/src/main/ets/components/imageknife/crop/Crop.ets
index b6e3114..c171b4c 100644
--- a/entry/src/main/ets/MainAbility/glide/crop/Crop.ets
+++ b/imageknife/src/main/ets/components/imageknife/crop/Crop.ets
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-import {AsyncTransform} from "../transform/AsyncTransform.ets"
+import {AsyncTransform} from "../transform/AsyncTransform"
import image from "@ohos.multimedia.image"
-import {TransformUtils} from "../transform/TransformUtils.ets"
+import {TransformUtils} from "../transform/TransformUtils"
export namespace Crop {
@@ -27,7 +27,7 @@ export namespace Crop {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
TransformUtils.getPixelMapSize(imageSource, (error, size: {
width: number,
height: number
diff --git a/entry/src/main/ets/MainAbility/glide/crop/CropImage.ets b/imageknife/src/main/ets/components/imageknife/crop/CropImage.ets
similarity index 96%
rename from entry/src/main/ets/MainAbility/glide/crop/CropImage.ets
rename to imageknife/src/main/ets/components/imageknife/crop/CropImage.ets
index 502676c..aa4c682 100644
--- a/entry/src/main/ets/MainAbility/glide/crop/CropImage.ets
+++ b/imageknife/src/main/ets/components/imageknife/crop/CropImage.ets
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-import {CropOptions} from "../crop/CropOptions.ets";
+import {CropOptions} from "../crop/CropOptions";
@Component
export struct CropImage {
diff --git a/entry/src/main/ets/MainAbility/glide/crop/CropOptions.ets b/imageknife/src/main/ets/components/imageknife/crop/CropOptions.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/crop/CropOptions.ets
rename to imageknife/src/main/ets/components/imageknife/crop/CropOptions.ets
diff --git a/entry/src/main/ets/MainAbility/glide/entry/ArcPoint.ets b/imageknife/src/main/ets/components/imageknife/entry/ArcPoint.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/entry/ArcPoint.ets
rename to imageknife/src/main/ets/components/imageknife/entry/ArcPoint.ets
diff --git a/imageknife/src/main/ets/components/imageknife/entry/PixelEntry.ets b/imageknife/src/main/ets/components/imageknife/entry/PixelEntry.ets
new file mode 100644
index 0000000..b14b30d
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/entry/PixelEntry.ets
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export class PixelEntry {
+ a: number;
+ b: number;
+ r: number;
+ g: number;
+ f: number;
+ pixel: number;
+
+ public toString(): string {
+ return "PixelEntry a:" + this.a + ";b:" + this.b + ";r:" + this.r + ";g:" + this.g + ";f:" + this.f;
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/holder/ErrorHolderManager.ets b/imageknife/src/main/ets/components/imageknife/holder/ErrorHolderManager.ets
similarity index 63%
rename from entry/src/main/ets/MainAbility/glide/holder/ErrorHolderManager.ets
rename to imageknife/src/main/ets/components/imageknife/holder/ErrorHolderManager.ets
index db630a6..242a650 100644
--- a/entry/src/main/ets/MainAbility/glide/holder/ErrorHolderManager.ets
+++ b/imageknife/src/main/ets/components/imageknife/holder/ErrorHolderManager.ets
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-import {RequestOption} from "../../glide/RequestOption.ets"
-import {FileTypeUtil} from "../../glide/utils/FileTypeUtil.ets"
-import {GlideData} from "../GlideData.ets"
-import {ParseImageUtil} from '../utils/ParseImageUtil.ets'
-import {ParseResClient} from '../resourcemanage/ParseResClient.ets'
+import {RequestOption} from "../../imageknife/RequestOption"
+import {FileTypeUtil} from "../../imageknife/utils/FileTypeUtil"
+import {ImageKnifeData} from "../ImageKnifeData"
+import {ParseImageUtil} from '../utils/ParseImageUtil'
+import {ParseResClient} from '../resourcemanage/ParseResClient'
import image from "@ohos.multimedia.image"
export class ErrorHolderManager {
@@ -39,11 +39,11 @@ export class ErrorHolderManager {
private displayErrorholder(onComplete, onError) {
console.log("displayErrorholder")
- if (this.options.errorholderSrc instanceof image.PixelMap) {
- let glidedata = new GlideData();
- glidedata.glideType = GlideData.PIXELMAP
- glidedata.glideValue = this.options.placeholderSrc as PixelMap
- onComplete(glidedata);
+ if ((typeof (this.options.errorholderSrc as image.PixelMap).isEditable) == 'boolean') {
+ let imageKnifeData = new ImageKnifeData();
+ imageKnifeData.imageKnifeType = ImageKnifeData.PIXELMAP
+ imageKnifeData.imageKnifeValue = this.options.placeholderSrc as PixelMap
+ onComplete(imageKnifeData);
} else if (typeof this.options.errorholderSrc == 'string') {
} else {
@@ -54,19 +54,19 @@ export class ErrorHolderManager {
let fileTypeUtil = new FileTypeUtil();
let typeValue = fileTypeUtil.getFileType(arraybuffer);
if ("gif" == typeValue || "svg" == typeValue) {
- let glidedata = new GlideData();
- glidedata.glideType = "Resource"
- glidedata.glideValue = this.options.errorholderSrc as Resource
- glidedata.glideSourceType = typeValue;
- onComplete(glidedata);
+ let imageKnifeData = new ImageKnifeData();
+ imageKnifeData.imageKnifeType = "Resource"
+ imageKnifeData.imageKnifeValue = this.options.errorholderSrc as Resource
+ imageKnifeData.imageKnifeSourceType = typeValue;
+ onComplete(imageKnifeData);
} else {
let parseImageUtils = new ParseImageUtil();
let success = (value: PixelMap) => {
- let glidedata = new GlideData();
- glidedata.glideType = "PixelMap"
- glidedata.glideValue = value
- glidedata.glideSourceType = typeValue;
- onComplete(glidedata);
+ let imageKnifeData = new ImageKnifeData();
+ imageKnifeData.imageKnifeType = "PixelMap"
+ imageKnifeData.imageKnifeValue = value
+ imageKnifeData.imageKnifeSourceType = typeValue;
+ onComplete(imageKnifeData);
}
parseImageUtils.parseImage(arraybuffer, success, onError)
}
diff --git a/entry/src/main/ets/MainAbility/glide/holder/PlaceHolderManager.ets b/imageknife/src/main/ets/components/imageknife/holder/PlaceHolderManager.ets
similarity index 60%
rename from entry/src/main/ets/MainAbility/glide/holder/PlaceHolderManager.ets
rename to imageknife/src/main/ets/components/imageknife/holder/PlaceHolderManager.ets
index 680ad77..56d711d 100644
--- a/entry/src/main/ets/MainAbility/glide/holder/PlaceHolderManager.ets
+++ b/imageknife/src/main/ets/components/imageknife/holder/PlaceHolderManager.ets
@@ -12,13 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {RequestOption} from "../../glide/RequestOption.ets"
-import {ResourceTypeEts} from "../../glide/constants/ResourceTypeEts.ets"
-import {Base64} from "../../cache/Base64.ets"
-import {FileTypeUtil} from "../../glide/utils/FileTypeUtil.ets"
-import {GlideData} from "../GlideData.ets"
-import {ParseImageUtil} from '../utils/ParseImageUtil.ets'
-import {ParseResClient} from '../resourcemanage/ParseResClient.ets'
+import {RequestOption} from "../../imageknife/RequestOption"
+import {ResourceTypeEts} from "../../imageknife/constants/ResourceTypeEts"
+import {Base64} from "../../cache/Base64"
+import {FileTypeUtil} from "../../imageknife/utils/FileTypeUtil"
+import {ImageKnifeData} from "../ImageKnifeData"
+import {ParseImageUtil} from '../utils/ParseImageUtil'
+import {ParseResClient} from '../resourcemanage/ParseResClient'
import resourceManager from '@ohos.resourceManager';
import image from "@ohos.multimedia.image"
@@ -41,11 +41,11 @@ export class PlaceHolderManager {
private displayPlaceholder(onComplete, onError) {
console.log("displayPlaceholder")
- if (this.options.placeholderSrc instanceof image.PixelMap) {
- let glidedata = new GlideData();
- glidedata.glideType = GlideData.PIXELMAP
- glidedata.glideValue = this.options.placeholderSrc as PixelMap
- onComplete(glidedata);
+ if ((typeof (this.options.placeholderSrc as image.PixelMap).isEditable) == 'boolean') {
+ let imageKnifeData = new ImageKnifeData();
+ imageKnifeData.imageKnifeType = ImageKnifeData.PIXELMAP
+ imageKnifeData.imageKnifeValue = this.options.placeholderSrc as PixelMap
+ onComplete(imageKnifeData);
} else if (typeof this.options.placeholderSrc == 'string') {
} else {
@@ -56,13 +56,13 @@ export class PlaceHolderManager {
let fileTypeUtil = new FileTypeUtil();
let typeValue = fileTypeUtil.getFileType(arraybuffer);
if ("gif" == typeValue || "svg" == typeValue) {
- let glidedata = this.createGlideData("Resource", this.options.placeholderSrc as Resource, typeValue);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData("Resource", this.options.placeholderSrc as Resource, typeValue);
+ onComplete(imageKnifeData);
} else {
let parseImageUtils = new ParseImageUtil();
let success = (value: PixelMap) => {
- let glidedata = this.createGlideData('PixelMap', value, typeValue);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData('PixelMap', value, typeValue);
+ onComplete(imageKnifeData);
}
parseImageUtils.parseImage(arraybuffer, success, onError)
}
@@ -73,11 +73,11 @@ export class PlaceHolderManager {
}
}
}
- private createGlideData(glideType:string, glideValue:PixelMap|string|Resource, glideSourceType:string):GlideData{
- let glidedata = new GlideData();
- glidedata.glideType = glideType;
- glidedata.glideValue = glideValue;
- glidedata.glideSourceType = glideSourceType;
- return glidedata;
+ private createImageKnifeData(imageKnifeType:string, imageKnifeValue:PixelMap|string|Resource, imageKnifeSourceType:string):ImageKnifeData{
+ let imageKnifeData = new ImageKnifeData();
+ imageKnifeData.imageKnifeType = imageKnifeType;
+ imageKnifeData.imageKnifeValue = imageKnifeValue;
+ imageKnifeData.imageKnifeSourceType = imageKnifeSourceType;
+ return imageKnifeData;
}
}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/interface/AsyncCallback.ets b/imageknife/src/main/ets/components/imageknife/interface/AsyncCallback.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/interface/AsyncCallback.ets
rename to imageknife/src/main/ets/components/imageknife/interface/AsyncCallback.ets
diff --git a/entry/src/main/ets/MainAbility/glide/interface/AsyncSuccess.ets b/imageknife/src/main/ets/components/imageknife/interface/AsyncSuccess.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/interface/AsyncSuccess.ets
rename to imageknife/src/main/ets/components/imageknife/interface/AsyncSuccess.ets
diff --git a/entry/src/main/ets/MainAbility/glide/interface/DataCallBack.ets b/imageknife/src/main/ets/components/imageknife/interface/DataCallBack.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/interface/DataCallBack.ets
rename to imageknife/src/main/ets/components/imageknife/interface/DataCallBack.ets
diff --git a/entry/src/main/ets/MainAbility/glide/interface/IAllCacheInfoCallback.ets b/imageknife/src/main/ets/components/imageknife/interface/IAllCacheInfoCallback.ets
similarity index 90%
rename from entry/src/main/ets/MainAbility/glide/interface/IAllCacheInfoCallback.ets
rename to imageknife/src/main/ets/components/imageknife/interface/IAllCacheInfoCallback.ets
index d50ddbf..9643f5f 100644
--- a/entry/src/main/ets/MainAbility/glide/interface/IAllCacheInfoCallback.ets
+++ b/imageknife/src/main/ets/components/imageknife/interface/IAllCacheInfoCallback.ets
@@ -13,12 +13,12 @@
* limitations under the License.
*/
-import {GlideData} from "../../glide/glidedata.ets"
+import {ImageKnifeData} from "../../imageknife/ImageKnifeData"
export class AllCacheInfo {
memoryCacheInfo: {
key: string,
- data: GlideData
+ data: ImageKnifeData
}
resourceCacheInfo: {
diff --git a/entry/src/main/ets/MainAbility/glide/interface/IParseImage.ets b/imageknife/src/main/ets/components/imageknife/interface/IParseImage.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/interface/IParseImage.ets
rename to imageknife/src/main/ets/components/imageknife/interface/IParseImage.ets
diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets
new file mode 100644
index 0000000..f4713c6
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {IDataFetch} from "../networkmanage/IDataFetch"
+import {RequestOption} from "../RequestOption"
+import {Md5} from "../../cache/Md5"
+import{FileUtils} from "../../cache/FileUtils"
+
+import loadRequest from '@ohos.request';
+
+export class DownloadClient implements IDataFetch {
+ loadData(request: RequestOption, onCompleteFunction, onErrorFunction) {
+
+ let requestUrl = request.loadSrc as string;
+ if (requestUrl.startsWith("http") || requestUrl.startsWith("https")) {
+ let filename = Md5.hashStr(request.generateDataKey);
+ let downloadFolder = request.getFilesPath() + "/" + request.networkCacheFolder;
+ let allpath = request.getFilesPath() + "/" + request.networkCacheFolder + "/" + filename + ".img";
+
+ if (!FileUtils.getInstance().existFolder(downloadFolder)) {
+ FileUtils.getInstance().createFolder(downloadFolder)
+ }
+
+ if (FileUtils.getInstance().exist(allpath)) {
+ FileUtils.getInstance().deleteFile(allpath)
+ }
+
+ let desc = filename + ".img";
+
+ var downloadConfig = {
+ url: (request.loadSrc as string),
+ filePath: allpath,
+ header: {},
+ enableMetered: true,
+ enableRoaming: true,
+ description: desc,
+ networkType: 1,
+ title: filename,
+ };
+
+ let loadTask = null;
+ loadRequest.download(downloadConfig, (err, downloadTask) =>{
+ if(err){
+ onErrorFunction(err)
+ }else {
+ if (downloadTask) {
+ loadTask = downloadTask;
+
+ loadTask.on('progress', (err, receivedSize, totalSize) => {
+ let percent = Math.round(((receivedSize * 1.0) / (totalSize * 1.0)) * 100) + "%"
+ if (request.progressFunc) {
+ request.progressFunc(percent);
+ }
+ });
+
+ loadTask.on('complete', () => {
+ let downloadPath = allpath;
+ request.downloadFilePath = downloadPath;
+ let arraybuffer = FileUtils.getInstance().readFilePic(downloadPath)
+ onCompleteFunction(arraybuffer);
+ FileUtils.getInstance().deleteFile(downloadPath);
+
+ loadTask.off('complete', () => {
+ loadTask = null;
+ })
+
+ loadTask.off('pause', () => {
+ })
+
+ loadTask.off('remove', () => {
+ })
+
+ loadTask.off('progress', () => {
+ })
+
+ loadTask.off('fail', () => {
+ })
+ })
+
+ loadTask.on('pause', () => {
+ })
+
+ loadTask.on('remove', () => {
+ })
+
+ loadTask.on('fail', (err) => {
+ onErrorFunction('DownloadClient Download task fail err =' + err)
+ if (loadTask) {
+ loadTask.remove().then(result => {
+ loadTask.off('complete', () => {
+ })
+
+ loadTask.off('pause', () => {
+ })
+
+ loadTask.off('remove', () => {
+ })
+
+ loadTask.off('progress', () => {
+ })
+
+ loadTask.off('fail', () => {
+ })
+ loadTask = null
+ }).catch(err => {
+ loadTask = null;
+ console.log('DownloadClient Download task fail err =' + err);
+ })
+ }
+ })
+
+ } else {
+ onErrorFunction('DownloadClient downloadTask dismiss!')
+ }
+ }
+ })
+
+ } else {
+ onErrorFunction("DownloadClient 暂不支持除http之外的uri加载")
+ }
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/networkmanage/IDataFetch.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets
similarity index 93%
rename from entry/src/main/ets/MainAbility/glide/networkmanage/IDataFetch.ets
rename to imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets
index 1900c36..cb25d56 100644
--- a/entry/src/main/ets/MainAbility/glide/networkmanage/IDataFetch.ets
+++ b/imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-import {RequestOption} from "../RequestOption.ets"
+import {RequestOption} from "../RequestOption"
// 网络接口
export interface IDataFetch {
diff --git a/imageknife/src/main/ets/components/imageknife/pngj/PngCallback.ets b/imageknife/src/main/ets/components/imageknife/pngj/PngCallback.ets
new file mode 100644
index 0000000..54d0bbd
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/pngj/PngCallback.ets
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export interface PngCallback{
+ (sender:R, receover:T)
+}
\ No newline at end of file
diff --git a/imageknife/src/main/ets/components/imageknife/pngj/PngReader.ets b/imageknife/src/main/ets/components/imageknife/pngj/PngReader.ets
new file mode 100644
index 0000000..26c2934
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/pngj/PngReader.ets
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {Closeable} from "/imageknife/pngj/io/Closeable"
+import {ImageInfo} from "/imageknife/pngj/entry/ImageInfo"
+
+export class PngReader implements Closeable {
+ private static LOG_TAG: string= "PngReader";
+ private static MAX_TOTAL_BYTES_READ_DEFAULT: number= 901001001;
+ private static MAX_BYTES_METADATA_DEFAULT: number= 5024024;
+ private static MAX_CHUNK_SIZE_SKIP: number= 2024024;
+ public imgInfo: ImageInfo;
+ public interlaced: boolean;
+
+ constructor(shouldCloseStream: boolean) {
+
+ }
+
+ close(): void {
+ }
+}
\ No newline at end of file
diff --git a/imageknife/src/main/ets/components/imageknife/pngj/PngWork.js b/imageknife/src/main/ets/components/imageknife/pngj/PngWork.js
new file mode 100644
index 0000000..a51628e
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/pngj/PngWork.js
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import arkWorker from '@ohos.worker';
+import {UPNG} from '../../imageknife/pngj/UPNG'
+
+export function handler (e) {
+ var data = e.data;
+ switch (data.type) {
+ case 'readPngImageAsync':
+ var png = UPNG.decode(data.data);
+ let array = png.data;
+ let arrayData = array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset)
+ png.data = arrayData;
+ let dataObj = { type: 'readPngImageAsync', data: png, receiver: data.data}
+ arkWorker.parentPort.postMessage(dataObj, [png.data, data.data]);
+ break;
+ case 'writePngWithStringAsync':
+ let addInfo = data.info;
+ let pngDecode = UPNG.decode(data.data);
+ let newPng = UPNG.encodeWithString(addInfo, UPNG.toRGBA8(pngDecode), pngDecode.width, pngDecode.height, 0)
+ let dataObj2 = { type: 'writePngWithStringAsync', data: newPng, receiver: data.data}
+ arkWorker.parentPort.postMessage(dataObj2, [newPng, data.data]);
+ break;
+ case 'writePngAsync':
+ let pngDecode3 = UPNG.decode(data.data);
+ let newPng3 = UPNG.encode(UPNG.toRGBA8(pngDecode3), pngDecode3.width, pngDecode3.height, 0)
+ let dataObj3 = { type: 'writePngAsync', data: newPng3, receiver: data.data}
+ arkWorker.parentPort.postMessage(dataObj3, [newPng3, data.data]);
+ break;
+ case 'normal':
+ arkWorker.parentPort.postMessage(data);
+ break;
+ case 'error':
+ throw new Error('123');
+ break;
+ case 'buffer':
+ let uint8Array = new Uint8Array(data.data);
+ arkWorker.parentPort.postMessage(data, [data.data]);
+
+ break;
+ default:
+
+ break
+ }
+}
+
+
diff --git a/imageknife/src/main/ets/components/imageknife/pngj/Pngj.ets b/imageknife/src/main/ets/components/imageknife/pngj/Pngj.ets
new file mode 100644
index 0000000..05ac328
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/pngj/Pngj.ets
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {UPNG} from '../pngj/UPNG';
+import {PngCallback} from '../pngj/PngCallback';
+import image from '@ohos.multimedia.image';
+import resourceManager from '@ohos.resourceManager';
+import featureability from '@ohos.ability.featureAbility'
+import ArkWorker from '@ohos.worker'
+
+export class Pngj {
+ readPngImageInfo(arraybuffer: ArrayBuffer, callback:PngCallback) {
+ let imageSource = image.createImageSource(arraybuffer as any);
+ imageSource.getImageInfo((err, value) => {
+ if (err) {
+ return;
+ }
+ callback(arraybuffer, value);
+ });
+ }
+
+ /**
+ *
+ * @param pngBuffer ArrayBuffer containing the PNG file
+ * @param callback
+ * returns an image object with following properties:
+ * width: the width of the image
+ * height: the height of the image
+ * depth: number of bits per channel
+ * ctype: color type of the file (Truecolor, Grayscale, Palette ...)
+ * frames: additional info about frames (frame delays etc.)
+ * tabs: additional chunks of the PNG file
+ * data: pixel data of the image
+ */
+ readPngImage(pngBuffer: ArrayBuffer, callback:PngCallback) {
+ var png = UPNG.decode(pngBuffer);
+ callback(pngBuffer, png)
+ }
+
+ writePngWithString(addInfo:string, pngBuffer: ArrayBuffer,callback:PngCallback) {
+ var pngDecode = UPNG.decode(pngBuffer);
+ var newPng = UPNG.encodeWithString(addInfo, UPNG.toRGBA8(pngDecode), pngDecode.width, pngDecode.height, 0)
+ callback(pngBuffer, newPng);
+ }
+
+ writePng(pngBuffer: ArrayBuffer,callback:PngCallback) {
+ var pngDecode = UPNG.decode(pngBuffer);
+ var newPng = UPNG.encode(UPNG.toRGBA8(pngDecode), pngDecode.width, pngDecode.height, 0)
+ callback(pngBuffer, newPng);
+ }
+
+ readPngImageAsync(worker:ArkWorker.Worker, pngBuffer: ArrayBuffer, callback:PngCallback){
+
+ worker.onerror = function(data){
+
+ }
+
+ worker.onmessageerror = function(e){
+
+ }
+
+ worker.onexit = function(){
+
+ }
+
+ worker.onmessage = function(e) {
+ var data = e.data;
+ switch (data.type) {
+ case 'readPngImageAsync':
+ callback(data.receiver, data.data)
+ break;
+ default:
+ break
+ }
+ worker.terminate();
+ }
+
+ var obj = { type: 'readPngImageAsync', data:pngBuffer}
+ worker.postMessage(obj, [pngBuffer])
+
+ }
+
+
+ writePngWithStringAsync(worker:ArkWorker.Worker,addInfo:string, pngBuffer:ArrayBuffer, callback:PngCallback) {
+
+ worker.onerror = function(data){
+
+ }
+
+ worker.onmessageerror = function(e){
+
+ }
+
+ worker.onexit = function(){
+
+ }
+
+ worker.onmessage = function(e) {
+ var data = e.data;
+ switch (data.type) {
+ case 'writePngWithStringAsync':
+ callback(data.receiver, data.data)
+ break;
+ default:
+ break
+ }
+ worker.terminate();
+ }
+
+ var obj = { type: 'writePngWithStringAsync', data:pngBuffer, info: addInfo}
+ worker.postMessage(obj, [pngBuffer])
+
+ }
+
+
+ writePngAsync(worker:ArkWorker.Worker,pngBuffer:ArrayBuffer, callback:PngCallback) {
+
+ worker.onerror = function(data){
+
+ }
+
+ worker.onmessageerror = function(e){
+
+ }
+
+ worker.onexit = function(){
+
+ }
+
+ worker.onmessage = function(e) {
+ var data = e.data;
+ switch (data.type) {
+ case 'writePngAsync':
+ callback(data.receiver, data.data)
+ break;
+ default:
+ break
+ }
+ worker.terminate();
+ }
+
+ var obj = { type: 'writePngAsync', data:pngBuffer}
+ worker.postMessage(obj, [pngBuffer])
+
+ }
+
+}
\ No newline at end of file
diff --git a/imageknife/src/main/ets/components/imageknife/pngj/PngjException.ets b/imageknife/src/main/ets/components/imageknife/pngj/PngjException.ets
new file mode 100644
index 0000000..d35951c
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/pngj/PngjException.ets
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export class PngjException extends Error {
+ constructor(s: string) {
+ super(s)
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/pngj/UPNG.js b/imageknife/src/main/ets/components/imageknife/pngj/UPNG.js
similarity index 99%
rename from entry/src/main/ets/MainAbility/glide/pngj/UPNG.js
rename to imageknife/src/main/ets/components/imageknife/pngj/UPNG.js
index b6468ed..f5bd3ec 100644
--- a/entry/src/main/ets/MainAbility/glide/pngj/UPNG.js
+++ b/imageknife/src/main/ets/components/imageknife/pngj/UPNG.js
@@ -1775,7 +1775,6 @@ UPNG.quantize.estats = function (stats) {
if (i != 0 && Math.abs(tmi - mi) < 1e-9) break;
mi = tmi;
}
- //b = [0,0,1,0]; mi=N;
var q = [m0 * iN, m1 * iN, m2 * iN, m3 * iN];
var eMq255 = M.dot(M.sml(255, q), b);
diff --git a/entry/src/main/ets/MainAbility/glide/pngj/entry/ImageInfo.ets b/imageknife/src/main/ets/components/imageknife/pngj/entry/ImageInfo.ets
similarity index 89%
rename from entry/src/main/ets/MainAbility/glide/pngj/entry/ImageInfo.ets
rename to imageknife/src/main/ets/components/imageknife/pngj/entry/ImageInfo.ets
index fdf7a38..9de32ec 100644
--- a/entry/src/main/ets/MainAbility/glide/pngj/entry/ImageInfo.ets
+++ b/imageknife/src/main/ets/components/imageknife/pngj/entry/ImageInfo.ets
@@ -1,4 +1,18 @@
-import {PngjException} from "../PngjException.ets"
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {PngjException} from "../PngjException"
export class ImageInfo {
private static MAX_COLS_ROW: number= 16777216;
diff --git a/imageknife/src/main/ets/components/imageknife/pngj/interface/IBytesConsumer.ets b/imageknife/src/main/ets/components/imageknife/pngj/interface/IBytesConsumer.ets
new file mode 100644
index 0000000..5607f29
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/pngj/interface/IBytesConsumer.ets
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export interface IBytesConsumer {
+ isDone(): boolean;
+
+ consume(buf: ArrayBuffer, offset: number, len: number): number;
+}
\ No newline at end of file
diff --git a/imageknife/src/main/ets/components/imageknife/pngj/io/Closeable.ets b/imageknife/src/main/ets/components/imageknife/pngj/io/Closeable.ets
new file mode 100644
index 0000000..0ba92ac
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/pngj/io/Closeable.ets
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export interface Closeable {
+ close(): void;
+}
\ No newline at end of file
diff --git a/imageknife/src/main/ets/components/imageknife/pngj/misc/Sandbox.ets b/imageknife/src/main/ets/components/imageknife/pngj/misc/Sandbox.ets
new file mode 100644
index 0000000..b294cf9
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/pngj/misc/Sandbox.ets
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export class Sandbox {
+
+
+ public static convert(origFileName: string, destFileName: string) {
+
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/requestmanage/DiskCacheProxy.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets
similarity index 92%
rename from entry/src/main/ets/MainAbility/glide/requestmanage/DiskCacheProxy.ets
rename to imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets
index 3234bf1..4da069b 100644
--- a/entry/src/main/ets/MainAbility/glide/requestmanage/DiskCacheProxy.ets
+++ b/imageknife/src/main/ets/components/imageknife/requestmanage/DiskCacheProxy.ets
@@ -13,8 +13,8 @@
* limitations under the License.
*/
-import {ICache} from "../requestmanage/ICache.ets"
-import {DiskLruCache} from "../../cache/DiskLruCache.ets"
+import {ICache} from "../requestmanage/ICache"
+import {DiskLruCache} from "../../cache/DiskLruCache"
export class DiskCacheProxy implements ICache {
private mDiskLruCache: DiskLruCache;
diff --git a/entry/src/main/ets/MainAbility/glide/requestmanage/ICache.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/ICache.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/requestmanage/ICache.ets
rename to imageknife/src/main/ets/components/imageknife/requestmanage/ICache.ets
diff --git a/entry/src/main/ets/MainAbility/glide/requestmanage/MemoryCacheProxy.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets
similarity index 96%
rename from entry/src/main/ets/MainAbility/glide/requestmanage/MemoryCacheProxy.ets
rename to imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets
index 18996b4..691404d 100644
--- a/entry/src/main/ets/MainAbility/glide/requestmanage/MemoryCacheProxy.ets
+++ b/imageknife/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-import {ICache} from "../requestmanage/ICache.ets"
+import {ICache} from "../requestmanage/ICache"
import {LruCache} from "../../cache/LruCache"
export class MemoryCacheProxy implements ICache {
diff --git a/entry/src/main/ets/MainAbility/glide/requestmanage/RequstManager.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/RequstManager.ets
similarity index 78%
rename from entry/src/main/ets/MainAbility/glide/requestmanage/RequstManager.ets
rename to imageknife/src/main/ets/components/imageknife/requestmanage/RequstManager.ets
index 9da4eaa..a3573d8 100644
--- a/entry/src/main/ets/MainAbility/glide/requestmanage/RequstManager.ets
+++ b/imageknife/src/main/ets/components/imageknife/requestmanage/RequstManager.ets
@@ -13,20 +13,20 @@
* limitations under the License.
*/
-import {RequestOption} from "../../glide/RequestOption.ets"
-import {DiskLruCache} from "../../cache/DiskLruCache.ets"
+import {RequestOption} from "../../imageknife/RequestOption"
+import {DiskLruCache} from "../../cache/DiskLruCache"
import {LruCache} from "../../cache/LruCache"
-import {FileUtils} from "../../cache/FileUtils.ets"
-import {Md5} from "../../cache/Md5.ets"
-import{MemoryCacheProxy} from "../requestmanage/MemoryCacheProxy.ets"
-import{DiskCacheProxy} from "../requestmanage/DiskCacheProxy.ets"
-import{FileTypeUtil} from "../utils/FileTypeUtil.ets"
-import{IDataFetch} from "../../glide/networkmanage/IDataFetch.ets"
-import{IResourceFetch} from "../../glide/resourcemanage/IResourceFetch.ets"
-import{GlideData} from "../GlideData.ets"
-import {AllCacheInfo, IAllCacheInfoCallback} from "../../glide/interface/iallcacheinfocallback.ets"
+import {FileUtils} from "../../cache/FileUtils"
+import {Md5} from "../../cache/Md5"
+import{MemoryCacheProxy} from "../requestmanage/MemoryCacheProxy"
+import{DiskCacheProxy} from "../requestmanage/DiskCacheProxy"
+import{FileTypeUtil} from "../utils/FileTypeUtil"
+import{IDataFetch} from "../../imageknife/networkmanage/IDataFetch"
+import{IResourceFetch} from "../../imageknife/resourcemanage/IResourceFetch"
+import{ImageKnifeData} from "../ImageKnifeData"
+import {AllCacheInfo, IAllCacheInfoCallback} from "../../imageknife/interface/IAllCacheInfoCallback"
import{ParseImageUtil} from '../utils/ParseImageUtil'
-import{IParseImage} from '../interface/IParseImage.ets'
+import{IParseImage} from '../interface/IParseImage'
import image from "@ohos.multimedia.image"
export interface AsyncString {
@@ -198,7 +198,7 @@ export class RequestManager {
let fileTypeUtil = new FileTypeUtil();
let typeValue = fileTypeUtil.getFileType(arrayBuffer)
console.log("RequstManager - 文件类型为= " + typeValue)
- if ((GlideData.GIF == typeValue && !request.dontAnimateFlag) || GlideData.SVG == typeValue) {
+ if ((ImageKnifeData.GIF == typeValue && !request.dontAnimateFlag) || ImageKnifeData.SVG == typeValue) {
// 将图片资源 转换为文件地址
let folderPath = this.options.getFilesPath() + "/" + this.options._svgAndGifFolder;
let filePath = this.options.getFilesPath() + "/" + this.options._svgAndGifFolder + "/"
@@ -217,22 +217,22 @@ export class RequestManager {
.writeData(this.options.getFilesPath() +
"/" + this.options._svgAndGifFolder + "/" + this.options._svgAndGifCommitFile, filename + "\n");
console.log("svg gif 本地保存成功 输出!");
- let glidedata = this.createGlideData(GlideData.STRING, filePath, typeValue);
- this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.STRING, filePath, typeValue);
+ this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
})
.catch((err) => {
onError(err)
})
}
else {
- if (request.transformtions[0]) {
- request.transformtions[0].transform(arrayBuffer, request, (error, pixelMap: PixelMap) => {
+ if (request.transformations[0]) {
+ request.transformations[0].transform(arrayBuffer, request, (error, pixelMap: PixelMap) => {
// 输出给Image
if (pixelMap) {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, pixelMap, typeValue);
- this.mMemoryCacheProxy.putValue(request.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, pixelMap, typeValue);
+ this.mMemoryCacheProxy.putValue(request.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
} else {
onError(error);
}
@@ -240,9 +240,9 @@ export class RequestManager {
}
else {
let success = (value: PixelMap) => {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, value, typeValue);
- this.mMemoryCacheProxy.putValue(request.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, value, typeValue);
+ this.mMemoryCacheProxy.putValue(request.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
}
this.mParseImageUtil.parseImage(arrayBuffer, success, onError)
}
@@ -276,7 +276,7 @@ export class RequestManager {
parseSource(request: RequestOption, onComplete, onError) {
console.log("RequestManager parseSource")
- if (request.loadSrc instanceof image.PixelMap) {
+ if ((typeof (request.loadSrc as image.PixelMap).isEditable) == 'boolean') {
// PixelMap 外层捕获效率更高,不会进入这里
} else if (typeof request.loadSrc == 'string') {
this.loadSourceFromNetwork(request, onComplete, onError);
@@ -310,7 +310,7 @@ export class RequestManager {
// 步骤一:文件转为pixelMap 然后变换 给Image组件
let fileTypeUtil = new FileTypeUtil();
let typeValue = fileTypeUtil.getFileType(source);
- if (((GlideData.GIF == typeValue && !request.dontAnimateFlag) || GlideData.SVG == typeValue)) {
+ if (((ImageKnifeData.GIF == typeValue && !request.dontAnimateFlag) || ImageKnifeData.SVG == typeValue)) {
// 将图片资源 转换为文件地址
let folderPath = this.options.getFilesPath() + "/" + this.options._svgAndGifFolder;
let filePath = this.options.getFilesPath() + "/" + this.options._svgAndGifFolder + "/"
@@ -325,16 +325,16 @@ export class RequestManager {
FileUtils.getInstance()
.writeData(this.options.getFilesPath() +
"/" + this.options._svgAndGifFolder + "/" + this.options._svgAndGifCommitFile, filename + "\n");
- let glidedata = this.createGlideData(GlideData.STRING, filePath, typeValue)
- this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.STRING, filePath, typeValue)
+ this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
})
.catch((err) => {
onError(err)
})
} else {
- if (this.options.transformtions[0]) {
+ if (this.options.transformations[0]) {
if (this.options.thumbSizeMultiplier) {
let thumbOption = new RequestOption();
thumbOption.setImageViewSize({
@@ -343,21 +343,21 @@ export class RequestManager {
})
let thumbCallback = this.options.thumbholderOnComplete.bind(this.options);
let thumbError = this.options.thumbholderOnError.bind(this.options);
- this.options.transformtions[0].transform(source, thumbOption, (error, pixelMap: PixelMap) => {
+ this.options.transformations[0].transform(source, thumbOption, (error, pixelMap: PixelMap) => {
if (pixelMap) {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, pixelMap, typeValue);
- thumbCallback(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, pixelMap, typeValue);
+ thumbCallback(imageKnifeData);
} else {
thumbError(error);
}
})
setTimeout(()=>{
- this.options.transformtions[0].transform(source, request, (error, pixelMap: PixelMap) => {
+ this.options.transformations[0].transform(source, request, (error, pixelMap: PixelMap) => {
if (pixelMap) {
// 保存一份变换后的图片PixelMap到MemoryCache
- let glidedata = this.createGlideData(GlideData.PIXELMAP, pixelMap, typeValue);
- this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, pixelMap, typeValue);
+ this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
} else {
onError(error);
}
@@ -365,12 +365,12 @@ export class RequestManager {
},this.options.thumbDelayTime);
}
else {
- this.options.transformtions[0].transform(source, request, (error, pixelMap: PixelMap) => {
+ this.options.transformations[0].transform(source, request, (error, pixelMap: PixelMap) => {
if (pixelMap) {
// 保存一份变换后的图片PixelMap到MemoryCache
- let glidedata = this.createGlideData(GlideData.PIXELMAP, pixelMap, typeValue);
- this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, pixelMap, typeValue);
+ this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
} else {
onError(error);
}
@@ -382,24 +382,24 @@ export class RequestManager {
let thumbCallback = this.options.thumbholderOnComplete.bind(this.options);
let thumbError = this.options.thumbholderOnError.bind(this.options);
let thumbSuccess = (value: PixelMap) => {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, value, typeValue);
- thumbCallback(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, value, typeValue);
+ thumbCallback(imageKnifeData);
}
this.mParseImageUtil.parseImageThumbnail(request.thumbSizeMultiplier, source, thumbSuccess, thumbError);
setTimeout(()=>{
let success = (value: PixelMap) => {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, value, typeValue);
- this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, value, typeValue);
+ this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
}
this.mParseImageUtil.parseImage(source, success, onError)
},this.options.thumbDelayTime)
}
else {
let success = (value: PixelMap) => {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, value, typeValue);
- this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, value, typeValue);
+ this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
}
this.mParseImageUtil.parseImage(source, success, onError)
}
@@ -416,23 +416,23 @@ export class RequestManager {
let thumbCallback = this.options.thumbholderOnComplete.bind(this.options);
let thumbError = this.options.thumbholderOnError.bind(this.options);
let thumbSuccess = (value: PixelMap) => {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, value, typeValue);
- thumbCallback(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, value, typeValue);
+ thumbCallback(imageKnifeData);
}
this.mParseImageUtil.parseImageThumbnail(request.thumbSizeMultiplier, source, thumbSuccess, thumbError);
setTimeout(()=>{
let success = (value: PixelMap) => {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, value, typeValue);
- this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, value, typeValue);
+ this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
}
this.mParseImageUtil.parseImage(source, success, onError)
},this.options.thumbDelayTime)
}else{
let success = (value: PixelMap) => {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, value, typeValue)
- this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, value, typeValue)
+ this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
}
this.mParseImageUtil.parseImage(source, success, onError)
}
@@ -441,6 +441,11 @@ export class RequestManager {
private downloadSuccess(source: ArrayBuffer, onComplete, onError) {
console.info('Download task completed.');
+ if(source == null || source == undefined || source.byteLength <= 0){
+ onError('Download task completed. but download file is empty!')
+ return
+ }
+
// 下载成功之后 去data/data/包名/唯一路径/文件名 读取数据
// 步骤一:文件转为pixelMap 然后变换 给Image组件
// 步骤二: 文件名保存一份全局
@@ -451,7 +456,7 @@ export class RequestManager {
onError("暂不支持 下载文件类型!类型=" + filetype);
return;
}
- if ((GlideData.GIF == filetype && !this.options.dontAnimateFlag) || GlideData.SVG == filetype) {
+ if ((ImageKnifeData.GIF == filetype && !this.options.dontAnimateFlag) || ImageKnifeData.SVG == filetype) {
// 将图片资源 转换为文件地址
let folderPath = this.options.getFilesPath() + "/" + this.options._svgAndGifFolder;
let filePath = this.options.getFilesPath() + "/" + this.options._svgAndGifFolder + "/"
@@ -468,9 +473,9 @@ export class RequestManager {
FileUtils.getInstance()
.writeData(this.options.getFilesPath() +
"/" + this.options._svgAndGifFolder + "/" + this.options._svgAndGifCommitFile, filename + "\n");
- let glidedata = this.createGlideData(GlideData.STRING, filePath, filetype);
- this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, glidedata);
- onComplete(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.STRING, filePath, filetype);
+ this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData);
+ onComplete(imageKnifeData);
})
.catch((err) => {
onError(err)
@@ -484,16 +489,16 @@ export class RequestManager {
this.mDiskCacheProxy.putValue(this.options.generateDataKey, arraybuffer)
})
.catch((err) => {
- console.log("err=" + err);
+ console.log("save diskLruCache error=" + err);
})
} else {
// 进行变换
- if (this.options.transformtions[0]) {
+ if (this.options.transformations[0]) {
// thumbnail 缩略图部分
if (this.options.thumbSizeMultiplier) {
this.thumbnailProcess(source, filetype, onComplete, onError);
} else {
- this.options.transformtions[0].transform(source, this.options, (error, pixelMap: PixelMap) => {
+ this.options.transformations[0].transform(source, this.options, (error, pixelMap: PixelMap) => {
if (pixelMap) {
this.saveCacheAndDisk(pixelMap, filetype, onComplete, source);
} else {
@@ -507,8 +512,8 @@ export class RequestManager {
let thumbCallback = this.options.thumbholderOnComplete.bind(this.options);
let thumbError = this.options.thumbholderOnError.bind(this.options);
let thumbSuccess = (value: PixelMap) => {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, value, filetype);
- thumbCallback(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, value, filetype);
+ thumbCallback(imageKnifeData);
}
this.mParseImageUtil.parseImageThumbnail(this.options.thumbSizeMultiplier, source, thumbSuccess, thumbError);
setTimeout(() => {
@@ -528,17 +533,17 @@ export class RequestManager {
}
- createGlideData(glideType:string, glideValue:PixelMap|string|Resource, glideSourceType:string):GlideData{
- let glidedata = new GlideData();
- glidedata.glideType = glideType;
- glidedata.glideValue = glideValue;
- glidedata.glideSourceType = glideSourceType;
- return glidedata;
+ createImageKnifeData(imageKnifeType:string, imageKnifeValue:PixelMap|string|Resource, imageKnifeSourceType:string):ImageKnifeData{
+ let imageKnifeData = new ImageKnifeData();
+ imageKnifeData.imageKnifeType = imageKnifeType;
+ imageKnifeData.imageKnifeValue = imageKnifeValue;
+ imageKnifeData.imageKnifeSourceType = imageKnifeSourceType;
+ return imageKnifeData;
}
private saveCacheAndDisk(value: PixelMap, filetype:string, onComplete, source:ArrayBuffer){
- let glidedata = this.createGlideData(GlideData.PIXELMAP, value, filetype);
- this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, value, filetype);
+ this.mMemoryCacheProxy.putValue(this.options.generateCacheKey, imageKnifeData);
let save2DiskCache = (arraybuffer) => {
this.mDiskCacheProxy.putValue(this.options.generateDataKey, arraybuffer)
}
@@ -547,7 +552,7 @@ export class RequestManager {
}
let promise = new Promise(runSave2Disk);
promise.then(save2DiskCache);
- onComplete(glidedata);
+ onComplete(imageKnifeData);
}
thumbnailProcess(source:ArrayBuffer, filetype:string, onComplete, onError){
@@ -558,16 +563,16 @@ export class RequestManager {
})
let thumbCallback = this.options.thumbholderOnComplete.bind(this.options);
let thumbError = this.options.thumbholderOnError.bind(this.options);
- this.options.transformtions[0].transform(source, thumbOption, (error, pixelMap: PixelMap) => {
+ this.options.transformations[0].transform(source, thumbOption, (error, pixelMap: PixelMap) => {
if (pixelMap) {
- let glidedata = this.createGlideData(GlideData.PIXELMAP, pixelMap, filetype);
- thumbCallback(glidedata);
+ let imageKnifeData = this.createImageKnifeData(ImageKnifeData.PIXELMAP, pixelMap, filetype);
+ thumbCallback(imageKnifeData);
} else {
thumbError(error);
}
})
setTimeout(() => {
- this.options.transformtions[0].transform(source, this.options, (error, pixelMap: PixelMap) => {
+ this.options.transformations[0].transform(source, this.options, (error, pixelMap: PixelMap) => {
if (pixelMap) {
this.saveCacheAndDisk(pixelMap, filetype, onComplete, source);
} else {
diff --git a/entry/src/main/ets/MainAbility/glide/resourcemanage/IResourceFetch.ets b/imageknife/src/main/ets/components/imageknife/resourcemanage/IResourceFetch.ets
similarity index 93%
rename from entry/src/main/ets/MainAbility/glide/resourcemanage/IResourceFetch.ets
rename to imageknife/src/main/ets/components/imageknife/resourcemanage/IResourceFetch.ets
index 872cc53..3ed14c4 100644
--- a/entry/src/main/ets/MainAbility/glide/resourcemanage/IResourceFetch.ets
+++ b/imageknife/src/main/ets/components/imageknife/resourcemanage/IResourceFetch.ets
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-import {RequestOption} from "../RequestOption.ets"
+import {RequestOption} from "../RequestOption"
// 本地资源解析抽象接口
export interface IResourceFetch {
diff --git a/entry/src/main/ets/MainAbility/glide/resourcemanage/ParseResClient.ets b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets
similarity index 92%
rename from entry/src/main/ets/MainAbility/glide/resourcemanage/ParseResClient.ets
rename to imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets
index eab8aa4..ab6b314 100644
--- a/entry/src/main/ets/MainAbility/glide/resourcemanage/ParseResClient.ets
+++ b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClient.ets
@@ -13,8 +13,8 @@
* limitations under the License.
*/
-import {IResourceFetch} from '../resourcemanage/IResourceFetch.ets'
-import {ResourceTypeEts} from '../../glide/constants/ResourceTypeEts.ets'
+import {IResourceFetch} from '../resourcemanage/IResourceFetch'
+import {ResourceTypeEts} from '../../imageknife/constants/ResourceTypeEts'
import resourceManager from '@ohos.resourceManager';
diff --git a/entry/src/main/ets/MainAbility/glide/resourcemanage/ParseResClientBase64.ets b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets
similarity index 90%
rename from entry/src/main/ets/MainAbility/glide/resourcemanage/ParseResClientBase64.ets
rename to imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets
index 40342cc..2ff7d02 100644
--- a/entry/src/main/ets/MainAbility/glide/resourcemanage/ParseResClientBase64.ets
+++ b/imageknife/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-import {IResourceFetch} from '../resourcemanage/IResourceFetch.ets'
-import {ResourceTypeEts} from '../../glide/constants/ResourceTypeEts.ets'
-import {Base64} from '../../cache/Base64.ets'
+import {IResourceFetch} from '../resourcemanage/IResourceFetch'
+import {ResourceTypeEts} from '../../imageknife/constants/ResourceTypeEts'
+import {Base64} from '../../cache/Base64'
import resourceManager from '@ohos.resourceManager';
diff --git a/entry/src/main/ets/MainAbility/glide/transform/AsyncTransform.ets b/imageknife/src/main/ets/components/imageknife/transform/AsyncTransform.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/transform/AsyncTransform.ets
rename to imageknife/src/main/ets/components/imageknife/transform/AsyncTransform.ets
diff --git a/entry/src/main/ets/MainAbility/glide/transform/BaseTransform.ets b/imageknife/src/main/ets/components/imageknife/transform/BaseTransform.ets
similarity index 86%
rename from entry/src/main/ets/MainAbility/glide/transform/BaseTransform.ets
rename to imageknife/src/main/ets/components/imageknife/transform/BaseTransform.ets
index 626c755..522f57d 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/BaseTransform.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/BaseTransform.ets
@@ -13,8 +13,8 @@
* limitations under the License.
*/
-import {AsyncTransform} from "../transform/AsyncTransform.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {AsyncTransform} from "../transform/AsyncTransform"
+import {RequestOption} from "../../imageknife/RequestOption"
export interface BaseTransform {
//实现类 返回作为key生成的一部分
diff --git a/entry/src/main/ets/MainAbility/glide/transform/BlurTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/BlurTransformation.ets
similarity index 95%
rename from entry/src/main/ets/MainAbility/glide/transform/BlurTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/BlurTransformation.ets
index 6216064..118b7f5 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/BlurTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/BlurTransformation.ets
@@ -16,7 +16,7 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import {TransformUtils} from "../transform/TransformUtils.ets"
import image from "@ohos.multimedia.image"
import {fastBlur} from "../utils/FastBlur"
@@ -41,7 +41,7 @@ export class BlurTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
TransformUtils.getPixelMapSize(imageSource, (error, size: {
width: number,
height: number
diff --git a/entry/src/main/ets/MainAbility/glide/transform/BrightnessFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/BrightnessFilterTransformation.ets
similarity index 59%
rename from entry/src/main/ets/MainAbility/glide/transform/BrightnessFilterTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/BrightnessFilterTransformation.ets
index f2001c1..bbd837d 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/BrightnessFilterTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/BrightnessFilterTransformation.ets
@@ -16,8 +16,7 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
-import {TransformUtils} from "../transform/TransformUtils.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import image from "@ohos.multimedia.image"
@@ -43,7 +42,7 @@ export class BrightnessFilterTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
let imageInfo = await imageSource.getImageInfo();
let size = {
@@ -74,58 +73,24 @@ export class BrightnessFilterTransformation implements BaseTransform {
}
}
let data = await imageSource.createPixelMap(options);
- let readPromise;
- let writePromise;
- for (let w = 0;w <= targetWidth; w++) {
- for (let h = 0;h <= targetHeight; h++) {
- var buffer = new ArrayBuffer(5);
+ let bufferData = new ArrayBuffer(data.getPixelBytesNumber());
+ await data.readPixelsToBuffer(bufferData);
- readPromise = new Promise((resolve, reject) => {
- var positionRen = {
- pixels: buffer,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- data.readPixels(positionRen, () => {
- resolve();
- });
- });
- await readPromise;
+ var dataArray = new Uint8Array(bufferData);
-
- writePromise = new Promise((resolve, reject) => {
- var bytes = new Uint8Array(buffer);
- var buffer1B = new ArrayBuffer(5);
- var bytes1B = new Uint8Array(buffer1B);
- var writePositionRenB = {
- pixels: buffer1B,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- bytes1B[0] = bytes[0];
- bytes1B[1] = this.checkVisAble(bytes[1] * this._mBrightness + bytes[1]);
- bytes1B[2] = this.checkVisAble(bytes[2] * this._mBrightness + bytes[2]);
- bytes1B[3] = this.checkVisAble(bytes[3] * this._mBrightness + bytes[3]);
- bytes1B[4] = bytes[4];
- data.writePixels(writePositionRenB, () => {
- resolve();
- });
- })
- await writePromise;
- }
+ for (let index = 0; index < dataArray.length; index += 4) {
+ dataArray[index] = this.checkVisAble(dataArray[index] * this._mBrightness + dataArray[index]);
+ dataArray[index+1] = this.checkVisAble(dataArray[index+1] * this._mBrightness + dataArray[index+1]);
+ dataArray[index+2] = this.checkVisAble(dataArray[index+2] * this._mBrightness + dataArray[index+2]);
+ dataArray[index+3] = this.checkVisAble(dataArray[index+3] * this._mBrightness + dataArray[index+3]);
}
- func("", data);
+ await data.writeBufferToPixels(bufferData);
+ if (func) {
+ func("", data);
+ }
}
private checkVisAble(input: number) {
diff --git a/entry/src/main/ets/MainAbility/glide/transform/ContrastFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/ContrastFilterTransformation.ets
similarity index 67%
rename from entry/src/main/ets/MainAbility/glide/transform/ContrastFilterTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/ContrastFilterTransformation.ets
index 29711b7..2eb7800 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/ContrastFilterTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/ContrastFilterTransformation.ets
@@ -16,7 +16,7 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import image from "@ohos.multimedia.image"
@@ -54,7 +54,7 @@ export class ContrastFilterTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
let imageInfo = await imageSource.getImageInfo();
let size = {
@@ -86,58 +86,24 @@ export class ContrastFilterTransformation implements BaseTransform {
}
let data = await imageSource.createPixelMap(options);
- let readPromise;
- let writePromise;
- for (let w = 0;w <= targetWidth; w++) {
- for (let h = 0;h <= targetHeight; h++) {
- var buffer = new ArrayBuffer(5);
- readPromise = new Promise((resolve, reject) => {
- var positionRen = {
- pixels: buffer,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- data.readPixels(positionRen, () => {
- resolve();
- });
- });
- await readPromise;
+ let bufferData = new ArrayBuffer(data.getPixelBytesNumber());
+ await data.readPixelsToBuffer(bufferData);
- writePromise = new Promise((resolve, reject) => {
- var bytes = new Uint8Array(buffer);
- var buffer1B = new ArrayBuffer(5);
- var bytes1B = new Uint8Array(buffer1B);
- var writePositionRenB = {
- pixels: buffer1B,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- let brightness = 0; //亮度的偏移量,可以默认0
+ var dataArray = new Uint8Array(bufferData);
- bytes1B[0] = bytes[0];
- bytes1B[1] = this.checkVisAble((bytes[1] - 127) * this._mContrast + brightness + 127);
- bytes1B[2] = this.checkVisAble((bytes[2] - 127) * this._mContrast + brightness + 127);
- bytes1B[3] = this.checkVisAble((bytes[3] - 127) * this._mContrast + brightness + 127);
- bytes1B[4] = bytes[4];
- data.writePixels(writePositionRenB, () => {
- resolve();
- });
- })
- await writePromise;
- }
+ let brightness = 0; //亮度的偏移量,可以默认0
+ for (let index = 0; index < dataArray.length; index += 4) {
+ dataArray[index] = this.checkVisAble((dataArray[index] - 127) * this._mContrast + brightness + 127);
+ dataArray[index+1] = this.checkVisAble((dataArray[index+1] - 127) * this._mContrast + brightness + 127);
+ dataArray[index+2] = this.checkVisAble((dataArray[index+2] - 127) * this._mContrast + brightness + 127);
+ dataArray[index+3] = this.checkVisAble((dataArray[index+3] - 127) * this._mContrast + brightness + 127);
}
- func("", data);
-
+ await data.writeBufferToPixels(bufferData);
+ if (func) {
+ func("", data);
+ }
}
private checkVisAble(input: number) {
diff --git a/entry/src/main/ets/MainAbility/glide/transform/CropCircleTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/CropCircleTransformation.ets
similarity index 73%
rename from entry/src/main/ets/MainAbility/glide/transform/CropCircleTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/CropCircleTransformation.ets
index e5a4f2d..6bec794 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/CropCircleTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/CropCircleTransformation.ets
@@ -16,9 +16,8 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import {TransformUtils} from "../transform/TransformUtils.ets"
-
import image from "@ohos.multimedia.image"
export class CropCircleTransformation implements BaseTransform {
@@ -26,7 +25,6 @@ export class CropCircleTransformation implements BaseTransform {
private mCenterX: number= 0;
private mCenterY: number= 0;
private mRadius: number= 0;
- private mTransform_pixelMap: any;
getName() {
return CropCircleTransformation.TAG + ";mCenterX:" + this.mCenterX
@@ -42,7 +40,7 @@ export class CropCircleTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
var that = this;
TransformUtils.getPixelMapSize(imageSource, (error, size: {
width: number,
@@ -76,19 +74,18 @@ export class CropCircleTransformation implements BaseTransform {
}
imageSource.createPixelMap(options)
.then(p => {
- this.transformCircle(p, func);
- })
+ this.transformCircle(p, func);
+ })
.catch(e => {
- console.error(Constants.PROJECT_TAG + CropCircleTransformation.TAG + " transform e:" + e);
- if (func) {
- func(Constants.PROJECT_TAG + CropCircleTransformation.TAG + "e" + e, null);
- }
- })
+ console.error(Constants.PROJECT_TAG + CropCircleTransformation.TAG + " transform e:" + e);
+ if (func) {
+ func(Constants.PROJECT_TAG + CropCircleTransformation.TAG + "e" + e, null);
+ }
+ })
}
- private async transformCircle(p: PixelMap, func?: AsyncTransform) {
- this.mTransform_pixelMap = p;
- let imageInfo = await this.mTransform_pixelMap.getImageInfo();
+ private async transformCircle(data: any, func?: AsyncTransform) {
+ let imageInfo = await data.getImageInfo();
let size = {
width: imageInfo.size.width,
height: imageInfo.size.height
@@ -109,37 +106,27 @@ export class CropCircleTransformation implements BaseTransform {
this.mCenterX = width / 2;
this.mCenterY = height / 2;
- let writePromise;
+ let bufferData = new ArrayBuffer(data.getPixelBytesNumber());
+ await data.readPixelsToBuffer(bufferData);
+
+ var dataArray = new Uint8Array(bufferData);
for (var h = 0;h <= height; h++) {
for (var w = 0;w <= width; w++) {
if (this.isContainsCircle(w, h)) {
continue;
}
- writePromise = new Promise((resolve, reject) => {
- var buffer1 = new ArrayBuffer(5);
- var bytes1 = new Uint8Array(buffer1);
- var writePositionRenB = {
- pixels: buffer1,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- for (let j = 0;j < 5; j++) {
- bytes1[j] = 0;
- }
- this.mTransform_pixelMap.writePixels(writePositionRenB, () => {
- resolve();
- });
- })
- await writePromise;
+ //针对的点
+ let index = (h * width + w) * 4;
+ dataArray[index] = 0;
+ dataArray[index+1] = 0;
+ dataArray[index+2] = 0;
+ dataArray[index+3] = 0;
}
}
+ await data.writeBufferToPixels(bufferData);
if (func) {
- func("", this.mTransform_pixelMap);
+ func("", data);
}
}
diff --git a/entry/src/main/ets/MainAbility/glide/transform/CropCircleWithBorderTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation.ets
similarity index 64%
rename from entry/src/main/ets/MainAbility/glide/transform/CropCircleWithBorderTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation.ets
index 40fefcc..7024890 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/CropCircleWithBorderTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/CropCircleWithBorderTransformation.ets
@@ -16,13 +16,12 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import {TransformUtils} from "../transform/TransformUtils.ets"
import image from "@ohos.multimedia.image"
export class CropCircleWithBorderTransformation implements BaseTransform {
private static TAG: string= "CropCircleTransformation";
- private mTransform_pixelMap: any;
private mBorderSize: number= 5;
private mCenterX: number= 0;
private mCenterY: number= 0;
@@ -60,7 +59,7 @@ export class CropCircleWithBorderTransformation implements BaseTransform) {
- this.mTransform_pixelMap = pixelMap;
+ private async transformPixelMap(pixelMap: any, width: number, height: number, func?: AsyncTransform) {
this.mRadius = 0;
if (width > height) {
this.mRadius = height / 2;
@@ -114,8 +112,13 @@ export class CropCircleWithBorderTransformation implements BaseTransform((resolve, reject) => {
- var buffer1B = new ArrayBuffer(5);
- var bytes1B = new Uint8Array(buffer1B);
- var writePositionRenB = {
- pixels: buffer1B,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- for (let j = 0;j < 5; j++) {
- bytes1B[j] = 0;
- }
- this.mTransform_pixelMap.writePixels(writePositionRenB, () => {
- resolve();
- });
- })
- await writePromise;
+ dataArray[index] = 0;
+ dataArray[index+1] = 0;
+ dataArray[index+2] = 0;
+ dataArray[index+3] = 0;
} else {
//设置broke
- var buffer = new ArrayBuffer(5);
- readPromise = new Promise((resolve, reject) => {
- var positionRen = {
- pixels: buffer,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- this.mTransform_pixelMap.readPixels(positionRen, () => {
- resolve();
- });
- });
- await readPromise;
- writePromise = new Promise((resolve, reject) => {
- var bytes = new Uint8Array(buffer);
- var buffer1 = new ArrayBuffer(5);
- var bytes1 = new Uint8Array(buffer1);
- var writePositionRen = {
- pixels: buffer1,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- for (let j = 0;j < 5; j++) {
- if (j == 1 && this.mBColor > 0) {
- bytes1[j] = this.mBColor;
- } else if (j == 2 && this.mGColor > 0) {
- bytes1[j] = this.mGColor;
- } else if (j == 3 && this.mRColor > 0) {
- bytes1[j] = this.mRColor;
- } else {
- bytes1[j] = bytes[j];
- }
- }
- this.mTransform_pixelMap.writePixels(writePositionRen, () => {
- resolve();
- });
- })
- await writePromise;
+ dataArray[index] = this.mRColor;
+ dataArray[index+1] = this.mGColor;
+ dataArray[index+2] = this.mBColor;
}
}
}
+
+ await pixelMap.writeBufferToPixels(bufferData);
if (func) {
- func("", this.mTransform_pixelMap);
+ func("", pixelMap);
}
}
diff --git a/entry/src/main/ets/MainAbility/glide/transform/CropSquareTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/CropSquareTransformation.ets
similarity index 95%
rename from entry/src/main/ets/MainAbility/glide/transform/CropSquareTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/CropSquareTransformation.ets
index 30aa686..8c3f3e8 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/CropSquareTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/CropSquareTransformation.ets
@@ -16,7 +16,7 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import image from "@ohos.multimedia.image"
@@ -39,7 +39,7 @@ export class CropSquareTransformation implements BaseTransform {
}
squareCrop(buf: ArrayBuffer, request: RequestOption, func?: AsyncTransform) {
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
imageSource.getImageInfo()
.then((p) => {
var pw = p.size.width;
diff --git a/entry/src/main/ets/MainAbility/glide/transform/CropTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/CropTransformation.ets
similarity index 82%
rename from entry/src/main/ets/MainAbility/glide/transform/CropTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/CropTransformation.ets
index 5e23729..fef3a54 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/CropTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/CropTransformation.ets
@@ -16,9 +16,8 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import {TransformUtils} from "../transform/TransformUtils.ets"
-
import image from "@ohos.multimedia.image"
export class CropTransformation implements BaseTransform {
@@ -47,7 +46,7 @@ export class CropTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
TransformUtils.getPixelMapSize(imageSource, (error, size: {
width: number,
height: number
@@ -68,23 +67,27 @@ export class CropTransformation implements BaseTransform {
var scaledWidth = scale * pixelMapWidth;
var scaledHeight = scale * pixelMapHeight;
- var xx = (this.mWidth - scaledWidth) / 2;
- var yy = Math.abs(this.getTop(pixelMapHeight));
+ var left = (this.mWidth - scaledWidth) / 2;
+ var top = Math.abs(this.getTop(pixelMapHeight));
var options = {
editable: true,
- desiredRegion: { size: { width: this.mWidth, height: this.mHeight },
- x: xx,
- y: yy,
+ desiredRegion: {
+ size: {
+ width: scaledWidth > pixelMapWidth ? pixelMapWidth : scaledWidth,
+ height: scaledHeight > pixelMapHeight ? pixelMapHeight : scaledHeight
+ },
+ x: left < 0 ? 0 : left,
+ y: top < 0 ? 0 : top,
},
}
imageSource.createPixelMap(options)
.then((data) => {
- func("", data);
- })
+ func("", data);
+ })
.catch((e) => {
- console.log(Constants.PROJECT_TAG + ";error:" + e);
- func(e, null);
- })
+ console.log(Constants.PROJECT_TAG + ";error:" + e);
+ func(e, null);
+ })
})
}
diff --git a/entry/src/main/ets/MainAbility/glide/transform/GrayscaleTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/GrayscaleTransformation.ets
similarity index 60%
rename from entry/src/main/ets/MainAbility/glide/transform/GrayscaleTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/GrayscaleTransformation.ets
index 8a536bc..02a437d 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/GrayscaleTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/GrayscaleTransformation.ets
@@ -16,7 +16,7 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import {TransformUtils} from "../transform/TransformUtils.ets"
import image from "@ohos.multimedia.image"
@@ -25,7 +25,6 @@ export class GrayscaleTransformation implements BaseTransform {
return "GrayscaleTransformation:" + this;
}
-
async transform(buf: ArrayBuffer, request: RequestOption, func?: AsyncTransform) {
if (!buf || buf.byteLength <= 0) {
console.log(Constants.PROJECT_TAG + ";GrayscaleTransformation buf is empty");
@@ -34,7 +33,7 @@ export class GrayscaleTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
let imageInfo = await imageSource.getImageInfo();
let size = {
@@ -65,53 +64,30 @@ export class GrayscaleTransformation implements BaseTransform {
}
}
let data = await imageSource.createPixelMap(options);
- let readPromise;
- let writePromise;
- for (let w = 0;w <= targetWidth; w++) {
- for (let h = 0;h <= targetHeight; h++) {
- var buffer = new ArrayBuffer(5);
- readPromise = new Promise((resolve, reject) => {
- var positionRen = {
- pixels: buffer,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- data.readPixels(positionRen, () => {
- resolve();
- });
- });
- await readPromise;
- writePromise = new Promise((resolve, reject) => {
- var bytes = new Uint8Array(buffer);
- var buffer1B = new ArrayBuffer(5);
- var bytes1B = new Uint8Array(buffer1B);
- var writePositionRenB = {
- pixels: buffer1B,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- bytes1B[0] = bytes[0];
- bytes1B[1] = this.grayscale(bytes[3], bytes[2], bytes[1]);
- bytes1B[2] = this.grayscale(bytes[3], bytes[2], bytes[1]);
- bytes1B[3] = this.grayscale(bytes[3], bytes[2], bytes[1]);
- bytes1B[4] = bytes[4];
- data.writePixels(writePositionRenB, () => {
- resolve();
- });
- })
- await writePromise;
- }
+ let bufferData = new ArrayBuffer(data.getPixelBytesNumber());
+ let bufferNewData = new ArrayBuffer(data.getPixelBytesNumber());
+ await data.readPixelsToBuffer(bufferData);
+
+ var dataArray = new Uint8Array(bufferData);
+ var dataNewArray = new Uint8Array(bufferNewData);
+
+ for (let index = 0; index < dataArray.length; index += 4) {
+ const r = dataArray[index];
+ const g = dataArray[index+1];
+ const b = dataArray[index+2];
+ const f = dataArray[index+3];
+ //b g r
+ dataNewArray[index] = this.grayscale(r, g, b);
+ dataNewArray[index+1] = this.grayscale(r, g, b);
+ dataNewArray[index+2] = this.grayscale(r, g, b);
+ dataNewArray[index+3] = f;
+ }
+
+ await data.writeBufferToPixels(bufferNewData);
+ if (func) {
+ func('', data);
}
- func('',data);
}
/**
diff --git a/entry/src/main/ets/MainAbility/glide/transform/InvertFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/InvertFilterTransformation.ets
similarity index 64%
rename from entry/src/main/ets/MainAbility/glide/transform/InvertFilterTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/InvertFilterTransformation.ets
index 159b8bb..462121e 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/InvertFilterTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/InvertFilterTransformation.ets
@@ -16,7 +16,7 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import image from "@ohos.multimedia.image"
/**
@@ -40,7 +40,7 @@ export class InvertFilterTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
let imageInfo = await imageSource.getImageInfo();
let size = {
@@ -73,55 +73,21 @@ export class InvertFilterTransformation implements BaseTransform {
}
let data = await imageSource.createPixelMap(options);
- let readPromise;
- let writePromise;
- for (let w = 0;w <= targetWidth; w++) {
- for (let h = 0;h <= targetHeight; h++) {
- var buffer = new ArrayBuffer(5);
- readPromise = new Promise((resolve, reject) => {
- var positionRen = {
- pixels: buffer,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- data.readPixels(positionRen, () => {
- resolve();
- });
- });
- await readPromise;
+ let bufferData = new ArrayBuffer(data.getPixelBytesNumber());
+ await data.readPixelsToBuffer(bufferData);
- writePromise = new Promise((resolve, reject) => {
- var bytes = new Uint8Array(buffer);
+ var dataArray = new Uint8Array(bufferData);
- var buffer1B = new ArrayBuffer(5);
- var bytes1B = new Uint8Array(buffer1B);
- var writePositionRenB = {
- pixels: buffer1B,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- bytes1B[0] = bytes[0];
- bytes1B[1] = this.checkVisAble(255 - bytes[1]);
- bytes1B[2] = this.checkVisAble(255 - bytes[2]);
- bytes1B[3] = this.checkVisAble(255 - bytes[3]);
- bytes1B[4] = bytes[4];
- data.writePixels(writePositionRenB, () => {
- resolve();
- });
- })
- await writePromise;
- }
+ for (let index = 0; index < dataArray.length; index += 4) {
+ dataArray[index] = this.checkVisAble(255 - dataArray[index]);
+ dataArray[index+1] = this.checkVisAble(255 - dataArray[index+1]);
+ dataArray[index+2] = this.checkVisAble(255 - dataArray[index+2]);
+ }
+ await data.writeBufferToPixels(bufferData);
+ if (func) {
+ func('', data);
}
- func("", data);
}
private checkVisAble(input: number) {
diff --git a/imageknife/src/main/ets/components/imageknife/transform/MaskTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/MaskTransformation.ets
new file mode 100644
index 0000000..273efb3
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/transform/MaskTransformation.ets
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {BaseTransform} from "../transform/BaseTransform.ets"
+import {AsyncTransform} from "../transform/AsyncTransform.ets"
+import {Constants} from "../constants/Constants.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
+import {MaskUtils} from "../utils/MaskUtils.ets"
+import image from "@ohos.multimedia.image"
+import resmgr from "@ohos.resourceManager"
+
+export class MaskTransformation implements BaseTransform {
+ private _mResourceData: Resource;
+
+ constructor(maskBitmap: Resource) {
+ this._mResourceData = maskBitmap;
+ }
+
+ getName() {
+ return "MaskTransformation:" + this._mResourceData;
+ }
+
+ async transform(buf: ArrayBuffer, request: RequestOption, func?: AsyncTransform) {
+ if (!buf || buf.byteLength <= 0) {
+ console.log(Constants.PROJECT_TAG + ";MaskTransformation buf is empty");
+ if (func) {
+ func(Constants.PROJECT_TAG + ";MaskTransformation buf is empty", null);
+ }
+ return;
+ }
+ var imageSource = image.createImageSource(buf as any);
+
+ let imageInfo = await imageSource.getImageInfo();
+ let size = {
+ width: imageInfo.size.width,
+ height: imageInfo.size.height
+ }
+
+ if (!size) {
+ func(new Error("MaskTransformation The image size does not exist."), null)
+ return;
+ }
+ var pixelMapWidth = size.width;
+ var pixelMapHeight = size.height;
+ var targetWidth = request.size.width;
+ var targetHeight = request.size.height;
+ if (pixelMapWidth < targetWidth) {
+ targetWidth = pixelMapWidth;
+ }
+ if (pixelMapHeight < targetHeight) {
+ targetHeight = pixelMapHeight;
+ }
+
+ var options = {
+ editable: true,
+ desiredSize: {
+ width: targetWidth,
+ height: targetHeight
+ }
+ }
+ imageSource.createPixelMap(options)
+ .then(data => {
+ this.openInternal(data, targetWidth, targetHeight, func)
+ })
+ .catch(e => {
+ func(e, null);
+ })
+ }
+
+ private openInternal(bitmap: any, width: number, height: number, func: AsyncTransform) {
+ if (!this._mResourceData) {
+ throw new Error("MaskTransformation resource is empty");
+ }
+ resmgr.getResourceManager()
+ .then(result => {
+ result.getMedia(this._mResourceData
+ .id)
+ .then(array => {
+ let buffer = array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset);
+ var imageSource = image.createImageSource(buffer as any);
+ var options = {
+ editable: true,
+ desiredSize: {
+ width: width,
+ height: height
+ }
+ }
+ imageSource.createPixelMap(options)
+ .then(maskBitmap => {
+ MaskUtils.mask(bitmap, maskBitmap, func)
+ })
+ })
+ .catch(err => {
+ func("MaskTransformation openInternal error" + err, null);
+ })
+ })
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/transform/PixelationFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/PixelationFilterTransformation.ets
similarity index 95%
rename from entry/src/main/ets/MainAbility/glide/transform/PixelationFilterTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/PixelationFilterTransformation.ets
index 976a26a..9e55bc5 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/PixelationFilterTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/PixelationFilterTransformation.ets
@@ -16,7 +16,7 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import {TransformUtils} from "../transform/TransformUtils.ets"
import image from "@ohos.multimedia.image"
import {pixelUtils} from "../utils/PixelUtils"
@@ -46,7 +46,7 @@ export class PixelationFilterTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
TransformUtils.getPixelMapSize(imageSource, (error, size: {
width: number,
height: number
diff --git a/entry/src/main/ets/MainAbility/glide/transform/RotateImageTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/RotateImageTransformation.ets
similarity index 95%
rename from entry/src/main/ets/MainAbility/glide/transform/RotateImageTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/RotateImageTransformation.ets
index 7d80646..ddb9c9a 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/RotateImageTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/RotateImageTransformation.ets
@@ -15,7 +15,7 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import {TransformUtils} from "../transform/TransformUtils.ets"
import image from "@ohos.multimedia.image"
@@ -39,7 +39,7 @@ export class RotateImageTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
TransformUtils.getPixelMapSize(imageSource, (error, size: {
width: number,
height: number
diff --git a/entry/src/main/ets/MainAbility/glide/transform/RoundedCornersTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/RoundedCornersTransformation.ets
similarity index 96%
rename from entry/src/main/ets/MainAbility/glide/transform/RoundedCornersTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/RoundedCornersTransformation.ets
index 17ba708..9220f5e 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/RoundedCornersTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/RoundedCornersTransformation.ets
@@ -16,7 +16,7 @@ import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {ArcPoint} from "../entry/ArcPoint.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import {TransformUtils} from "../transform/TransformUtils.ets"
import image from "@ohos.multimedia.image"
@@ -49,6 +49,8 @@ export class RoundedCornersTransformation implements BaseTransform {
}
transform(buf: ArrayBuffer, request: RequestOption, func?: AsyncTransform) {
+ console.log('RoundedCornersTransformation = '+ this.getName()
+ + 'buf is null ='+ (buf == null));
if (!buf || buf.byteLength <= 0) {
console.log(Constants.PROJECT_TAG + ";RoundedCornersTransformation buf is empty");
if (func) {
@@ -56,7 +58,7 @@ export class RoundedCornersTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
var that = this;
TransformUtils.getPixelMapSize(imageSource, (error, size: {
width: number,
diff --git a/entry/src/main/ets/MainAbility/glide/transform/SepiaFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/SepiaFilterTransformation.ets
similarity index 57%
rename from entry/src/main/ets/MainAbility/glide/transform/SepiaFilterTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/SepiaFilterTransformation.ets
index d47e703..de3d9e9 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/SepiaFilterTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/SepiaFilterTransformation.ets
@@ -16,7 +16,7 @@
import {BaseTransform} from "../transform/BaseTransform.ets"
import {AsyncTransform} from "../transform/AsyncTransform.ets"
import {Constants} from "../constants/Constants.ets"
-import {RequestOption} from "../../glide/RequestOption.ets"
+import {RequestOption} from "../../imageknife/RequestOption.ets"
import image from "@ohos.multimedia.image"
/**
@@ -37,7 +37,7 @@ export class SepiaFilterTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
let imageInfo = await imageSource.getImageInfo();
let size = {
@@ -69,61 +69,36 @@ export class SepiaFilterTransformation implements BaseTransform {
}
}
let data = await imageSource.createPixelMap(options);
- let readPromise;
- let writePromise;
- for (let w = 0;w <= targetWidth; w++) {
- for (let h = 0;h <= targetHeight; h++) {
- var buffer = new ArrayBuffer(5);
- readPromise = new Promise((resolve, reject) => {
- var positionRen = {
- pixels: buffer,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- data.readPixels(positionRen, () => {
- resolve();
- });
- });
- await readPromise;
- writePromise = new Promise((resolve, reject) => {
- var bytes = new Uint8Array(buffer);
- var buffer1B = new ArrayBuffer(5);
- var bytes1B = new Uint8Array(buffer1B);
+ let bufferData = new ArrayBuffer(data.getPixelBytesNumber());
+ let bufferNewData = new ArrayBuffer(data.getPixelBytesNumber());
+ await data.readPixelsToBuffer(bufferData);
- var writePositionRenB = {
- pixels: buffer1B,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- bytes1B[0] = bytes[0];
- bytes1B[1] = this.checkVisAble(this.colorBlend(this.noise()
- , (bytes[3] * 0.272) + (bytes[2] * 0.534) + (bytes[1] * 0.131)
- , bytes[1]));
- bytes1B[2] = this.checkVisAble(this.colorBlend(this.noise()
- , (bytes[3] * 0.349) + (bytes[2] * 0.686) + (bytes[1] * 0.168)
- , bytes[2]));
- bytes1B[3] = this.checkVisAble(this.colorBlend(this.noise()
- , (bytes[3] * 0.393) + (bytes[2] * 0.769) + (bytes[1] * 0.189)
- , bytes[3]));
- bytes1B[4] = bytes[4];
+ var dataArray = new Uint8Array(bufferData);
+ var dataNewArray = new Uint8Array(bufferNewData);
- data.writePixels(writePositionRenB, () => {
- resolve();
- });
- })
- await writePromise;
- }
+ for (let index = 0; index < dataArray.length; index += 4) {
+ const r = dataArray[index];
+ const g = dataArray[index+1];
+ const b = dataArray[index+2];
+ const f = dataArray[index+3];
+
+ dataNewArray[index+2] = this.checkVisAble(this.colorBlend(this.noise()
+ , (r * 0.272) + (g * 0.534) + (b * 0.131)
+ , b));
+ dataNewArray[index+1] = this.checkVisAble(this.colorBlend(this.noise()
+ , (r * 0.349) + (g * 0.686) + (b * 0.168)
+ , g));
+ dataNewArray[index] = this.checkVisAble(this.colorBlend(this.noise()
+ , (r * 0.393) + (g * 0.769) + (b * 0.189)
+ , r));
+ dataNewArray[index+3] = f;
+ }
+
+ await data.writeBufferToPixels(bufferNewData);
+ if (func) {
+ func("", data);
}
- func("", data);
}
private checkVisAble(input: number) {
diff --git a/entry/src/main/ets/MainAbility/glide/transform/SketchFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/SketchFilterTransformation.ets
similarity index 94%
rename from entry/src/main/ets/MainAbility/glide/transform/SketchFilterTransformation.ets
rename to imageknife/src/main/ets/components/imageknife/transform/SketchFilterTransformation.ets
index fa15e4d..d074c80 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/SketchFilterTransformation.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/SketchFilterTransformation.ets
@@ -16,7 +16,7 @@
import {BaseTransform} from '../transform/BaseTransform.ets'
import {AsyncTransform} from '../transform/AsyncTransform.ets'
import {Constants} from '../constants/Constants.ets'
-import {RequestOption} from '../../glide/RequestOption.ets'
+import {RequestOption} from '../../imageknife/RequestOption.ets'
import {TransformUtils} from '../transform/TransformUtils.ets'
import image from '@ohos.multimedia.image'
import {CalculatePixelUtils} from '../utils/CalculatePixelUtils'
@@ -34,7 +34,7 @@ export class SketchFilterTransformation implements BaseTransform {
}
return;
}
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
TransformUtils.getPixelMapSize(imageSource, (error, size: {
width: number,
height: number
diff --git a/imageknife/src/main/ets/components/imageknife/transform/SwirlFilterTransformation.ets b/imageknife/src/main/ets/components/imageknife/transform/SwirlFilterTransformation.ets
new file mode 100644
index 0000000..4dad54e
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/transform/SwirlFilterTransformation.ets
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {BaseTransform} from '../transform/BaseTransform.ets'
+import {AsyncTransform} from '../transform/AsyncTransform.ets'
+import {Constants} from '../constants/Constants.ets'
+import {RequestOption} from '../../imageknife/RequestOption.ets'
+import {TransformUtils} from '../transform/TransformUtils.ets'
+import image from '@ohos.multimedia.image'
+import {PixelEntry} from '../entry/PixelEntry'
+import {ColorUtils} from '../utils/ColorUtils'
+import {CalculatePixelUtils} from '../utils/CalculatePixelUtils'
+
+export class SwirlFilterTransformation implements BaseTransform {
+ private _degree: number;
+
+ constructor(degree: number) {
+ this._degree = degree;
+ }
+
+ getName() {
+ return 'SwirlFilterTransformation' + this._degree;
+ }
+
+ transform(buf: ArrayBuffer, request: RequestOption, func?: AsyncTransform) {
+ if (!buf || buf.byteLength <= 0) {
+ throw new Error(Constants.PROJECT_TAG + ';SwirlFilterTransformation buf is empty');
+ if (func) {
+ func(Constants.PROJECT_TAG + ';SwirlFilterTransformation buf is empty', null);
+ }
+ return;
+ }
+ var imageSource = image.createImageSource(buf as any);
+ TransformUtils.getPixelMapSize(imageSource, (error, size: {
+ width: number,
+ height: number
+ }) => {
+ if (!size) {
+ func(error, null)
+ return;
+ }
+ var pixelMapWidth = size.width;
+ var pixelMapHeight = size.height;
+ var targetWidth = request.size.width;
+ var targetHeight = request.size.height;
+ if (pixelMapWidth < targetWidth) {
+ targetWidth = pixelMapWidth;
+ }
+ if (pixelMapHeight < targetHeight) {
+ targetHeight = pixelMapHeight;
+ }
+
+ var options = {
+ editable: true,
+ desiredSize: {
+ width: targetWidth,
+ height: targetHeight
+ }
+ }
+ imageSource.createPixelMap(options)
+ .then((data) => {
+ this.swirl(data, this._degree, func);
+ })
+ .catch((e) => {
+ func(e, null);
+ })
+ })
+ }
+
+ private async swirl(bitmap: any, degree: number, func?: AsyncTransform) {
+ let imageInfo = await bitmap.getImageInfo();
+ let size = {
+ width: imageInfo.size.width,
+ height: imageInfo.size.height
+ }
+ if (!size) {
+ return;
+ }
+ let width = size.width;
+ let height = size.height;
+ let pixEntry: Array = new Array();
+
+
+ let rgbData = CalculatePixelUtils.createInt2DArray(height, width);
+
+ let bufferData = new ArrayBuffer(bitmap.getPixelBytesNumber());
+ await bitmap.readPixelsToBuffer(bufferData);
+ let dataArray = new Uint8Array(bufferData);
+
+ let ph = 0;
+ let pw = 0;
+ for (let index = 0; index < dataArray.length; index += 4) {
+ const r = dataArray[index];
+ const g = dataArray[index+1];
+ const b = dataArray[index+2];
+ const f = dataArray[index+3];
+
+ let entry = new PixelEntry();
+ entry.a = 0;
+ entry.b = b;
+ entry.g = g;
+ entry.r = r;
+ entry.f = f;
+ entry.pixel = ColorUtils.rgb(entry.r, entry.g, entry.b);
+ pixEntry.push(entry);
+ rgbData[ph][pw] = ColorUtils.rgb(entry.r, entry.g, entry.b);
+ if (pw == width - 1) {
+ pw = 0;
+ ph++;
+ } else {
+ pw++;
+ }
+ }
+
+ let k = degree / 3600;
+ let cenX = width / 2;
+ let cenY = height / 2;
+
+ let radius = 0;
+ for (let h = 0;h < height; h++) {
+ for (let w = 0; w < width; w++) {
+
+ let offerX = w - cenX;
+ let offerY = h - cenY;
+ let radian = Math.atan2(offerY, offerX)
+ radius = Math.floor(Math.sqrt(offerX * offerX + offerY * offerY));
+
+ let newX = Math.floor(radius * Math.cos(radian + k * radius)) + cenX;
+ let newY = Math.floor(radius * Math.sin(radian + k * radius)) + cenY;
+
+ newX = Math.floor(Math.min(width - 1, Math.max(0, newX)));
+ newY = Math.floor(Math.min(height - 1, Math.max(0, newY)));
+
+ rgbData[h][w] = rgbData[newY][newX];
+ }
+ }
+
+
+ let bufferNewData = new ArrayBuffer(bitmap.getPixelBytesNumber());
+ let dataNewArray = new Uint8Array(bufferNewData);
+ let index = 0;
+ let mh = 0;
+ let nw = 0;
+
+ for (let i = 0; i < dataNewArray.length; i += 4) {
+ let pixel_1 = rgbData[mh][nw];
+
+ if (nw == width - 1) {
+ nw = 0;
+ mh++;
+ } else {
+ nw++;
+ }
+
+ let p_r = ColorUtils.red(pixel_1);
+ let p_g = ColorUtils.green(pixel_1);
+ let p_b = ColorUtils.blue(pixel_1);
+
+ dataNewArray[i] = p_r;
+ dataNewArray[i+1] = p_g;
+ dataNewArray[i+2] = p_b;
+ dataNewArray[i+3] = pixEntry[index].f;
+ index++;
+ }
+ await bitmap.writeBufferToPixels(bufferNewData);
+ if (func) {
+ func("", bitmap);
+ }
+ }
+}
\ No newline at end of file
diff --git a/imageknife/src/main/ets/components/imageknife/transform/TransformType.ets b/imageknife/src/main/ets/components/imageknife/transform/TransformType.ets
new file mode 100644
index 0000000..bde5ccc
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/transform/TransformType.ets
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export enum TransformType {
+ BlurTransformation,
+ BrightnessFilterTransformation,
+ ContrastFilterTransformation,
+ CropCircleTransformation,
+ CropCircleWithBorderTransformation,
+ CropSquareTransformation,
+ CropTransformation,
+ GrayscaleTransformation,
+ InvertFilterTransformation,
+ MaskTransformation,
+ PixelationFilterTransformation,
+ RotateImageTransformation,
+ RoundedCornersTransformation,
+ SepiaFilterTransformation,
+ SketchFilterTransformation,
+ SwirlFilterTransformation,
+ CenterCrop,
+ CenterInside,
+ FitCenter
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/transform/TransformUtils.ets b/imageknife/src/main/ets/components/imageknife/transform/TransformUtils.ets
similarity index 93%
rename from entry/src/main/ets/MainAbility/glide/transform/TransformUtils.ets
rename to imageknife/src/main/ets/components/imageknife/transform/TransformUtils.ets
index 3cd80a1..14653b9 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/TransformUtils.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/TransformUtils.ets
@@ -12,13 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {AsyncTransform} from '../transform/AsyncTransform.ets'
+import {AsyncTransform} from '../transform/AsyncTransform'
import image from '@ohos.multimedia.image'
export class TransformUtils {
static centerCrop(buf: ArrayBuffer, outWidth: number, outHeihgt: number,
callback?: AsyncTransform>) {
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
imageSource.getImageInfo()
.then((p) => {
var sw;
@@ -57,7 +57,7 @@ export class TransformUtils {
}
static rotateImage(buf: ArrayBuffer, degreesToRotate: number): Promise{
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
var options = {
editable: true,
rotate: degreesToRotate
@@ -67,7 +67,7 @@ export class TransformUtils {
static centerInside(buf: ArrayBuffer, outWidth: number, outHeihgt: number,
callback?: AsyncTransform>) {
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
imageSource.getImageInfo()
.then((p) => {
var pw = p.size.width;
@@ -86,7 +86,7 @@ export class TransformUtils {
static fitCenter(buf: ArrayBuffer, outWidth: number, outHeihgt: number
, callback?: AsyncTransform>) {
- var imageSource = image.createImageSource(buf);
+ var imageSource = image.createImageSource(buf as any);
imageSource.getImageInfo()
.then((p) => {
var pw = p.size.width;
diff --git a/entry/src/main/ets/MainAbility/glide/transform/pixelmap/CenterCrop.ets b/imageknife/src/main/ets/components/imageknife/transform/pixelmap/CenterCrop.ets
similarity index 82%
rename from entry/src/main/ets/MainAbility/glide/transform/pixelmap/CenterCrop.ets
rename to imageknife/src/main/ets/components/imageknife/transform/pixelmap/CenterCrop.ets
index 45012bb..28349dc 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/pixelmap/CenterCrop.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/pixelmap/CenterCrop.ets
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-import {BaseTransform} from '../BaseTransform.ets'
-import {AsyncTransform} from '../AsyncTransform.ets'
-import {Constants} from '../../constants/Constants.ets'
-import {TransformUtils} from '../TransformUtils.ets'
-import {RequestOption} from '../../../glide/RequestOption.ets'
+import {BaseTransform} from '../BaseTransform'
+import {AsyncTransform} from '../AsyncTransform'
+import {Constants} from '../../constants/Constants'
+import {TransformUtils} from '../TransformUtils'
+import {RequestOption} from '../../../imageknife/RequestOption'
export class CenterCrop implements BaseTransform {
getName() {
diff --git a/entry/src/main/ets/MainAbility/glide/transform/pixelmap/CenterInside.ets b/imageknife/src/main/ets/components/imageknife/transform/pixelmap/CenterInside.ets
similarity index 82%
rename from entry/src/main/ets/MainAbility/glide/transform/pixelmap/CenterInside.ets
rename to imageknife/src/main/ets/components/imageknife/transform/pixelmap/CenterInside.ets
index 292a84b..c3b8b43 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/pixelmap/CenterInside.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/pixelmap/CenterInside.ets
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-import {BaseTransform} from '../BaseTransform.ets'
-import {AsyncTransform} from '../AsyncTransform.ets'
-import {Constants} from '../../constants/Constants.ets'
-import {TransformUtils} from '../TransformUtils.ets'
-import {RequestOption} from '../../../glide/RequestOption.ets'
+import {BaseTransform} from '../BaseTransform'
+import {AsyncTransform} from '../AsyncTransform'
+import {Constants} from '../../constants/Constants'
+import {TransformUtils} from '../TransformUtils'
+import {RequestOption} from '../../../imageknife/RequestOption'
export class CenterInside implements BaseTransform {
getName() {
diff --git a/entry/src/main/ets/MainAbility/glide/transform/pixelmap/FitCenter.ets b/imageknife/src/main/ets/components/imageknife/transform/pixelmap/FitCenter.ets
similarity index 82%
rename from entry/src/main/ets/MainAbility/glide/transform/pixelmap/FitCenter.ets
rename to imageknife/src/main/ets/components/imageknife/transform/pixelmap/FitCenter.ets
index 0e8c0b8..2330b0d 100644
--- a/entry/src/main/ets/MainAbility/glide/transform/pixelmap/FitCenter.ets
+++ b/imageknife/src/main/ets/components/imageknife/transform/pixelmap/FitCenter.ets
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-import {BaseTransform} from '../BaseTransform.ets'
-import {AsyncTransform} from '../AsyncTransform.ets'
-import {Constants} from '../../constants/Constants.ets'
-import {TransformUtils} from '../TransformUtils.ets'
-import {RequestOption} from '../../../glide/RequestOption.ets'
+import {BaseTransform} from '../BaseTransform'
+import {AsyncTransform} from '../AsyncTransform'
+import {Constants} from '../../constants/Constants'
+import {TransformUtils} from '../TransformUtils'
+import {RequestOption} from '../../../imageknife/RequestOption'
export class FitCenter implements BaseTransform {
getName() {
diff --git a/entry/src/main/ets/MainAbility/glide/utils/CalculatePixelUtils.ets b/imageknife/src/main/ets/components/imageknife/utils/CalculatePixelUtils.ets
similarity index 80%
rename from entry/src/main/ets/MainAbility/glide/utils/CalculatePixelUtils.ets
rename to imageknife/src/main/ets/components/imageknife/utils/CalculatePixelUtils.ets
index 2ee2de2..e7a6684 100644
--- a/entry/src/main/ets/MainAbility/glide/utils/CalculatePixelUtils.ets
+++ b/imageknife/src/main/ets/components/imageknife/utils/CalculatePixelUtils.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import {PixelEntry} from "../entry/PixelEntry"
import {AsyncTransform} from "../transform/AsyncTransform"
import {ColorUtils} from "./ColorUtils"
@@ -20,41 +34,29 @@ export namespace CalculatePixelUtils {
var pixEntry: Array = new Array()
var pixSrc: Array = new Array()
var pixNvt: Array = new Array()
- let readPromise;
- let writePromise;
- for (let h = 0; h < height; h++) {
- for (let w = 0; w < width; w++) {
- let buffer = new ArrayBuffer(5);
- readPromise = new Promise((resolve, reject) => {
- var positionRen = {
- pixels: buffer,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: w,
- y: h
- }
- }
- p.readPixels(positionRen, () => {
- resolve();
- });
- });
- await readPromise;
+ let bufferData = new ArrayBuffer(p.getPixelBytesNumber());
+ await p.readPixelsToBuffer(bufferData);
+ let dataArray = new Uint8Array(bufferData);
- let bytes = new Uint8Array(buffer);
- let entry = new PixelEntry();
- entry.a = bytes[0];
- entry.b = bytes[1];
- entry.g = bytes[2];
- entry.r = bytes[3];
- entry.f = bytes[4];
- entry.pixel = ColorUtils.rgb(entry.r, entry.g, entry.b);
- pixEntry.push(entry);
- pixSrc.push(ColorUtils.rgb(entry.r, entry.g, entry.b));
- pixNvt.push(0);
- }
+ for (let index = 0; index < dataArray.length; index += 4) {
+ const r = dataArray[index];
+ const g = dataArray[index+1];
+ const b = dataArray[index+2];
+ const f = dataArray[index+3];
+
+ let entry = new PixelEntry();
+ entry.a = 0;
+ entry.b = b;
+ entry.g = g;
+ entry.r = r;
+ entry.f = f;
+ entry.pixel = ColorUtils.rgb(entry.r, entry.g, entry.b);
+ pixEntry.push(entry);
+ pixSrc.push(ColorUtils.rgb(entry.r, entry.g, entry.b));
+ pixNvt.push(0);
}
+
for (row = 0; row < height; row++) {
for (col = 0; col < width; col++) {
pos = row * width + col;
@@ -74,36 +76,23 @@ export namespace CalculatePixelUtils {
pixSrc[pos] = ColorUtils.rgb(clr, clr, clr);
}
}
- for (let m = 0;m < height; m++) { //y
- for (let n = 0;n < width; n++) { //x
- writePromise = new Promise((resolve, reject) => {
- let buffer1B = new ArrayBuffer(5);
- let bytes1B = new Uint8Array(buffer1B);
- var writePositionRenB = {
- pixels: buffer1B,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: n,
- y: m
- }
- }
- let index = m * width + n;
- bytes1B[0] = pixEntry[m * width + n].a;
- bytes1B[1] = ColorUtils.blue(pixSrc[index]);
- bytes1B[2] = ColorUtils.green(pixSrc[index]);
- bytes1B[3] = ColorUtils.red(pixSrc[index]);
- bytes1B[4] = pixEntry[m * width + n].f;
- p.writePixels(writePositionRenB, () => {
- resolve();
- });
- })
- await writePromise;
- }
+ let bufferNewData = new ArrayBuffer(p.getPixelBytesNumber());
+ let dataNewArray = new Uint8Array(bufferNewData);
+ let index = 0;
+
+ for (let i = 0; i < dataNewArray.length; i += 4) {
+ dataNewArray[i] = ColorUtils.red(pixSrc[index]);
+ dataNewArray[i+1] = ColorUtils.green(pixSrc[index]);
+ dataNewArray[i+2] = ColorUtils.blue(pixSrc[index]);
+ dataNewArray[i+3] = pixEntry[index].f;
+ index++;
}
- func("success", p);
+ await p.writeBufferToPixels(bufferNewData);
+ if (func) {
+ func("success", p);
+ }
}
function gaussGray(psrc: Array, horz: number, vert: number,
diff --git a/entry/src/main/ets/MainAbility/glide/utils/ColorUtils.ets b/imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets
similarity index 65%
rename from entry/src/main/ets/MainAbility/glide/utils/ColorUtils.ets
rename to imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets
index a14bcf7..4254369 100644
--- a/entry/src/main/ets/MainAbility/glide/utils/ColorUtils.ets
+++ b/imageknife/src/main/ets/components/imageknife/utils/ColorUtils.ets
@@ -1,3 +1,17 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import resmgr from '@ohos.resourceManager'
import {DataCallBack} from "../interface/DataCallBack"
diff --git a/entry/src/main/ets/MainAbility/glide/utils/FastBlur.ets b/imageknife/src/main/ets/components/imageknife/utils/FastBlur.ets
similarity index 78%
rename from entry/src/main/ets/MainAbility/glide/utils/FastBlur.ets
rename to imageknife/src/main/ets/components/imageknife/utils/FastBlur.ets
index d690091..57bf3bd 100644
--- a/entry/src/main/ets/MainAbility/glide/utils/FastBlur.ets
+++ b/imageknife/src/main/ets/components/imageknife/utils/FastBlur.ets
@@ -13,7 +13,6 @@
* limitations under the License.
*/
-import image from "@ohos.multimedia.image"
import {CalculatePixelUtils} from "./CalculatePixelUtils"
import {PixelEntry} from "../entry/PixelEntry"
import {AsyncTransform} from "../transform/AsyncTransform"
@@ -31,7 +30,7 @@ export namespace fastBlur {
// Java Author: Mario Klingemann
// http://incubator.quasimondo.com
// created Feburary 29, 2004
- // Android port : Yahel Bouaziz
+ // port : Yahel Bouaziz
// http://www.kayenko.com
// ported april 5th, 2012
@@ -73,42 +72,28 @@ export namespace fastBlur {
var pixEntry: Array = new Array()
var pix: Array = new Array()
- let readPromise;
- let writePromise;
- for (let ph = 0; ph < h; ph++) {
- for (let pw = 0; pw < w; pw++) {
- let buffer = new ArrayBuffer(5);
- readPromise = new Promise((resolve, reject) => {
- var positionRen = {
- pixels: buffer,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: pw,
- y: ph
- }
- }
- bitmap.readPixels(positionRen, () => {
- resolve();
- });
- });
- await readPromise;
+ let bufferData = new ArrayBuffer(bitmap.getPixelBytesNumber());
+ await bitmap.readPixelsToBuffer(bufferData);
+ let dataArray = new Uint8Array(bufferData);
- let bytes = new Uint8Array(buffer);
- let entry = new PixelEntry();
- entry.a = bytes[0];
- entry.b = bytes[1];
- entry.g = bytes[2];
- entry.r = bytes[3];
- entry.f = bytes[4];
- entry.pixel = ColorUtils.rgb(entry.r, entry.g, entry.b);
- pixEntry.push(entry);
- pix.push(ColorUtils.rgb(entry.r, entry.g, entry.b));
- }
+ for (let index = 0; index < dataArray.length; index+=4) {
+ const r = dataArray[index];
+ const g = dataArray[index+1];
+ const b = dataArray[index+2];
+ const f = dataArray[index+3];
+
+ let entry = new PixelEntry();
+ entry.a = 0;
+ entry.b = b;
+ entry.g = g;
+ entry.r = r;
+ entry.f = f;
+ entry.pixel = ColorUtils.rgb(entry.r, entry.g, entry.b);
+ pixEntry.push(entry);
+ pix.push(ColorUtils.rgb(entry.r, entry.g, entry.b));
}
-
let wm = w - 1;
let hm = h - 1;
let wh = w * h;
@@ -288,33 +273,21 @@ export namespace fastBlur {
}
}
- for (let m = 0;m < h; m++) { //y
- for (let n = 0;n < w; n++) { //x
- writePromise = new Promise((resolve, reject) => {
- let buffer1B = new ArrayBuffer(5);
- let bytes1B = new Uint8Array(buffer1B);
- var writePositionRenB = {
- pixels: buffer1B,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: n,
- y: m
- }
- }
- let index = m * w + n;
- bytes1B[0] = pixEntry[m * w + n].a;
- bytes1B[1] = ColorUtils.blue(pix[index]);
- bytes1B[2] = ColorUtils.green(pix[index]);
- bytes1B[3] = ColorUtils.red(pix[index]);
- bytes1B[4] = pixEntry[m * w + n].f;
- bitmap.writePixels(writePositionRenB, () => {
- resolve();
- });
- })
- await writePromise;
- }
+
+ let bufferNewData = new ArrayBuffer(bitmap.getPixelBytesNumber());
+ let dataNewArray = new Uint8Array(bufferNewData);
+ let index = 0;
+
+ for (let i = 0; i < dataNewArray.length; i += 4) {
+ dataNewArray[i] = ColorUtils.red(pix[index]);
+ dataNewArray[i+1] = ColorUtils.green(pix[index]);
+ dataNewArray[i+2] = ColorUtils.blue(pix[index]);
+ dataNewArray[i+3] = pixEntry[index].f;
+ index++;
+ }
+ await bitmap.writeBufferToPixels(bufferNewData);
+ if (func) {
+ func("success", bitmap);
}
- func("success", bitmap);
}
}
diff --git a/entry/src/main/ets/MainAbility/glide/utils/FileTypeUtil.ets b/imageknife/src/main/ets/components/imageknife/utils/FileTypeUtil.ets
similarity index 97%
rename from entry/src/main/ets/MainAbility/glide/utils/FileTypeUtil.ets
rename to imageknife/src/main/ets/components/imageknife/utils/FileTypeUtil.ets
index 7462063..fb8babc 100644
--- a/entry/src/main/ets/MainAbility/glide/utils/FileTypeUtil.ets
+++ b/imageknife/src/main/ets/components/imageknife/utils/FileTypeUtil.ets
@@ -167,6 +167,9 @@ export class FileTypeUtil {
}
getFileType(arraybuffer: ArrayBuffer) {
+ if(arraybuffer == null || arraybuffer == undefined || arraybuffer.byteLength <= this.getMaxKeyLength()){
+ return undefined;
+ }
let maxlen = this.getMaxKeyLength() / 2;
let dataView = new DataView(arraybuffer);
let searchKey = "";
diff --git a/entry/src/main/ets/MainAbility/glide/utils/K2DArray.ets b/imageknife/src/main/ets/components/imageknife/utils/K2DArray.ets
similarity index 100%
rename from entry/src/main/ets/MainAbility/glide/utils/K2DArray.ets
rename to imageknife/src/main/ets/components/imageknife/utils/K2DArray.ets
diff --git a/imageknife/src/main/ets/components/imageknife/utils/MaskUtils.ets b/imageknife/src/main/ets/components/imageknife/utils/MaskUtils.ets
new file mode 100644
index 0000000..756a94b
--- /dev/null
+++ b/imageknife/src/main/ets/components/imageknife/utils/MaskUtils.ets
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {PixelEntry} from "../entry/PixelEntry"
+import {AsyncTransform} from "../transform/AsyncTransform"
+import {ColorUtils} from "./ColorUtils"
+import {CalculatePixelUtils} from "./CalculatePixelUtils"
+
+export class MaskUtils {
+ static async mask(bitmap: any, maskBitmap: any, func?: AsyncTransform) {
+ let imageInfo = await bitmap.getImageInfo();
+ let size = {
+ width: imageInfo.size.width,
+ height: imageInfo.size.height
+ }
+ if (!size) {
+ return;
+ }
+ let width = size.width;
+ let height = size.height;
+
+ let rgbData = CalculatePixelUtils.createInt2DArray(height, width);
+
+ let bufferData = new ArrayBuffer(bitmap.getPixelBytesNumber());
+ await bitmap.readPixelsToBuffer(bufferData);
+ let dataArray = new Uint8Array(bufferData);
+
+ let ph = 0;
+ let pw = 0;
+ for (let index = 0; index < dataArray.length; index += 4) {
+ const r = dataArray[index];
+ const g = dataArray[index+1];
+ const b = dataArray[index+2];
+ const f = dataArray[index+3];
+
+ let entry = new PixelEntry();
+ entry.a = 0;
+ entry.b = b;
+ entry.g = g;
+ entry.r = r;
+ entry.f = f;
+ entry.pixel = ColorUtils.rgb(entry.r, entry.g, entry.b);
+ rgbData[ph][pw] = ColorUtils.rgb(entry.r, entry.g, entry.b);
+ if (pw == width - 1) {
+ pw = 0;
+ ph++;
+ } else {
+ pw++;
+ }
+ }
+
+
+ let imageInfoMask = await maskBitmap.getImageInfo();
+ let sizeMask = {
+ width: imageInfoMask.size.width,
+ height: imageInfoMask.size.height
+ }
+ if (!sizeMask) {
+ return;
+ }
+ let widthMask = sizeMask.width;
+ let heightMask = sizeMask.height;
+ let rgbDataMask = CalculatePixelUtils.createInt2DArray(heightMask, widthMask);
+ let pixEntry: Array = new Array();
+
+ let bufferData_m = new ArrayBuffer(maskBitmap.getPixelBytesNumber());
+ await maskBitmap.readPixelsToBuffer(bufferData_m);
+ let dataArray_m = new Uint8Array(bufferData_m);
+
+ let ph_m = 0;
+ let pw_m = 0;
+
+ for (let index = 0; index < dataArray_m.length; index += 4) {
+ const r = dataArray_m[index];
+ const g = dataArray_m[index+1];
+ const b = dataArray_m[index+2];
+ const f = dataArray_m[index+3];
+
+ let entry = new PixelEntry();
+ entry.a = 0;
+ entry.b = b;
+ entry.g = g;
+ entry.r = r;
+ entry.f = f;
+ entry.pixel = ColorUtils.rgb(entry.r, entry.g, entry.b);
+ pixEntry.push(entry);
+ if (entry.r == 0 && entry.g == 0 && entry.b == 0) {
+ rgbDataMask[ph_m][pw_m] = rgbData[ph_m][pw_m];
+ } else {
+ rgbDataMask[ph_m][pw_m] = ColorUtils.rgb(entry.r, entry.g, entry.b);
+ }
+
+ if (pw_m == widthMask - 1) {
+ pw_m = 0;
+ ph_m++;
+ } else {
+ pw_m++;
+ }
+ }
+
+
+ let bufferNewData = new ArrayBuffer(maskBitmap.getPixelBytesNumber());
+ let dataNewArray = new Uint8Array(bufferNewData);
+ let index = 0;
+ let mh = 0;
+ let nw = 0;
+
+ for (let i = 0; i < dataNewArray.length; i += 4) {
+ let pixel_1 = rgbDataMask[mh][nw];
+
+ if (nw == widthMask - 1) {
+ nw = 0;
+ mh++;
+ } else {
+ nw++;
+ }
+
+ let p_r = ColorUtils.red(pixel_1);
+ let p_g = ColorUtils.green(pixel_1);
+ let p_b = ColorUtils.blue(pixel_1);
+
+ dataNewArray[i] = p_r;
+ dataNewArray[i+1] = p_g;
+ dataNewArray[i+2] = p_b;
+ dataNewArray[i+3] = pixEntry[index].f;
+ index++;
+ }
+ await maskBitmap.writeBufferToPixels(bufferNewData);
+ if (func) {
+ func("", maskBitmap);
+ }
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/glide/utils/ParseImageUtil.ets b/imageknife/src/main/ets/components/imageknife/utils/ParseImageUtil.ets
similarity index 87%
rename from entry/src/main/ets/MainAbility/glide/utils/ParseImageUtil.ets
rename to imageknife/src/main/ets/components/imageknife/utils/ParseImageUtil.ets
index 670cec2..d4dbd5f 100644
--- a/entry/src/main/ets/MainAbility/glide/utils/ParseImageUtil.ets
+++ b/imageknife/src/main/ets/components/imageknife/utils/ParseImageUtil.ets
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-import{IParseImage} from '../interface/IParseImage.ets'
+import{IParseImage} from '../interface/IParseImage'
import image from '@ohos.multimedia.image';
export class ParseImageUtil implements IParseImage {
@@ -23,7 +23,7 @@ export class ParseImageUtil implements IParseImage {
// scale(0,1)
parseImageThumbnail(scale: number, imageinfo: ArrayBuffer, onCompleteFunction, onErrorFunction) {
- let imageSource = image.createImageSource(imageinfo); // 步骤一:文件转为pixelMap 然后变换 给Image组件
+ let imageSource = image.createImageSource(imageinfo as any); // 步骤一:文件转为pixelMap 然后变换 给Image组件
imageSource.getImageInfo((err, value) => {
if (err) {
onErrorFunction(err);
@@ -38,7 +38,7 @@ export class ParseImageUtil implements IParseImage {
let opts = {
editable: true,
- size: defaultSize
+ desiredSize: defaultSize
};
diff --git a/entry/src/main/ets/MainAbility/glide/utils/PixelUtils.ets b/imageknife/src/main/ets/components/imageknife/utils/PixelUtils.ets
similarity index 54%
rename from entry/src/main/ets/MainAbility/glide/utils/PixelUtils.ets
rename to imageknife/src/main/ets/components/imageknife/utils/PixelUtils.ets
index 0cc14de..03fd923 100644
--- a/entry/src/main/ets/MainAbility/glide/utils/PixelUtils.ets
+++ b/imageknife/src/main/ets/components/imageknife/utils/PixelUtils.ets
@@ -36,39 +36,38 @@ export namespace pixelUtils {
var pixEntry: Array = new Array()
let inPixels: Array> = CalculatePixelUtils.createInt2DArray(targetHeight, targetWidth);
- let readPromise;
- let writePromise;
- //读取
- for (let ph = 0; ph < targetHeight; ph++) {
- for (let pw = 0; pw < targetWidth; pw++) {
- let buffer = new ArrayBuffer(5);
- readPromise = new Promise((resolve, reject) => {
- var positionRen = {
- pixels: buffer,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: pw,
- y: ph
- }
- }
- bitmap.readPixels(positionRen, () => {
- resolve();
- });
- });
- await readPromise;
- let bytes = new Uint8Array(buffer);
- let entry = new PixelEntry();
- entry.a = bytes[0];
- entry.b = bytes[1];
- entry.g = bytes[2];
- entry.r = bytes[3];
- entry.f = bytes[4];
- entry.pixel = ColorUtils.rgb(entry.r, entry.g, entry.b);
- pixEntry.push(entry);
- inPixels[ph][pw] = ColorUtils.rgb(entry.r, entry.g, entry.b);
+
+ let bufferData = new ArrayBuffer(bitmap.getPixelBytesNumber());
+ await bitmap.readPixelsToBuffer(bufferData);
+ let dataArray = new Uint8Array(bufferData);
+
+ let ph = 0;
+ let pw = 0;
+
+
+ for (let index = 0; index < dataArray.length; index += 4) {
+ const r = dataArray[index];
+ const g = dataArray[index+1];
+ const b = dataArray[index+2];
+ const f = dataArray[index+3];
+
+ let entry = new PixelEntry();
+ entry.a = 0;
+ entry.b = b;
+ entry.g = g;
+ entry.r = r;
+ entry.f = f;
+ entry.pixel = ColorUtils.rgb(entry.r, entry.g, entry.b);
+ pixEntry.push(entry);
+ inPixels[ph][pw] = ColorUtils.rgb(entry.r, entry.g, entry.b);
+ if (pw == targetWidth - 1) {
+ pw = 0;
+ ph++;
+ } else {
+ pw++;
}
}
+
var realPixel_W = pixel > targetWidth ? targetWidth : pixel;
var realPixel_H = pixel > targetHeight ? targetHeight : pixel;
@@ -99,38 +98,35 @@ export namespace pixelUtils {
}
- for (let m = 0;m < targetHeight; m++) { //y
- for (let n = 0;n < targetWidth; n++) { //x
- writePromise = new Promise((resolve, reject) => {
- let buffer1B = new ArrayBuffer(5);
- let bytes1B = new Uint8Array(buffer1B);
- let writePositionRenB = {
- pixels: buffer1B,
- offset: 1,
- stride: 1024,
- region: { size: { width: 1, height: 1 },
- x: n,
- y: m
- }
- }
- let index = m * targetWidth + n;
- let pxix1 = inPixels[m][n];
- let p_b = ColorUtils.blue(pxix1);
- let p_g = ColorUtils.green(pxix1);
- let p_r = ColorUtils.red(pxix1);
+ let bufferNewData = new ArrayBuffer(bitmap.getPixelBytesNumber());
+ let dataNewArray = new Uint8Array(bufferNewData);
+ let index = 0;
+ let mh = 0;
+ let nw = 0;
- bytes1B[0] = pixEntry[index].a;
- bytes1B[1] = p_b;
- bytes1B[2] = p_g;
- bytes1B[3] = p_r;
- bytes1B[4] = pixEntry[index].f;
- bitmap.writePixels(writePositionRenB, () => {
- resolve();
- });
- })
- await writePromise;
+ for (let i = 0; i < dataNewArray.length; i += 4) {
+ let pixel_1 = inPixels[mh][nw];
+
+ if (nw == targetWidth - 1) {
+ nw = 0;
+ mh++;
+ } else {
+ nw++;
}
+
+ let p_r = ColorUtils.red(pixel_1);
+ let p_g = ColorUtils.green(pixel_1);
+ let p_b = ColorUtils.blue(pixel_1);
+
+ dataNewArray[i] = p_r;
+ dataNewArray[i+1] = p_g;
+ dataNewArray[i+2] = p_b;
+ dataNewArray[i+3] = pixEntry[index].f;
+ index++;
+ }
+ await bitmap.writeBufferToPixels(bufferNewData);
+ if (func) {
+ func("success", bitmap);
}
- func("success", bitmap);
}
}
\ No newline at end of file
diff --git a/imageknife/src/main/resources/base/media/icon_failed.png b/imageknife/src/main/resources/base/media/icon_failed.png
new file mode 100644
index 0000000..6eadcfd
Binary files /dev/null and b/imageknife/src/main/resources/base/media/icon_failed.png differ
diff --git a/imageknife/src/main/resources/base/media/icon_loading.png b/imageknife/src/main/resources/base/media/icon_loading.png
new file mode 100644
index 0000000..6eb4e9a
Binary files /dev/null and b/imageknife/src/main/resources/base/media/icon_loading.png differ
diff --git a/imageknife/src/main/resources/base/media/icon_retry.jpg b/imageknife/src/main/resources/base/media/icon_retry.jpg
new file mode 100644
index 0000000..19911b6
Binary files /dev/null and b/imageknife/src/main/resources/base/media/icon_retry.jpg differ
diff --git a/package-lock.json b/package-lock.json
index 74bc244..336d297 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,11 +1,1657 @@
{
- "requires": true,
+ "name": "imageknifegiteepro",
+ "version": "1.0.0",
"lockfileVersion": 1,
+ "requires": true,
"dependencies": {
- "pako": {
- "version": "1.0.11",
- "resolved": "http://mirrors.tools.huawei.com/npm/pako/-/pako-1.0.11.tgz",
- "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
+ "@ohos/hvigor": {
+ "version": "1.0.6",
+ "resolved": "https://cmc.centralrepo.rnd.huawei.com/artifactory/api/npm/product_npm/@ohos/hvigor/-/@ohos/hvigor-1.0.6.tgz",
+ "integrity": "sha512-jjp7vpvUOMW1Nf7TdyhOtonwWHoSyBJLUiZTQqIx/GJV4UJyIqsiURUOqFwncQ4L7PDdeHuWly4uEelknYeWhg==",
+ "requires": {
+ "@ohos/hvigor-base": "1.0.6",
+ "interpret": "1.4.0",
+ "liftoff": "4.0.0",
+ "mute-stdout": "1.0.0",
+ "pretty-hrtime": "1.0.0",
+ "v8flags": "3.2.0",
+ "yargs": "7.1.0"
+ }
+ },
+ "@ohos/hvigor-base": {
+ "version": "1.0.6",
+ "resolved": "https://cmc.centralrepo.rnd.huawei.com/artifactory/api/npm/product_npm/@ohos/hvigor-base/-/@ohos/hvigor-base-1.0.6.tgz",
+ "integrity": "sha512-cRDnWICTxmpNiFb9clIioqP5Oik1seLCICztXVhZqultrHuxwTheCRUZrHwlpyWdkSB2Al+FFBqmSwzIgZX4IQ==",
+ "requires": {
+ "json5": "2.2.0",
+ "log4js": "6.4.1",
+ "undertaker": "1.2.1"
+ }
+ },
+ "@ohos/hvigor-ohos-plugin": {
+ "version": "1.0.6",
+ "resolved": "https://cmc.centralrepo.rnd.huawei.com/artifactory/api/npm/product_npm/@ohos/hvigor-ohos-plugin/-/@ohos/hvigor-ohos-plugin-1.0.6.tgz",
+ "integrity": "sha512-MAAi8uJxMzODUoSSNfBr+fU4HQ20dfQtkje9I+X4asc7qY2kAplW/q9f5XS8IOvv8zhC8OcSgsAXOAJuLMstOQ==",
+ "requires": {
+ "@ohos/hvigor-base": "1.0.6",
+ "@ohos/sdkmanager-common": "1.1.3",
+ "ajv": "8.10.0",
+ "archiver": "5.3.0",
+ "execa": "5.1.1",
+ "fs-extra": "10.0.0",
+ "glob": "7.2.0",
+ "iconv-lite": "0.6.3",
+ "json5": "2.2.0",
+ "lodash": "4.17.21",
+ "pretty-hrtime": "1.0.3",
+ "resolve-package-path": "4.0.3"
+ },
+ "dependencies": {
+ "fs-extra": {
+ "version": "10.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/fs-extra/-/fs-extra-10.0.0.tgz",
+ "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==",
+ "requires": {
+ "graceful-fs": "^4.2.0",
+ "jsonfile": "^6.0.1",
+ "universalify": "^2.0.0"
+ }
+ },
+ "pretty-hrtime": {
+ "version": "1.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz",
+ "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE="
+ }
+ }
+ },
+ "@ohos/sdkmanager-common": {
+ "version": "1.1.3",
+ "resolved": "https://cmc.centralrepo.rnd.huawei.com/artifactory/api/npm/product_npm/@ohos/sdkmanager-common/-/@ohos/sdkmanager-common-1.1.3.tgz",
+ "integrity": "sha512-d2uhVauDDJZIUvyyaWWoavG4N/jLyfF5IH5kEXKV6R8HNf3606H1zDQzA+UZtOfwwJFXhD9djRjnVFNB8xc7aw=="
+ },
+ "ajv": {
+ "version": "8.10.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/ajv/-/ajv-8.10.0.tgz",
+ "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==",
+ "requires": {
+ "fast-deep-equal": "^3.1.1",
+ "json-schema-traverse": "^1.0.0",
+ "require-from-string": "^2.0.2",
+ "uri-js": "^4.2.2"
+ }
+ },
+ "ansi-regex": {
+ "version": "2.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/ansi-regex/-/ansi-regex-2.1.1.tgz",
+ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
+ },
+ "archiver": {
+ "version": "5.3.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/archiver/-/archiver-5.3.0.tgz",
+ "integrity": "sha512-iUw+oDwK0fgNpvveEsdQ0Ase6IIKztBJU2U0E9MzszMfmVVUyv1QJhS2ITW9ZCqx8dktAxVAjWWkKehuZE8OPg==",
+ "requires": {
+ "archiver-utils": "^2.1.0",
+ "async": "^3.2.0",
+ "buffer-crc32": "^0.2.1",
+ "readable-stream": "^3.6.0",
+ "readdir-glob": "^1.0.0",
+ "tar-stream": "^2.2.0",
+ "zip-stream": "^4.1.0"
+ }
+ },
+ "archiver-utils": {
+ "version": "2.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/archiver-utils/-/archiver-utils-2.1.0.tgz",
+ "integrity": "sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==",
+ "requires": {
+ "glob": "^7.1.4",
+ "graceful-fs": "^4.2.0",
+ "lazystream": "^1.0.0",
+ "lodash.defaults": "^4.2.0",
+ "lodash.difference": "^4.5.0",
+ "lodash.flatten": "^4.4.0",
+ "lodash.isplainobject": "^4.0.6",
+ "lodash.union": "^4.6.0",
+ "normalize-path": "^3.0.0",
+ "readable-stream": "^2.0.0"
+ },
+ "dependencies": {
+ "readable-stream": {
+ "version": "2.3.7",
+ "resolved": "http://mirrors.tools.huawei.com/npm/readable-stream/-/readable-stream-2.3.7.tgz",
+ "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
+ "requires": {
+ "core-util-is": "~1.0.0",
+ "inherits": "~2.0.3",
+ "isarray": "~1.0.0",
+ "process-nextick-args": "~2.0.0",
+ "safe-buffer": "~5.1.1",
+ "string_decoder": "~1.1.1",
+ "util-deprecate": "~1.0.1"
+ }
+ }
+ }
+ },
+ "arr-filter": {
+ "version": "1.1.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/arr-filter/-/arr-filter-1.1.2.tgz",
+ "integrity": "sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4=",
+ "requires": {
+ "make-iterator": "^1.0.0"
+ }
+ },
+ "arr-flatten": {
+ "version": "1.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/arr-flatten/-/arr-flatten-1.1.0.tgz",
+ "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg=="
+ },
+ "arr-map": {
+ "version": "2.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/arr-map/-/arr-map-2.0.2.tgz",
+ "integrity": "sha1-Onc0X/wc814qkYJWAfnljy4kysQ=",
+ "requires": {
+ "make-iterator": "^1.0.0"
+ }
+ },
+ "array-each": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/array-each/-/array-each-1.0.1.tgz",
+ "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8="
+ },
+ "array-initial": {
+ "version": "1.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/array-initial/-/array-initial-1.1.0.tgz",
+ "integrity": "sha1-L6dLJnOTccOUe9enrcc74zSz15U=",
+ "requires": {
+ "array-slice": "^1.0.0",
+ "is-number": "^4.0.0"
+ }
+ },
+ "array-last": {
+ "version": "1.3.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/array-last/-/array-last-1.3.0.tgz",
+ "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==",
+ "requires": {
+ "is-number": "^4.0.0"
+ }
+ },
+ "array-slice": {
+ "version": "1.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/array-slice/-/array-slice-1.1.0.tgz",
+ "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w=="
+ },
+ "async": {
+ "version": "3.2.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/async/-/async-3.2.3.tgz",
+ "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g=="
+ },
+ "async-done": {
+ "version": "1.3.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/async-done/-/async-done-1.3.2.tgz",
+ "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==",
+ "requires": {
+ "end-of-stream": "^1.1.0",
+ "once": "^1.3.2",
+ "process-nextick-args": "^2.0.0",
+ "stream-exhaust": "^1.0.1"
+ }
+ },
+ "async-settle": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/async-settle/-/async-settle-1.0.0.tgz",
+ "integrity": "sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs=",
+ "requires": {
+ "async-done": "^1.2.2"
+ }
+ },
+ "bach": {
+ "version": "1.2.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/bach/-/bach-1.2.0.tgz",
+ "integrity": "sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA=",
+ "requires": {
+ "arr-filter": "^1.1.1",
+ "arr-flatten": "^1.0.1",
+ "arr-map": "^2.0.0",
+ "array-each": "^1.0.0",
+ "array-initial": "^1.0.0",
+ "array-last": "^1.1.1",
+ "async-done": "^1.2.2",
+ "async-settle": "^1.0.0",
+ "now-and-later": "^2.0.0"
+ }
+ },
+ "balanced-match": {
+ "version": "1.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/balanced-match/-/balanced-match-1.0.2.tgz",
+ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
+ },
+ "base64-js": {
+ "version": "1.5.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/base64-js/-/base64-js-1.5.1.tgz",
+ "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
+ },
+ "bl": {
+ "version": "4.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/bl/-/bl-4.1.0.tgz",
+ "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==",
+ "requires": {
+ "buffer": "^5.5.0",
+ "inherits": "^2.0.4",
+ "readable-stream": "^3.4.0"
+ }
+ },
+ "brace-expansion": {
+ "version": "1.1.11",
+ "resolved": "http://mirrors.tools.huawei.com/npm/brace-expansion/-/brace-expansion-1.1.11.tgz",
+ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "requires": {
+ "balanced-match": "^1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "braces": {
+ "version": "3.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/braces/-/braces-3.0.2.tgz",
+ "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
+ "requires": {
+ "fill-range": "^7.0.1"
+ }
+ },
+ "buffer": {
+ "version": "5.7.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/buffer/-/buffer-5.7.1.tgz",
+ "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
+ "requires": {
+ "base64-js": "^1.3.1",
+ "ieee754": "^1.1.13"
+ }
+ },
+ "buffer-crc32": {
+ "version": "0.2.13",
+ "resolved": "http://mirrors.tools.huawei.com/npm/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
+ "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI="
+ },
+ "call-bind": {
+ "version": "1.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/call-bind/-/call-bind-1.0.2.tgz",
+ "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
+ "requires": {
+ "function-bind": "^1.1.1",
+ "get-intrinsic": "^1.0.2"
+ }
+ },
+ "camelcase": {
+ "version": "3.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/camelcase/-/camelcase-3.0.0.tgz",
+ "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo="
+ },
+ "cliui": {
+ "version": "3.2.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/cliui/-/cliui-3.2.0.tgz",
+ "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=",
+ "requires": {
+ "string-width": "^1.0.1",
+ "strip-ansi": "^3.0.1",
+ "wrap-ansi": "^2.0.0"
+ }
+ },
+ "code-point-at": {
+ "version": "1.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/code-point-at/-/code-point-at-1.1.0.tgz",
+ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
+ },
+ "collection-map": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/collection-map/-/collection-map-1.0.0.tgz",
+ "integrity": "sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw=",
+ "requires": {
+ "arr-map": "^2.0.2",
+ "for-own": "^1.0.0",
+ "make-iterator": "^1.0.0"
+ }
+ },
+ "compress-commons": {
+ "version": "4.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/compress-commons/-/compress-commons-4.1.1.tgz",
+ "integrity": "sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==",
+ "requires": {
+ "buffer-crc32": "^0.2.13",
+ "crc32-stream": "^4.0.2",
+ "normalize-path": "^3.0.0",
+ "readable-stream": "^3.6.0"
+ }
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
+ },
+ "core-util-is": {
+ "version": "1.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/core-util-is/-/core-util-is-1.0.3.tgz",
+ "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
+ },
+ "crc-32": {
+ "version": "1.2.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/crc-32/-/crc-32-1.2.1.tgz",
+ "integrity": "sha512-Dn/xm/1vFFgs3nfrpEVScHoIslO9NZRITWGz/1E/St6u4xw99vfZzVkW0OSnzx2h9egej9xwMCEut6sqwokM/w==",
+ "requires": {
+ "exit-on-epipe": "~1.0.1",
+ "printj": "~1.3.1"
+ }
+ },
+ "crc32-stream": {
+ "version": "4.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/crc32-stream/-/crc32-stream-4.0.2.tgz",
+ "integrity": "sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==",
+ "requires": {
+ "crc-32": "^1.2.0",
+ "readable-stream": "^3.4.0"
+ }
+ },
+ "cross-spawn": {
+ "version": "7.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/cross-spawn/-/cross-spawn-7.0.3.tgz",
+ "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
+ "requires": {
+ "path-key": "^3.1.0",
+ "shebang-command": "^2.0.0",
+ "which": "^2.0.1"
+ },
+ "dependencies": {
+ "which": {
+ "version": "2.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/which/-/which-2.0.2.tgz",
+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
+ "requires": {
+ "isexe": "^2.0.0"
+ }
+ }
+ }
+ },
+ "d": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/d/-/d-1.0.1.tgz",
+ "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
+ "requires": {
+ "es5-ext": "^0.10.50",
+ "type": "^1.0.1"
+ }
+ },
+ "date-format": {
+ "version": "4.0.6",
+ "resolved": "http://mirrors.tools.huawei.com/npm/date-format/-/date-format-4.0.6.tgz",
+ "integrity": "sha512-B9vvg5rHuQ8cbUXE/RMWMyX2YA5TecT3jKF5fLtGNlzPlU7zblSPmAm2OImDbWL+LDOQ6pUm+4LOFz+ywS41Zw=="
+ },
+ "debug": {
+ "version": "4.3.4",
+ "resolved": "http://mirrors.tools.huawei.com/npm/debug/-/debug-4.3.4.tgz",
+ "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
+ "requires": {
+ "ms": "2.1.2"
+ }
+ },
+ "decamelize": {
+ "version": "1.2.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/decamelize/-/decamelize-1.2.0.tgz",
+ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
+ },
+ "default-resolution": {
+ "version": "2.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/default-resolution/-/default-resolution-2.0.0.tgz",
+ "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ="
+ },
+ "define-properties": {
+ "version": "1.1.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/define-properties/-/define-properties-1.1.3.tgz",
+ "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
+ "requires": {
+ "object-keys": "^1.0.12"
+ }
+ },
+ "detect-file": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/detect-file/-/detect-file-1.0.0.tgz",
+ "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc="
+ },
+ "end-of-stream": {
+ "version": "1.4.4",
+ "resolved": "http://mirrors.tools.huawei.com/npm/end-of-stream/-/end-of-stream-1.4.4.tgz",
+ "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
+ "requires": {
+ "once": "^1.4.0"
+ }
+ },
+ "error-ex": {
+ "version": "1.3.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/error-ex/-/error-ex-1.3.2.tgz",
+ "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==",
+ "requires": {
+ "is-arrayish": "^0.2.1"
+ }
+ },
+ "es5-ext": {
+ "version": "0.10.59",
+ "resolved": "http://mirrors.tools.huawei.com/npm/es5-ext/-/es5-ext-0.10.59.tgz",
+ "integrity": "sha512-cOgyhW0tIJyQY1Kfw6Kr0viu9ZlUctVchRMZ7R0HiH3dxTSp5zJDLecwxUqPUrGKMsgBI1wd1FL+d9Jxfi4cLw==",
+ "requires": {
+ "es6-iterator": "^2.0.3",
+ "es6-symbol": "^3.1.3",
+ "next-tick": "^1.1.0"
+ }
+ },
+ "es6-iterator": {
+ "version": "2.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/es6-iterator/-/es6-iterator-2.0.3.tgz",
+ "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=",
+ "requires": {
+ "d": "1",
+ "es5-ext": "^0.10.35",
+ "es6-symbol": "^3.1.1"
+ }
+ },
+ "es6-symbol": {
+ "version": "3.1.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/es6-symbol/-/es6-symbol-3.1.3.tgz",
+ "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
+ "requires": {
+ "d": "^1.0.1",
+ "ext": "^1.1.2"
+ }
+ },
+ "es6-weak-map": {
+ "version": "2.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/es6-weak-map/-/es6-weak-map-2.0.3.tgz",
+ "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==",
+ "requires": {
+ "d": "1",
+ "es5-ext": "^0.10.46",
+ "es6-iterator": "^2.0.3",
+ "es6-symbol": "^3.1.1"
+ }
+ },
+ "execa": {
+ "version": "5.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/execa/-/execa-5.1.1.tgz",
+ "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==",
+ "requires": {
+ "cross-spawn": "^7.0.3",
+ "get-stream": "^6.0.0",
+ "human-signals": "^2.1.0",
+ "is-stream": "^2.0.0",
+ "merge-stream": "^2.0.0",
+ "npm-run-path": "^4.0.1",
+ "onetime": "^5.1.2",
+ "signal-exit": "^3.0.3",
+ "strip-final-newline": "^2.0.0"
+ }
+ },
+ "exit-on-epipe": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz",
+ "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw=="
+ },
+ "expand-tilde": {
+ "version": "2.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/expand-tilde/-/expand-tilde-2.0.2.tgz",
+ "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=",
+ "requires": {
+ "homedir-polyfill": "^1.0.1"
+ }
+ },
+ "ext": {
+ "version": "1.6.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/ext/-/ext-1.6.0.tgz",
+ "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==",
+ "requires": {
+ "type": "^2.5.0"
+ },
+ "dependencies": {
+ "type": {
+ "version": "2.6.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/type/-/type-2.6.0.tgz",
+ "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ=="
+ }
+ }
+ },
+ "extend": {
+ "version": "3.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/extend/-/extend-3.0.2.tgz",
+ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
+ },
+ "fast-deep-equal": {
+ "version": "3.1.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
+ },
+ "fill-range": {
+ "version": "7.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/fill-range/-/fill-range-7.0.1.tgz",
+ "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
+ "requires": {
+ "to-regex-range": "^5.0.1"
+ }
+ },
+ "find-up": {
+ "version": "1.1.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/find-up/-/find-up-1.1.2.tgz",
+ "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=",
+ "requires": {
+ "path-exists": "^2.0.0",
+ "pinkie-promise": "^2.0.0"
+ }
+ },
+ "findup-sync": {
+ "version": "5.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/findup-sync/-/findup-sync-5.0.0.tgz",
+ "integrity": "sha512-MzwXju70AuyflbgeOhzvQWAvvQdo1XL0A9bVvlXsYcFEBM87WR4OakL4OfZq+QRmr+duJubio+UtNQCPsVESzQ==",
+ "requires": {
+ "detect-file": "^1.0.0",
+ "is-glob": "^4.0.3",
+ "micromatch": "^4.0.4",
+ "resolve-dir": "^1.0.1"
+ }
+ },
+ "fined": {
+ "version": "2.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/fined/-/fined-2.0.0.tgz",
+ "integrity": "sha512-OFRzsL6ZMHz5s0JrsEr+TpdGNCtrVtnuG3x1yzGNiQHT0yaDnXAj8V/lWcpJVrnoDpcwXcASxAZYbuXda2Y82A==",
+ "requires": {
+ "expand-tilde": "^2.0.2",
+ "is-plain-object": "^5.0.0",
+ "object.defaults": "^1.1.0",
+ "object.pick": "^1.3.0",
+ "parse-filepath": "^1.0.2"
+ }
+ },
+ "flagged-respawn": {
+ "version": "2.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/flagged-respawn/-/flagged-respawn-2.0.0.tgz",
+ "integrity": "sha512-Gq/a6YCi8zexmGHMuJwahTGzXlAZAOsbCVKduWXC6TlLCjjFRlExMJc4GC2NYPYZ0r/brw9P7CpRgQmlPVeOoA=="
+ },
+ "flatted": {
+ "version": "3.2.5",
+ "resolved": "http://mirrors.tools.huawei.com/npm/flatted/-/flatted-3.2.5.tgz",
+ "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg=="
+ },
+ "for-in": {
+ "version": "1.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/for-in/-/for-in-1.0.2.tgz",
+ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA="
+ },
+ "for-own": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/for-own/-/for-own-1.0.0.tgz",
+ "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=",
+ "requires": {
+ "for-in": "^1.0.1"
+ }
+ },
+ "fs-constants": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/fs-constants/-/fs-constants-1.0.0.tgz",
+ "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow=="
+ },
+ "fs-extra": {
+ "version": "10.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/fs-extra/-/fs-extra-10.0.1.tgz",
+ "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==",
+ "requires": {
+ "graceful-fs": "^4.2.0",
+ "jsonfile": "^6.0.1",
+ "universalify": "^2.0.0"
+ }
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
+ },
+ "function-bind": {
+ "version": "1.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/function-bind/-/function-bind-1.1.1.tgz",
+ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
+ },
+ "get-caller-file": {
+ "version": "1.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/get-caller-file/-/get-caller-file-1.0.3.tgz",
+ "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w=="
+ },
+ "get-intrinsic": {
+ "version": "1.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/get-intrinsic/-/get-intrinsic-1.1.1.tgz",
+ "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==",
+ "requires": {
+ "function-bind": "^1.1.1",
+ "has": "^1.0.3",
+ "has-symbols": "^1.0.1"
+ }
+ },
+ "get-stream": {
+ "version": "6.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/get-stream/-/get-stream-6.0.1.tgz",
+ "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg=="
+ },
+ "glob": {
+ "version": "7.2.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/glob/-/glob-7.2.0.tgz",
+ "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
+ "requires": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.0.4",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ }
+ },
+ "global-modules": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/global-modules/-/global-modules-1.0.0.tgz",
+ "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==",
+ "requires": {
+ "global-prefix": "^1.0.1",
+ "is-windows": "^1.0.1",
+ "resolve-dir": "^1.0.0"
+ }
+ },
+ "global-prefix": {
+ "version": "1.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/global-prefix/-/global-prefix-1.0.2.tgz",
+ "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=",
+ "requires": {
+ "expand-tilde": "^2.0.2",
+ "homedir-polyfill": "^1.0.1",
+ "ini": "^1.3.4",
+ "is-windows": "^1.0.1",
+ "which": "^1.2.14"
+ }
+ },
+ "graceful-fs": {
+ "version": "4.2.9",
+ "resolved": "http://mirrors.tools.huawei.com/npm/graceful-fs/-/graceful-fs-4.2.9.tgz",
+ "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ=="
+ },
+ "has": {
+ "version": "1.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/has/-/has-1.0.3.tgz",
+ "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+ "requires": {
+ "function-bind": "^1.1.1"
+ }
+ },
+ "has-symbols": {
+ "version": "1.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/has-symbols/-/has-symbols-1.0.3.tgz",
+ "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="
+ },
+ "homedir-polyfill": {
+ "version": "1.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz",
+ "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==",
+ "requires": {
+ "parse-passwd": "^1.0.0"
+ }
+ },
+ "hosted-git-info": {
+ "version": "2.8.9",
+ "resolved": "http://mirrors.tools.huawei.com/npm/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
+ "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw=="
+ },
+ "human-signals": {
+ "version": "2.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/human-signals/-/human-signals-2.1.0.tgz",
+ "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw=="
+ },
+ "hypium": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/hypium/-/hypium-1.0.0.tgz",
+ "integrity": "sha512-nl+RQVv2AU/5FvFRhsXyWO5wh+2huhdqRZ3bszBWZzW+kpNI3AT4ydvVRYIfaQbYwV4UlX/rSc7BtFjLAezhow=="
+ },
+ "iconv-lite": {
+ "version": "0.6.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/iconv-lite/-/iconv-lite-0.6.3.tgz",
+ "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
+ "requires": {
+ "safer-buffer": ">= 2.1.2 < 3.0.0"
+ }
+ },
+ "ieee754": {
+ "version": "1.2.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/ieee754/-/ieee754-1.2.1.tgz",
+ "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "resolved": "http://mirrors.tools.huawei.com/npm/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+ "requires": {
+ "once": "^1.3.0",
+ "wrappy": "1"
+ }
+ },
+ "inherits": {
+ "version": "2.0.4",
+ "resolved": "http://mirrors.tools.huawei.com/npm/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
+ },
+ "ini": {
+ "version": "1.3.8",
+ "resolved": "http://mirrors.tools.huawei.com/npm/ini/-/ini-1.3.8.tgz",
+ "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
+ },
+ "interpret": {
+ "version": "1.4.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/interpret/-/interpret-1.4.0.tgz",
+ "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA=="
+ },
+ "invert-kv": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/invert-kv/-/invert-kv-1.0.0.tgz",
+ "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY="
+ },
+ "is-absolute": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-absolute/-/is-absolute-1.0.0.tgz",
+ "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==",
+ "requires": {
+ "is-relative": "^1.0.0",
+ "is-windows": "^1.0.1"
+ }
+ },
+ "is-arrayish": {
+ "version": "0.2.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-arrayish/-/is-arrayish-0.2.1.tgz",
+ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0="
+ },
+ "is-core-module": {
+ "version": "2.8.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-core-module/-/is-core-module-2.8.1.tgz",
+ "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==",
+ "requires": {
+ "has": "^1.0.3"
+ }
+ },
+ "is-extglob": {
+ "version": "2.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-extglob/-/is-extglob-2.1.1.tgz",
+ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI="
+ },
+ "is-fullwidth-code-point": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
+ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
+ "requires": {
+ "number-is-nan": "^1.0.0"
+ }
+ },
+ "is-glob": {
+ "version": "4.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-glob/-/is-glob-4.0.3.tgz",
+ "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
+ "requires": {
+ "is-extglob": "^2.1.1"
+ }
+ },
+ "is-number": {
+ "version": "4.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-number/-/is-number-4.0.0.tgz",
+ "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ=="
+ },
+ "is-plain-object": {
+ "version": "5.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-plain-object/-/is-plain-object-5.0.0.tgz",
+ "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
+ },
+ "is-relative": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-relative/-/is-relative-1.0.0.tgz",
+ "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==",
+ "requires": {
+ "is-unc-path": "^1.0.0"
+ }
+ },
+ "is-stream": {
+ "version": "2.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-stream/-/is-stream-2.0.1.tgz",
+ "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="
+ },
+ "is-unc-path": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-unc-path/-/is-unc-path-1.0.0.tgz",
+ "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==",
+ "requires": {
+ "unc-path-regex": "^0.1.2"
+ }
+ },
+ "is-utf8": {
+ "version": "0.2.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-utf8/-/is-utf8-0.2.1.tgz",
+ "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI="
+ },
+ "is-windows": {
+ "version": "1.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-windows/-/is-windows-1.0.2.tgz",
+ "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA=="
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/isarray/-/isarray-1.0.0.tgz",
+ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
+ },
+ "isexe": {
+ "version": "2.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/isexe/-/isexe-2.0.0.tgz",
+ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
+ },
+ "isobject": {
+ "version": "3.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/isobject/-/isobject-3.0.1.tgz",
+ "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8="
+ },
+ "json-schema-traverse": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
+ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
+ },
+ "json5": {
+ "version": "2.2.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/json5/-/json5-2.2.0.tgz",
+ "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==",
+ "requires": {
+ "minimist": "^1.2.5"
+ }
+ },
+ "jsonfile": {
+ "version": "6.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/jsonfile/-/jsonfile-6.1.0.tgz",
+ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
+ "requires": {
+ "graceful-fs": "^4.1.6",
+ "universalify": "^2.0.0"
+ }
+ },
+ "kind-of": {
+ "version": "6.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/kind-of/-/kind-of-6.0.3.tgz",
+ "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw=="
+ },
+ "last-run": {
+ "version": "1.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/last-run/-/last-run-1.1.1.tgz",
+ "integrity": "sha1-RblpQsF7HHnHchmCWbqUO+v4yls=",
+ "requires": {
+ "default-resolution": "^2.0.0",
+ "es6-weak-map": "^2.0.1"
+ }
+ },
+ "lazystream": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/lazystream/-/lazystream-1.0.1.tgz",
+ "integrity": "sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==",
+ "requires": {
+ "readable-stream": "^2.0.5"
+ },
+ "dependencies": {
+ "readable-stream": {
+ "version": "2.3.7",
+ "resolved": "http://mirrors.tools.huawei.com/npm/readable-stream/-/readable-stream-2.3.7.tgz",
+ "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
+ "requires": {
+ "core-util-is": "~1.0.0",
+ "inherits": "~2.0.3",
+ "isarray": "~1.0.0",
+ "process-nextick-args": "~2.0.0",
+ "safe-buffer": "~5.1.1",
+ "string_decoder": "~1.1.1",
+ "util-deprecate": "~1.0.1"
+ }
+ }
+ }
+ },
+ "lcid": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/lcid/-/lcid-1.0.0.tgz",
+ "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=",
+ "requires": {
+ "invert-kv": "^1.0.0"
+ }
+ },
+ "liftoff": {
+ "version": "4.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/liftoff/-/liftoff-4.0.0.tgz",
+ "integrity": "sha512-rMGwYF8q7g2XhG2ulBmmJgWv25qBsqRbDn5gH0+wnuyeFt7QBJlHJmtg5qEdn4pN6WVAUMgXnIxytMFRX9c1aA==",
+ "requires": {
+ "extend": "^3.0.2",
+ "findup-sync": "^5.0.0",
+ "fined": "^2.0.0",
+ "flagged-respawn": "^2.0.0",
+ "is-plain-object": "^5.0.0",
+ "object.map": "^1.0.1",
+ "rechoir": "^0.8.0",
+ "resolve": "^1.20.0"
+ }
+ },
+ "load-json-file": {
+ "version": "1.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/load-json-file/-/load-json-file-1.1.0.tgz",
+ "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
+ "requires": {
+ "graceful-fs": "^4.1.2",
+ "parse-json": "^2.2.0",
+ "pify": "^2.0.0",
+ "pinkie-promise": "^2.0.0",
+ "strip-bom": "^2.0.0"
+ }
+ },
+ "lodash": {
+ "version": "4.17.21",
+ "resolved": "http://mirrors.tools.huawei.com/npm/lodash/-/lodash-4.17.21.tgz",
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
+ },
+ "lodash.defaults": {
+ "version": "4.2.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
+ "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw="
+ },
+ "lodash.difference": {
+ "version": "4.5.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/lodash.difference/-/lodash.difference-4.5.0.tgz",
+ "integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw="
+ },
+ "lodash.flatten": {
+ "version": "4.4.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/lodash.flatten/-/lodash.flatten-4.4.0.tgz",
+ "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8="
+ },
+ "lodash.isplainobject": {
+ "version": "4.0.6",
+ "resolved": "http://mirrors.tools.huawei.com/npm/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
+ "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs="
+ },
+ "lodash.union": {
+ "version": "4.6.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/lodash.union/-/lodash.union-4.6.0.tgz",
+ "integrity": "sha1-SLtQiECfFvGCFmZkHETdGqrjzYg="
+ },
+ "log4js": {
+ "version": "6.4.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/log4js/-/log4js-6.4.1.tgz",
+ "integrity": "sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg==",
+ "requires": {
+ "date-format": "^4.0.3",
+ "debug": "^4.3.3",
+ "flatted": "^3.2.4",
+ "rfdc": "^1.3.0",
+ "streamroller": "^3.0.2"
+ }
+ },
+ "make-iterator": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/make-iterator/-/make-iterator-1.0.1.tgz",
+ "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==",
+ "requires": {
+ "kind-of": "^6.0.2"
+ }
+ },
+ "map-cache": {
+ "version": "0.2.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/map-cache/-/map-cache-0.2.2.tgz",
+ "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8="
+ },
+ "merge-stream": {
+ "version": "2.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/merge-stream/-/merge-stream-2.0.0.tgz",
+ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w=="
+ },
+ "micromatch": {
+ "version": "4.0.4",
+ "resolved": "http://mirrors.tools.huawei.com/npm/micromatch/-/micromatch-4.0.4.tgz",
+ "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
+ "requires": {
+ "braces": "^3.0.1",
+ "picomatch": "^2.2.3"
+ }
+ },
+ "mimic-fn": {
+ "version": "2.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/mimic-fn/-/mimic-fn-2.1.0.tgz",
+ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg=="
+ },
+ "minimatch": {
+ "version": "3.1.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/minimatch/-/minimatch-3.1.2.tgz",
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
+ "requires": {
+ "brace-expansion": "^1.1.7"
+ }
+ },
+ "minimist": {
+ "version": "1.2.6",
+ "resolved": "http://mirrors.tools.huawei.com/npm/minimist/-/minimist-1.2.6.tgz",
+ "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
+ },
+ "ms": {
+ "version": "2.1.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/ms/-/ms-2.1.2.tgz",
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
+ },
+ "mute-stdout": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/mute-stdout/-/mute-stdout-1.0.0.tgz",
+ "integrity": "sha1-WzLqB+tDyd7WEwQ0z5JvRrKn/U0="
+ },
+ "next-tick": {
+ "version": "1.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/next-tick/-/next-tick-1.1.0.tgz",
+ "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
+ },
+ "normalize-package-data": {
+ "version": "2.5.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
+ "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==",
+ "requires": {
+ "hosted-git-info": "^2.1.4",
+ "resolve": "^1.10.0",
+ "semver": "2 || 3 || 4 || 5",
+ "validate-npm-package-license": "^3.0.1"
+ }
+ },
+ "normalize-path": {
+ "version": "3.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/normalize-path/-/normalize-path-3.0.0.tgz",
+ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="
+ },
+ "now-and-later": {
+ "version": "2.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/now-and-later/-/now-and-later-2.0.1.tgz",
+ "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==",
+ "requires": {
+ "once": "^1.3.2"
+ }
+ },
+ "npm-run-path": {
+ "version": "4.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/npm-run-path/-/npm-run-path-4.0.1.tgz",
+ "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==",
+ "requires": {
+ "path-key": "^3.0.0"
+ }
+ },
+ "number-is-nan": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/number-is-nan/-/number-is-nan-1.0.1.tgz",
+ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
+ },
+ "object-keys": {
+ "version": "1.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/object-keys/-/object-keys-1.1.1.tgz",
+ "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="
+ },
+ "object.assign": {
+ "version": "4.1.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/object.assign/-/object.assign-4.1.2.tgz",
+ "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==",
+ "requires": {
+ "call-bind": "^1.0.0",
+ "define-properties": "^1.1.3",
+ "has-symbols": "^1.0.1",
+ "object-keys": "^1.1.1"
+ }
+ },
+ "object.defaults": {
+ "version": "1.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/object.defaults/-/object.defaults-1.1.0.tgz",
+ "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=",
+ "requires": {
+ "array-each": "^1.0.1",
+ "array-slice": "^1.0.0",
+ "for-own": "^1.0.0",
+ "isobject": "^3.0.0"
+ }
+ },
+ "object.map": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/object.map/-/object.map-1.0.1.tgz",
+ "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=",
+ "requires": {
+ "for-own": "^1.0.0",
+ "make-iterator": "^1.0.0"
+ }
+ },
+ "object.pick": {
+ "version": "1.3.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/object.pick/-/object.pick-1.3.0.tgz",
+ "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=",
+ "requires": {
+ "isobject": "^3.0.1"
+ }
+ },
+ "object.reduce": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/object.reduce/-/object.reduce-1.0.1.tgz",
+ "integrity": "sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60=",
+ "requires": {
+ "for-own": "^1.0.0",
+ "make-iterator": "^1.0.0"
+ }
+ },
+ "once": {
+ "version": "1.4.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/once/-/once-1.4.0.tgz",
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
+ "requires": {
+ "wrappy": "1"
+ }
+ },
+ "onetime": {
+ "version": "5.1.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/onetime/-/onetime-5.1.2.tgz",
+ "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==",
+ "requires": {
+ "mimic-fn": "^2.1.0"
+ }
+ },
+ "os-locale": {
+ "version": "1.4.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/os-locale/-/os-locale-1.4.0.tgz",
+ "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=",
+ "requires": {
+ "lcid": "^1.0.0"
+ }
+ },
+ "parse-filepath": {
+ "version": "1.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/parse-filepath/-/parse-filepath-1.0.2.tgz",
+ "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=",
+ "requires": {
+ "is-absolute": "^1.0.0",
+ "map-cache": "^0.2.0",
+ "path-root": "^0.1.1"
+ }
+ },
+ "parse-json": {
+ "version": "2.2.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/parse-json/-/parse-json-2.2.0.tgz",
+ "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
+ "requires": {
+ "error-ex": "^1.2.0"
+ }
+ },
+ "parse-passwd": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/parse-passwd/-/parse-passwd-1.0.0.tgz",
+ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY="
+ },
+ "path-exists": {
+ "version": "2.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/path-exists/-/path-exists-2.1.0.tgz",
+ "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=",
+ "requires": {
+ "pinkie-promise": "^2.0.0"
+ }
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
+ },
+ "path-key": {
+ "version": "3.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/path-key/-/path-key-3.1.1.tgz",
+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="
+ },
+ "path-parse": {
+ "version": "1.0.7",
+ "resolved": "http://mirrors.tools.huawei.com/npm/path-parse/-/path-parse-1.0.7.tgz",
+ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="
+ },
+ "path-root": {
+ "version": "0.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/path-root/-/path-root-0.1.1.tgz",
+ "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=",
+ "requires": {
+ "path-root-regex": "^0.1.0"
+ }
+ },
+ "path-root-regex": {
+ "version": "0.1.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/path-root-regex/-/path-root-regex-0.1.2.tgz",
+ "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0="
+ },
+ "path-type": {
+ "version": "1.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/path-type/-/path-type-1.1.0.tgz",
+ "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=",
+ "requires": {
+ "graceful-fs": "^4.1.2",
+ "pify": "^2.0.0",
+ "pinkie-promise": "^2.0.0"
+ }
+ },
+ "picomatch": {
+ "version": "2.3.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/picomatch/-/picomatch-2.3.1.tgz",
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="
+ },
+ "pify": {
+ "version": "2.3.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/pify/-/pify-2.3.0.tgz",
+ "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
+ },
+ "pinkie": {
+ "version": "2.0.4",
+ "resolved": "http://mirrors.tools.huawei.com/npm/pinkie/-/pinkie-2.0.4.tgz",
+ "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA="
+ },
+ "pinkie-promise": {
+ "version": "2.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/pinkie-promise/-/pinkie-promise-2.0.1.tgz",
+ "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=",
+ "requires": {
+ "pinkie": "^2.0.0"
+ }
+ },
+ "pretty-hrtime": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/pretty-hrtime/-/pretty-hrtime-1.0.0.tgz",
+ "integrity": "sha1-9ualItPmBwRSK/Db5oVu0g515Nw="
+ },
+ "printj": {
+ "version": "1.3.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/printj/-/printj-1.3.1.tgz",
+ "integrity": "sha512-GA3TdL8szPK4AQ2YnOe/b+Y1jUFwmmGMMK/qbY7VcE3Z7FU8JstbKiKRzO6CIiAKPhTO8m01NoQ0V5f3jc4OGg=="
+ },
+ "process-nextick-args": {
+ "version": "2.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
+ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
+ },
+ "punycode": {
+ "version": "2.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/punycode/-/punycode-2.1.1.tgz",
+ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
+ },
+ "read-pkg": {
+ "version": "1.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/read-pkg/-/read-pkg-1.1.0.tgz",
+ "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=",
+ "requires": {
+ "load-json-file": "^1.0.0",
+ "normalize-package-data": "^2.3.2",
+ "path-type": "^1.0.0"
+ }
+ },
+ "read-pkg-up": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/read-pkg-up/-/read-pkg-up-1.0.1.tgz",
+ "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=",
+ "requires": {
+ "find-up": "^1.0.0",
+ "read-pkg": "^1.0.0"
+ }
+ },
+ "readable-stream": {
+ "version": "3.6.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/readable-stream/-/readable-stream-3.6.0.tgz",
+ "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
+ "requires": {
+ "inherits": "^2.0.3",
+ "string_decoder": "^1.1.1",
+ "util-deprecate": "^1.0.1"
+ }
+ },
+ "readdir-glob": {
+ "version": "1.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/readdir-glob/-/readdir-glob-1.1.1.tgz",
+ "integrity": "sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==",
+ "requires": {
+ "minimatch": "^3.0.4"
+ }
+ },
+ "rechoir": {
+ "version": "0.8.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/rechoir/-/rechoir-0.8.0.tgz",
+ "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==",
+ "requires": {
+ "resolve": "^1.20.0"
+ }
+ },
+ "require-directory": {
+ "version": "2.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/require-directory/-/require-directory-2.1.1.tgz",
+ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I="
+ },
+ "require-from-string": {
+ "version": "2.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/require-from-string/-/require-from-string-2.0.2.tgz",
+ "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw=="
+ },
+ "require-main-filename": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/require-main-filename/-/require-main-filename-1.0.1.tgz",
+ "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE="
+ },
+ "resolve": {
+ "version": "1.22.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/resolve/-/resolve-1.22.0.tgz",
+ "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==",
+ "requires": {
+ "is-core-module": "^2.8.1",
+ "path-parse": "^1.0.7",
+ "supports-preserve-symlinks-flag": "^1.0.0"
+ }
+ },
+ "resolve-dir": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/resolve-dir/-/resolve-dir-1.0.1.tgz",
+ "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=",
+ "requires": {
+ "expand-tilde": "^2.0.0",
+ "global-modules": "^1.0.0"
+ }
+ },
+ "resolve-package-path": {
+ "version": "4.0.3",
+ "resolved": "http://mirrors.tools.huawei.com/npm/resolve-package-path/-/resolve-package-path-4.0.3.tgz",
+ "integrity": "sha512-SRpNAPW4kewOaNUt8VPqhJ0UMxawMwzJD8V7m1cJfdSTK9ieZwS6K7Dabsm4bmLFM96Z5Y/UznrpG5kt1im8yA==",
+ "requires": {
+ "path-root": "^0.1.1"
+ }
+ },
+ "rfdc": {
+ "version": "1.3.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/rfdc/-/rfdc-1.3.0.tgz",
+ "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA=="
+ },
+ "safe-buffer": {
+ "version": "5.1.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/safe-buffer/-/safe-buffer-5.1.2.tgz",
+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
+ },
+ "safer-buffer": {
+ "version": "2.1.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/safer-buffer/-/safer-buffer-2.1.2.tgz",
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
+ },
+ "semver": {
+ "version": "5.7.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/semver/-/semver-5.7.1.tgz",
+ "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
+ },
+ "set-blocking": {
+ "version": "2.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/set-blocking/-/set-blocking-2.0.0.tgz",
+ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
+ },
+ "shebang-command": {
+ "version": "2.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/shebang-command/-/shebang-command-2.0.0.tgz",
+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
+ "requires": {
+ "shebang-regex": "^3.0.0"
+ }
+ },
+ "shebang-regex": {
+ "version": "3.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/shebang-regex/-/shebang-regex-3.0.0.tgz",
+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="
+ },
+ "signal-exit": {
+ "version": "3.0.7",
+ "resolved": "http://mirrors.tools.huawei.com/npm/signal-exit/-/signal-exit-3.0.7.tgz",
+ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="
+ },
+ "spdx-correct": {
+ "version": "3.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/spdx-correct/-/spdx-correct-3.1.1.tgz",
+ "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==",
+ "requires": {
+ "spdx-expression-parse": "^3.0.0",
+ "spdx-license-ids": "^3.0.0"
+ }
+ },
+ "spdx-exceptions": {
+ "version": "2.3.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz",
+ "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A=="
+ },
+ "spdx-expression-parse": {
+ "version": "3.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz",
+ "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==",
+ "requires": {
+ "spdx-exceptions": "^2.1.0",
+ "spdx-license-ids": "^3.0.0"
+ }
+ },
+ "spdx-license-ids": {
+ "version": "3.0.11",
+ "resolved": "http://mirrors.tools.huawei.com/npm/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz",
+ "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g=="
+ },
+ "stream-exhaust": {
+ "version": "1.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/stream-exhaust/-/stream-exhaust-1.0.2.tgz",
+ "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw=="
+ },
+ "streamroller": {
+ "version": "3.0.6",
+ "resolved": "http://mirrors.tools.huawei.com/npm/streamroller/-/streamroller-3.0.6.tgz",
+ "integrity": "sha512-Qz32plKq/MZywYyhEatxyYc8vs994Gz0Hu2MSYXXLD233UyPeIeRBZARIIGwFer4Mdb8r3Y2UqKkgyDghM6QCg==",
+ "requires": {
+ "date-format": "^4.0.6",
+ "debug": "^4.3.4",
+ "fs-extra": "^10.0.1"
+ }
+ },
+ "string-width": {
+ "version": "1.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/string-width/-/string-width-1.0.2.tgz",
+ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
+ "requires": {
+ "code-point-at": "^1.0.0",
+ "is-fullwidth-code-point": "^1.0.0",
+ "strip-ansi": "^3.0.0"
+ }
+ },
+ "string_decoder": {
+ "version": "1.1.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/string_decoder/-/string_decoder-1.1.1.tgz",
+ "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
+ "requires": {
+ "safe-buffer": "~5.1.0"
+ }
+ },
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "requires": {
+ "ansi-regex": "^2.0.0"
+ }
+ },
+ "strip-bom": {
+ "version": "2.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/strip-bom/-/strip-bom-2.0.0.tgz",
+ "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
+ "requires": {
+ "is-utf8": "^0.2.0"
+ }
+ },
+ "strip-final-newline": {
+ "version": "2.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/strip-final-newline/-/strip-final-newline-2.0.0.tgz",
+ "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA=="
+ },
+ "supports-preserve-symlinks-flag": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
+ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w=="
+ },
+ "tar-stream": {
+ "version": "2.2.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/tar-stream/-/tar-stream-2.2.0.tgz",
+ "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",
+ "requires": {
+ "bl": "^4.0.3",
+ "end-of-stream": "^1.4.1",
+ "fs-constants": "^1.0.0",
+ "inherits": "^2.0.3",
+ "readable-stream": "^3.1.1"
+ }
+ },
+ "to-regex-range": {
+ "version": "5.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/to-regex-range/-/to-regex-range-5.0.1.tgz",
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
+ "requires": {
+ "is-number": "^7.0.0"
+ },
+ "dependencies": {
+ "is-number": {
+ "version": "7.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/is-number/-/is-number-7.0.0.tgz",
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
+ }
+ }
+ },
+ "type": {
+ "version": "1.2.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/type/-/type-1.2.0.tgz",
+ "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
+ },
+ "unc-path-regex": {
+ "version": "0.1.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/unc-path-regex/-/unc-path-regex-0.1.2.tgz",
+ "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo="
+ },
+ "undertaker": {
+ "version": "1.2.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/undertaker/-/undertaker-1.2.1.tgz",
+ "integrity": "sha512-71WxIzDkgYk9ZS+spIB8iZXchFhAdEo2YU8xYqBYJ39DIUIqziK78ftm26eecoIY49X0J2MLhG4hr18Yp6/CMA==",
+ "requires": {
+ "arr-flatten": "^1.0.1",
+ "arr-map": "^2.0.0",
+ "bach": "^1.0.0",
+ "collection-map": "^1.0.0",
+ "es6-weak-map": "^2.0.1",
+ "last-run": "^1.1.0",
+ "object.defaults": "^1.0.0",
+ "object.reduce": "^1.0.0",
+ "undertaker-registry": "^1.0.0"
+ }
+ },
+ "undertaker-registry": {
+ "version": "1.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/undertaker-registry/-/undertaker-registry-1.0.1.tgz",
+ "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA="
+ },
+ "universalify": {
+ "version": "2.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/universalify/-/universalify-2.0.0.tgz",
+ "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ=="
+ },
+ "uri-js": {
+ "version": "4.4.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/uri-js/-/uri-js-4.4.1.tgz",
+ "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
+ "requires": {
+ "punycode": "^2.1.0"
+ }
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
+ },
+ "v8flags": {
+ "version": "3.2.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/v8flags/-/v8flags-3.2.0.tgz",
+ "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==",
+ "requires": {
+ "homedir-polyfill": "^1.0.1"
+ }
+ },
+ "validate-npm-package-license": {
+ "version": "3.0.4",
+ "resolved": "http://mirrors.tools.huawei.com/npm/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
+ "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==",
+ "requires": {
+ "spdx-correct": "^3.0.0",
+ "spdx-expression-parse": "^3.0.0"
+ }
+ },
+ "which": {
+ "version": "1.3.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/which/-/which-1.3.1.tgz",
+ "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
+ "requires": {
+ "isexe": "^2.0.0"
+ }
+ },
+ "which-module": {
+ "version": "1.0.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/which-module/-/which-module-1.0.0.tgz",
+ "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8="
+ },
+ "wrap-ansi": {
+ "version": "2.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
+ "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
+ "requires": {
+ "string-width": "^1.0.1",
+ "strip-ansi": "^3.0.1"
+ }
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
+ },
+ "y18n": {
+ "version": "3.2.2",
+ "resolved": "http://mirrors.tools.huawei.com/npm/y18n/-/y18n-3.2.2.tgz",
+ "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ=="
+ },
+ "yargs": {
+ "version": "7.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/yargs/-/yargs-7.1.0.tgz",
+ "integrity": "sha1-a6MY6xaWFyf10oT46gA+jWFU0Mg=",
+ "requires": {
+ "camelcase": "^3.0.0",
+ "cliui": "^3.2.0",
+ "decamelize": "^1.1.1",
+ "get-caller-file": "^1.0.1",
+ "os-locale": "^1.4.0",
+ "read-pkg-up": "^1.0.1",
+ "require-directory": "^2.1.1",
+ "require-main-filename": "^1.0.1",
+ "set-blocking": "^2.0.0",
+ "string-width": "^1.0.2",
+ "which-module": "^1.0.0",
+ "y18n": "^3.2.1",
+ "yargs-parser": "^5.0.0"
+ }
+ },
+ "yargs-parser": {
+ "version": "5.0.1",
+ "resolved": "http://mirrors.tools.huawei.com/npm/yargs-parser/-/yargs-parser-5.0.1.tgz",
+ "integrity": "sha512-wpav5XYiddjXxirPoCTUPbqM0PXvJ9hiBMvuJgInvo4/lAOTZzUprArw17q2O1P2+GHhbBr18/iQwjL5Z9BqfA==",
+ "requires": {
+ "camelcase": "^3.0.0",
+ "object.assign": "^4.1.0"
+ }
+ },
+ "zip-stream": {
+ "version": "4.1.0",
+ "resolved": "http://mirrors.tools.huawei.com/npm/zip-stream/-/zip-stream-4.1.0.tgz",
+ "integrity": "sha512-zshzwQW7gG7hjpBlgeQP9RuyPGNxvJdzR8SUM3QhxCnLjWN2E7j3dOvpeDcQoETfHx0urRS7EtmVToql7YpU4A==",
+ "requires": {
+ "archiver-utils": "^2.1.0",
+ "compress-commons": "^4.1.0",
+ "readable-stream": "^3.6.0"
+ }
}
}
}
diff --git a/package.json b/package.json
index a0c761f..282d2d2 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,18 @@
{
- "dependencies": {
- "pako": "^1.0.5"
- }
-}
+ "license":"ISC",
+ "devDependencies":{},
+ "name":"imageknifegiteepro",
+ "ohos":{
+ "org":"huawei",
+ "directoryLevel":"project",
+ "buildTool":"hvigor"
+ },
+ "description":"example description",
+ "repository":{},
+ "version":"1.0.0",
+ "dependencies":{
+ "@ohos/hvigor-ohos-plugin":"1.0.6",
+ "hypium":"^1.0.0",
+ "@ohos/hvigor":"1.0.6"
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
deleted file mode 100644
index 4773db7..0000000
--- a/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':entry'