Compare commits

...

224 Commits

Author SHA1 Message Date
landwind bc55de9e2e Modify the README file
Signed-off-by: landwind <mamingshuai1@huawei.com>
2025-04-28 10:56:30 +08:00
openharmony_ci c1426cd35a
!463 项目配置文件新增设备类型,样例设置混淆
Merge pull request !463 from zgf/master
2025-02-20 03:00:15 +00:00
zgf adb78853af 项目配置文件新增设备类型,样例设置混淆
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-02-19 17:39:29 +08:00
openharmony_ci 9e387602f6
!461 支持图片携带的EXIF元数据作为显示方向
Merge pull request !461 from yang/master
2025-02-19 09:24:27 +00:00
yang 115118e238 支持图片携带的EXIF元数据作为显示方向
Signed-off-by: yang <yangweiping7@h-partners.com>
2025-02-19 14:46:37 +08:00
openharmony_ci acb45a66bc
!460 修改版本号3.2.2-rc.0
Merge pull request !460 from zgf/master
2025-02-18 07:51:13 +00:00
zgf 25b7899746 修改版本号3.2.2-rc.0
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-02-18 15:03:11 +08:00
openharmony_ci e41fce46bf
!459 增加ImageKnifeComponent组件销毁网络请求中断
Merge pull request !459 from zgf/master
2025-02-18 03:56:03 +00:00
zgf 8601f87865 增加ImageKnifeComponent组件销毁网络请求中断
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-02-13 16:15:49 +08:00
openharmony_ci 933cc284ec
!458 优化ImageKnifeLoader类的getImageArrayBuffer方法
Merge pull request !458 from 刘海康/master
2025-02-07 09:12:11 +00:00
openharmony_ci fbf4cc88bd
!456 增加图片下载失败各种错误信息样例
Merge pull request !456 from zgf/master
2025-02-07 02:48:13 +00:00
liuhaikang a21a8f025f 优化ImageKnifeLoader类的getImageArrayBuffer方法
Signed-off-by: liuhaikang <liuhaikang1@h-partners.com>
2025-02-06 20:09:06 +08:00
zgf 996fc5c909
增加图片下载失败各种错误信息样例
增加图片下载失败各种错误信息样例

Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-02-06 08:16:36 +00:00
zgf 677ea73337 增加图片下载失败各种错误信息样例
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-02-06 15:56:37 +08:00
openharmony_ci 5c22496b96
!455 发布正式版本3.2.1
Merge pull request !455 from 刘海康/master
2025-01-23 03:38:42 +00:00
liuhaikang 425aa3a5bc 发布正式版本3.2.1
Signed-off-by: liuhaikang <liuhaikang1@h-partners.com>
2025-01-23 11:04:36 +08:00
openharmony_ci 226d9939be
!454 判断loadSrc传入pixelmap类型处增加保护
Merge pull request !454 from zgf/master
2025-01-21 08:04:35 +00:00
zgf 2c7473f422 判断loadSrc传入pixelmap类型处增加保护
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-01-21 15:25:12 +08:00
openharmony_ci 17e3787cfa
!453 优化文件缓存初始化效率
Merge pull request !453 from 刘海康/master
2025-01-21 02:29:39 +00:00
liuhaikang 915eded1ab 优化文件缓存初始化效率
Signed-off-by: liuhaikang <liuhaikang1@h-partners.com>
2025-01-20 15:34:07 +08:00
openharmony_ci a1e8e0b15f
!452 修复自定义矩形裁剪异常、清除文件缓存接口导致文件缓存失效
Merge pull request !452 from zgf/master
2025-01-13 07:40:45 +00:00
zgf 1615da7b7c 修复自定义矩形裁剪异常、清除文件缓存接口导致文件缓存失效
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-01-13 14:49:46 +08:00
madixin 3378d36046 优化ImageFit.Auto的demo,使用滚动条调整宽度,体现高度的自适应
Signed-off-by: madixin <42690727@qq.com>
2025-01-12 11:57:05 +08:00
openharmony_ci f709bd3f01
!450 修改版本号和OAT配置
Merge pull request !450 from zgf/master
2025-01-03 06:02:22 +00:00
zgf a844860bae 修改版本号和OAT配置
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-01-03 12:07:39 +08:00
zgf 60ec83850a 删除重复debug日志(showpixelmap)
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-01-02 07:36:20 +00:00
openharmony_ci 9939c748a8
!448 修改样例resource泄露、heic格式补充、降采样优化、增加解码和文件读取debug日志
Merge pull request !448 from zgf/master
2025-01-02 02:23:11 +00:00
zgf 1efe55db1e 修改样例resource泄露、heic格式补充、降采样优化、增加解码和文件读取debug日志
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2025-01-02 10:15:25 +08:00
openharmony_ci 990a9a363f
!446 修正decodeEndTime记录错误
Merge pull request !446 from Madi/master
2024-12-24 03:05:09 +00:00
madixin 618320843f 1.修正decodeEndTime记录错误
2.内存缓存记录图片buffersize
3.测试加载回调demo里展示图片来源于网络,文件缓存,还是内存缓存。 去除renderTime的记录
4.调整动图的测试页面,不涉及逻辑修改

Signed-off-by: madixin <madixin@huawei.com>
2024-12-24 10:40:17 +08:00
openharmony_ci db56763a50
!445 扩大内存和文件缓存的限制和默认值
Merge pull request !445 from Madi/master
2024-12-23 02:48:35 +00:00
madixin 2f2e562aed 扩大内存和文件缓存的限制和默认值
Signed-off-by: madixin <madixin@huawei.com>
2024-12-21 18:25:32 +08:00
zgf fc6668cb0d 高度自适应方案修改、成功回调返回httpCode以及修复错误码httpCode无数据
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-12-19 17:04:22 +08:00
openharmony_ci ba48f233a7
!443 增加页面展示和测试local本地图片的显示
Merge pull request !443 from Madi/master
2024-12-16 03:58:54 +00:00
madixin 549d9edf48 1.增加页面展示和测试local本地图片的显示,目前发现rawfile下的文件无法显示
2.httpRequestOption --》 HttpRequestOption

Signed-off-by: madixin <madixin@huawei.com>
2024-12-14 17:22:05 +08:00
openharmony_ci db78e56e9a
!442 增加日志开关和网络请求超时参数
Merge pull request !442 from zgf/master
2024-12-09 02:56:01 +00:00
zgf 68672e1dc7 增加日志开关和网络请求超时参数
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-12-09 10:43:33 +08:00
zgf 6719e8ab19 修改网络请求readTimeout和日志修改
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-12-05 19:35:18 +08:00
zgf 7b025a7415 错误日志和回调增加信息
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-12-04 06:44:32 +00:00
openharmony_ci 912c23f34b
!439 调整closeSync方法,紧接着writeSync,readSync,防止打开的文件没有正确关闭
Merge pull request !439 from Madi/master
2024-12-03 10:43:13 +00:00
madixin 5f548d1090 调整closeSync方法,紧接着writeSync,readSync,防止打开的文件没有正确关闭
Signed-off-by: madixin <madixin@huawei.com>
2024-12-03 17:21:18 +08:00
madixin 303ff79be1 更新issue bug的模版版本和PR模版
Signed-off-by: madixin <madixin@huawei.com>
2024-12-01 19:58:19 +08:00
openharmony_ci 51e4675957
!437 增加仓库默认issue模板,填写正确imageknife版本
Merge pull request !437 from Madi/master
2024-11-30 13:02:57 +00:00
madixin 47edcfed3e 提交imageknife issue模版,选定版本
Signed-off-by: madixin <madixin@huawei.com>
2024-11-30 20:37:36 +08:00
zgf e475dcd30a 修改ImageKnifeComponent组件pixel Map初始值以及修复多张错误图不显示
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-11-29 18:26:46 +08:00
openharmony_ci e98984c56a
!435 主图和错误图并发加载时,以及主图加载失败后立即加载错误图,可能会导致短时间内并发数超过maxRequests,及时减少并发
Merge pull request !435 from Madi/master
2024-11-27 11:32:27 +00:00
madixin fba280904e 主图和错误图并发加载时,以及主图加载失败后立即加载错误图,可能会导致短时间内并发数超过maxRequests,故在dispatchNextJob减少响应的并发
Signed-off-by: madixin <madixin@huawei.com>
2024-11-27 15:39:04 +08:00
Madixin 8aebc58a53 更新默认OpenHarmony工程
Signed-off-by: Madixin <madixin@huawei.com>
2024-11-27 06:00:00 +00:00
openharmony_ci 9ff70d9c78
!433 ImageFit.Auto 组件宽度更改后自动支持自适应高度
Merge pull request !433 from Madi/master
2024-11-27 01:13:11 +00:00
madixin e29c659e89 1. ImageFit.Auto 组件宽度更改后自动支持自适应高度,并补充样例。
2.修复onLoadStart会调用2次的bug

Signed-off-by: madixin <madixin@huawei.com>
2024-11-25 17:45:55 +08:00
openharmony_ci 83b42f36b0
!432 完善日志,补充组件id信息
Merge pull request !432 from Madi/master
2024-11-25 02:40:14 +00:00
madixin 74bc24d61d 完善日志,补充组件id信息
Signed-off-by: madixin <madixin@huawei.com>
2024-11-25 09:54:50 +08:00
zgf dac7731794 支持ico格式图片、修复错误回调无法执行reload和新增降采样默认值
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-11-22 16:51:22 +08:00
zgf 1ae2ce8d92 ImageKnifeAnimatorComponent补充圆角功能
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-11-15 15:37:10 +08:00
openharmony_ci 65c39faf8a
!429 taskpool执行异常时,回调onLoadFailed
Merge pull request !429 from Madi/master
2024-11-15 06:03:32 +00:00
madixin 328257bb96 1.taskpool执行异常时,回调onLoadFailed
2.调整imageKnifeData为public作用域,以及命名

Signed-off-by: madixin <madixin@huawei.com>
2024-11-15 12:17:52 +08:00
openharmony_ci a45fb6af7d
!428 完善错误日志的打印
Merge pull request !428 from Madi/master
2024-11-15 03:03:58 +00:00
madixin 5296bf7a1d 1.完善错误日志
2.修复部分imagesource没有release的问题

Signed-off-by: madixin <madixin@huawei.com>
2024-11-15 10:05:23 +08:00
openharmony_ci 30c327747b
!427 修复无法解析其他module的Resource格式图片
Merge pull request !427 from zgf/master
2024-11-12 09:44:47 +00:00
zgf 73bc96e524 修复无法解析其他module的Resource格式图片
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-11-12 17:05:05 +08:00
openharmony_ci 32da743bcc
!426 判断和处理imageSource.getImageInfo为空的场景,返回错误信息
Merge pull request !426 from Madi/master
2024-11-12 01:45:34 +00:00
madixin 630b0df448 判断和处理imageSource.getImageInfo为空的场景,返回错误信息
Signed-off-by: madixin <madixin@huawei.com>
2024-11-10 08:06:57 +08:00
zgf f552f57713 修改CHANGELOG版本号
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-11-08 15:12:39 +08:00
openharmony_ci 3dd622e4e2
!424 3.x分支代码合并master分支
Merge pull request !424 from zgf/master
2024-11-08 06:10:07 +00:00
zgf 3423f4cd5d 3.x分支代码合并到master分支
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-11-08 11:02:58 +08:00
zgf 0e0f1a96c2 Merge remote-tracking branch 'origin/3.x'
# Conflicts:
#	CHANGELOG.md
#	README.md
#	README_zh.md
#	entry/src/main/ets/common/CustomEngineKeyImpl.ets
#	entry/src/main/ets/pages/DownSamplePage.ets
#	entry/src/main/ets/pages/ImageAnimatorPage.ets
#	entry/src/main/ets/pages/Index.ets
#	entry/src/main/ets/pages/LoadStatePage.ets
#	entry/src/main/ets/pages/ObjectFitPage.ets
#	entry/src/main/ets/pages/SingleImage.ets
#	entry/src/main/ets/pages/TestCacheDataPage.ets
#	entry/src/main/ets/pages/TestChangeColorPage.ets
#	entry/src/main/ets/pages/TestLoadCancelListenerPage.ets
#	entry/src/main/ets/pages/TestSetCustomImagePage.ets
#	entry/src/main/ets/pages/TestTaskResourcePage.ets
#	entry/src/main/ets/pages/TestWriteCacheStage.ets
#	entry/src/main/ets/pages/UserPage.ets
#	entry/src/main/resources/base/element/string.json
#	entry/src/main/resources/base/profile/main_pages.json
#	entry/src/main/resources/zh_CN/element/string.json
#	entry/src/ohosTest/ets/test/List.test.ets
#	entry/src/ohosTest/ets/test/SamplingTest.test.ets
#	entry/src/ohosTest/ets/test/imageFormatAndSize.test.ets
#	library/oh-package.json5
#	library/src/main/ets/ImageKnife.ets
#	library/src/main/ets/ImageKnifeDispatcher.ets
#	library/src/main/ets/ImageKnifeLoader.ets
#	library/src/main/ets/components/ImageKnifeAnimatorComponent.ets
#	library/src/main/ets/components/ImageKnifeComponent.ets
#	library/src/main/ets/downsampling/BaseDownsampling.ets
#	library/src/main/ets/downsampling/DownsampleStartegy.ets
#	library/src/main/ets/downsampling/Downsampler.ets
#	library/src/main/ets/key/DefaultEngineKey.ets
#	library/src/main/ets/model/ImageKnifeData.ets
#	library/src/main/ets/model/ImageKnifeOption.ets
#	library/src/main/ets/model/ImageKnifeRequest.ets
#	sharedlibrary/src/main/ets/pages/Index.ets
2024-11-06 18:40:38 +08:00
madixin 8adc342444 补充:解决单个图片解码后内存占用超过内存缓存最大值,导致无法显示图片的问题
Signed-off-by: madixin <madixin@huawei.com>
2024-11-06 16:52:09 +08:00
madixin 95ffcb9e74 解决单个图片解码后内存占用超过内存缓存最大值,导致无法显示图片的问题
Signed-off-by: madixin <madixin@huawei.com>
2024-11-06 15:50:15 +08:00
openharmony_ci a7fa5de2de
!405 ImageKnife降采样适配3.x
Merge pull request !405 from 田双明/master
2024-10-23 01:53:00 +00:00
田双明 346c704193
update entry/src/main/ets/pages/Index.ets.
Signed-off-by: 田双明 <tianshuangming@h-partners.com>
2024-10-23 01:12:36 +00:00
田双明 e857a41129 Merge branch 'master' of gitee.com:openharmony-tpc/ImageKnife into master
Signed-off-by: 田双明 <tianshuangming@h-partners.com>
2024-10-22 10:43:49 +00:00
openharmony_ci da4c159d44
!404 增加onLoadCancel回调的demo、增加设置图片颜色变换demo、增加从缓存获取图片格式大小的xts等
Merge pull request !404 from tyBrave/master
2024-10-21 01:28:42 +00:00
tsm 29e0df8d2b 降采样功demo文字国际化
Signed-off-by: tsm <tianshuangming@h-partners.com>
2024-10-18 18:16:42 +08:00
tsm 5fa004afc0 降采样功能
Signed-off-by: tsm <tianshuangming@h-partners.com>
2024-10-18 15:31:38 +08:00
tyBrave d82d85ea19 去掉多余的日志信息
Signed-off-by: tyBrave <tianyong21@h-partners.com>

TestCacheDataPage 文件添加版权头

Signed-off-by: tyBrave <tianyong21@h-partners.com>

资源国际化

Signed-off-by: tyBrave <tianyong21@h-partners.com>

add TIPS text dec

Signed-off-by: tyBrave <tianyong21@h-partners.com>

update code because of checkcode

Signed-off-by: tyBrave <tianyong21@h-partners.com>

update code because of use image url

Signed-off-by: tyBrave <tianyong21@h-partners.com>
2024-10-17 17:39:50 +08:00
tyBrave 8e55d336f9 修改获取缓存中的图片格式大小的单元测试
Signed-off-by: tyBrave <tianyong21@h-partners.com>
2024-10-16 17:17:02 +08:00
tyBrave e31c592ee4 修改onLoadCancel回调demo及其缓存中获取图片的格式大小信息
Signed-off-by: tyBrave <tianyong21@h-partners.com>
2024-10-16 15:56:42 +08:00
tyBrave 1027fc0304 add xts test get size and format in image of callback
Signed-off-by: tyBrave <tianyong21@h-partners.com>
2024-10-16 10:57:36 +08:00
tyBrave ec651e91df add test cancel callback demo
Signed-off-by: tyBrave <tianyong21@h-partners.com>
2024-10-16 10:56:06 +08:00
tyBrave 7b9da8d9fa add change color of image in lib
Signed-off-by: tyBrave <tianyong21@h-partners.com>
2024-10-16 10:40:22 +08:00
tyBrave 2a81312ed5 add get cache data
Signed-off-by: tyBrave <tianyong21@h-partners.com>
2024-10-12 09:57:11 +08:00
openharmony_ci 78770a430c
!398 中文图片链接替换
Merge pull request !398 from zgf/master
2024-10-10 01:24:31 +00:00
zgf 2201fec90c 中文图片链接替换
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-10-09 15:36:07 +08:00
openharmony_ci f7cef581b1
!388 适配国际化
Merge pull request !388 from hexagon1337/master
2024-09-25 03:40:24 +00:00
hexagon1337 ddb8fc89be 修改README_zh屏蔽词
Signed-off-by: hexagon1337 <liuyaoming3@h-partners.com>
2024-09-25 11:03:44 +08:00
hexagon1337 858e28c3a2 补充imagetransformation和removecache页面的国际化
Signed-off-by: hexagon1337 <liuyaoming3@h-partners.com>
2024-09-25 10:34:33 +08:00
hexagon1337 565938c98a 补充imagetransformation和removecache页面的国际化
Signed-off-by: hexagon1337 <liuyaoming3@h-partners.com>
2024-09-23 12:14:04 +08:00
hexagon1337 f1008e869e 适配国际化
Signed-off-by: hexagon1337 <liuyaoming3@h-partners.com>
2024-09-21 18:19:06 +08:00
openharmony_ci afde885ae1
!385 调整内部包的结构
Merge pull request !385 from Madi/master
2024-09-06 09:04:17 +00:00
Madixin 9f98c174f2 调整内部包的结构
Signed-off-by: Madixin <madixin@huawei.com>
2024-09-06 16:39:42 +08:00
openharmony_ci b491bc8dae
!384 重构代码:抽取ImageKnifeDispatcher子线程requestJob相关代码到ImageKnifeLoader中,降低函数复杂度
Merge pull request !384 from Madi/master
2024-09-06 08:19:22 +00:00
Madixin 6cbe5eadc5 重构代码:抽取ImageKnifeDispatcher子线程requestJob相关代码到ImageKnifeLoader中,降低函数复杂度
Signed-off-by: Madixin <madixin@huawei.com>
2024-09-06 15:15:35 +08:00
zgf 0dd26b9e75 Revert "降采样"
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-09-06 11:05:46 +08:00
openharmony_ci 233b24032e
!382 修改网络请求超时设置
Merge pull request !382 from zgf/master
2024-09-05 10:35:52 +00:00
zgf d78ba39efe 修改网络请求超时设置
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-09-05 18:08:43 +08:00
zgf dcdc17f51f 修改网络请求超时设置
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-09-05 18:04:21 +08:00
openharmony_ci 483803a302
!380 修改file格式图片同步close和PixelMap默认不可编辑
Merge pull request !380 from zgf/master
2024-09-02 08:38:03 +00:00
zgf 2cbce5790b 修改file格式图片同步close和PixelMap默认不可编辑
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-09-02 15:58:32 +08:00
openharmony_ci f9e83786a8
!379 imageKnife降采样
Merge pull request !379 from 田双明/master
2024-09-02 07:43:33 +00:00
tsm f415bb7aa1 降采样
Signed-off-by: tsm <tianshuangming@h-partners.com>
2024-09-02 11:44:53 +08:00
openharmony_ci 55fcfe6021
!375 ImageknifeComponents代码整理
Merge pull request !375 from Madi/master
2024-08-30 06:26:33 +00:00
Madixin 587d35f085 优化整理imageknifecomponent代码
Signed-off-by: Madixin <madixin@huawei.com>
2024-08-30 11:56:11 +08:00
openharmony_ci b3114dd47b
!371 新增Task任务报错10200006样例
Merge pull request !371 from zgf/master
2024-08-28 09:26:58 +00:00
zgf 0c8a777c82 新增Task任务报错10200006样例
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-28 17:00:43 +08:00
zgf ddbff75a7d 新增Task任务报错10200006样例
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-28 16:27:47 +08:00
zgf 2911708267 子线程本地Resource参数类型转换成number
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-27 11:30:08 +00:00
zgf 7252a2fe05 子线程本地Resource参数类型转换成number
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-27 16:48:48 +08:00
Madixin 47c178fe1f 修改使用hilog记录日志,默认打开debug级别的日志,增加可维侧性
Signed-off-by: Madixin <madixin@huawei.com>
2024-08-27 16:37:47 +08:00
openharmony_ci 6612dea1d5
!368 修改webp图片区分动静图和错误图加载完未发起排队队列中的请求
Merge pull request !368 from zgf/master
2024-08-23 09:45:04 +00:00
zgf fae5b3c7fd 修改webp图片区分动静图和错误图加载完未发起排队队列中的请求
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-23 17:28:50 +08:00
Madi ad18fe60b2
!366 修复宽高不等svg图片显示有毛边
Merge pull request !366 from zgf/master
2024-08-19 03:47:42 +00:00
zgf 906337cc62 修复宽高不等svg图片显示有毛边
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-19 11:01:32 +08:00
openharmony_ci fa59e2b9ac
!365 修改README待实现特性
Merge pull request !365 from zgf/master
2024-08-15 06:56:52 +00:00
zgf bebbc865f7 修改README待实现特性
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-15 14:44:38 +08:00
zgf 48b425109a 控制动图组件新增事件和文件缓存数量最大值修改
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-14 17:29:58 +08:00
openharmony_ci bea89c5c77
!361 新增动画显示首帧和第一帧样例
Merge pull request !361 from zgf/master
2024-08-14 08:18:04 +00:00
zgf 4898145979 新增动画显示首帧和第一帧样例
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-09 16:07:33 +08:00
openharmony_ci dd0c64fb91
!359 修复xts报错:ImageKnifeOption用法变更
Merge pull request !359 from zgf/master
2024-08-07 10:18:13 +00:00
zgf 5c1b0578b6 修复xts报错:ImageKnifeOption用法变更
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-07 18:05:26 +08:00
zgf cdfb4fafa9 修复xts报错:ImageKnifeOption用法变更
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-07 17:42:07 +08:00
openharmony_ci 370cc03b96
!357 适配ComponentV2装饰器
Merge pull request !357 from zgf/master
2024-08-06 07:29:26 +00:00
zgf 1b05a2aa2d ComponentV2装饰器适配
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-06 11:37:43 +08:00
zgf d7a14b8833 修复webp静态图无法设置图形变换
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-05 10:07:37 +08:00
zgf 69f951b290 修复动图控制组件初始值失效、网络请求成功code以及文件缓存可选初始化
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-08-02 16:25:41 +08:00
wangyingjun01 f497f32c48 ImageKnife3.x分支合并到master分支
Signed-off-by: wangyingjun01 <wangyingjun5@h-partners.com>
2024-07-31 11:41:01 +08:00
wangyingjun01 7fac49e442 ImageKnife3.x分支合并到master分支
Signed-off-by: wangyingjun01 <wangyingjun5@h-partners.com>
2024-07-31 11:23:37 +08:00
wangyingjun01 45b1fbc591 ImageKnife3.x分支合并到master分支
Signed-off-by: wangyingjun01 <wangyingjun5@h-partners.com>
2024-07-31 11:06:41 +08:00
wangyingjun01 7d39ff5129 Merge remote-tracking branch 'origin/3.x'
# Conflicts:
#	CHANGELOG.md
#	OAT.xml
#	README.md
#	build-profile.json5
#	entry/oh-package.json5
#	entry/src/main/ets/entryability/EntryAbility.ets
#	entry/src/main/ets/pages/UserPage.ets
#	entry/src/main/ets/pages/dataShareUriLoadPage.ets
#	entry/src/main/ets/pages/imageknifeTestCaseIndex.ets
#	entry/src/main/ets/pages/index.ets
#	entry/src/main/ets/pages/testImageKnifeHttpRequestHeader.ets
#	entry/src/main/ets/pages/testImageKnifeOptionChangedPage5.ets
#	entry/src/main/ets/pages/testManyNetImageLoadWithPage2.ets
#	entry/src/main/module.json5
#	entry/src/main/resources/base/element/string.json
#	entry/src/main/resources/base/profile/main_pages.json
#	entry/src/ohosTest/ets/test/DefaultJobQueueTest.test.ets
#	entry/src/ohosTest/ets/test/List.test.ets
#	entry/src/ohosTest/ets/test/diskLruCache.test.ets
#	entry/src/ohosTest/ets/test/imageknife.test.ets
#	entry/src/ohosTest/ets/test/requestoption.test.ets
#	entry/src/ohosTest/module.json5
#	gpu_transform/CHANGELOG.md
#	gpu_transform/oh-package.json5
#	library/index.ets
#	library/oh-package.json5
#	library/src/main/ets/SendableData.ets
#	library/src/main/ets/components/cache/DiskCacheEntry.ets
#	library/src/main/ets/components/cache/DiskLruCache.ets
#	library/src/main/ets/components/cache/FileUtils.ets
#	library/src/main/ets/components/cache/LruCache.ets
#	library/src/main/ets/components/imageknife/ImageKnife.ets
#	library/src/main/ets/components/imageknife/ImageKnifeComponent.ets
#	library/src/main/ets/components/imageknife/ImageKnifeData.ets
#	library/src/main/ets/components/imageknife/ImageKnifeDrawFactory.ets
#	library/src/main/ets/components/imageknife/ImageKnifeOption.ets
#	library/src/main/ets/components/imageknife/RequestOption.ets
#	library/src/main/ets/components/imageknife/TaskParams.ets
#	library/src/main/ets/components/imageknife/constants/Constants.ets
#	library/src/main/ets/components/imageknife/holder/ErrorHolderManager.ets
#	library/src/main/ets/components/imageknife/holder/PlaceHolderManager.ets
#	library/src/main/ets/components/imageknife/holder/RetryHolderManager.ets
#	library/src/main/ets/components/imageknife/interface/IParseImage.ets
#	library/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets
#	library/src/main/ets/components/imageknife/networkmanage/HttpDownloadClient.ets
#	library/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets
#	library/src/main/ets/components/imageknife/networkmanage/LoadDataShareFileClient.ets
#	library/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets
#	library/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets
#	library/src/main/ets/components/imageknife/requestmanage/MemoryCacheProxy.ets
#	library/src/main/ets/components/imageknife/requestmanage/RequestManager.ets
#	library/src/main/ets/components/imageknife/resourcemanage/ParseResClientBase64.ets
#	library/src/main/ets/components/imageknife/transform/TransformUtils.ets
#	library/src/main/ets/components/imageknife/utils/ParseImageUtil.ets
#	library/src/main/ets/components/imageknife/utils/gif/GIFFrame.ts
#	library/src/main/ets/components/imageknife/utils/gif/GIFParseImpl.ets
#	library/src/main/ets/components/imageknife/utils/gif/IParseGif.ets
#	library/src/main/ets/components/imageknife/utils/svg/SVGParseImpl.ets
#	library/src/main/ets/downsampling/BaseDownsampling.ets
#	library/src/main/ets/downsampling/DownsampleStartegy.ets
#	library/src/main/ets/downsampling/Downsampler.ets
#	library/src/main/ets/networkmanage/CustomDataFetchClient.ets
#	library/src/main/ets/networkmanage/DataFetchResult.ets
#	library/src/main/ets/networkmanage/RequestData.ets
#	library/src/main/ets/utils/CalculatePixelUtils.ets
#	library/src/main/ets/utils/DefaultJobQueue.ets
#	library/src/main/ets/utils/IJobQueue.ets
#	library/src/main/ets/utils/MResource.ets
#	library/src/main/ets/utils/base/AsyncLock.ts
#	oh-package.json5
#	sharedlibrary/src/main/ets/Index.ets
#	sharedlibrary/src/main/ets/pages/Index.ets
#	sharedlibrary/src/test/List.test.ets
2024-07-31 11:02:46 +08:00
openharmony_ci 8f41c6d13e
!345 去除READ_IMAGEVIDEO和WRITE_IMAGEVIDEO权限以及修复部分heif图无法解码
Merge pull request !345 from zgf/master
2024-07-24 02:36:16 +00:00
zgf 7101a26267 去除READ_IMAGEVIDEO和WRITE_IMAGEVIDEO权限以及修复部分heif图无法解码
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-07-24 10:01:12 +08:00
zgf 1dee5f345b 去除READ_IMAGEVIDEO和WRITE_IMAGEVIDEO权限以及修复部分heif图无法解码
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-07-23 16:34:16 +08:00
zgf d2bd8f75fc 修改下采样和hsp本地图样例
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-07-22 14:41:15 +08:00
openharmony_ci 659d28dd37
!340 加载优先级Priority类型改为taskpool.Priority类型
Merge pull request !340 from zgf/master
2024-07-18 06:18:40 +00:00
zgf 136c3e509a 加载优先级Priority类型改为taskpool.Priority类型
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-07-18 10:55:44 +08:00
chongtiantian e48600fe7f 修改uuid的生成方式,使用资源loadSrc,宽高以及转换效果的拼接字符串作为入参,修复同资源图形转换错乱的问题。
Signed-off-by: chongtiantian <chongtiantian1@h-partners.com>
2024-07-01 16:07:57 +08:00
zgf db1ccdc604 修复file://格式图片无法显示以及媒体展示图片样例改用photoAccessHelper接口获取本地图片资源
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-06-27 06:44:44 +00:00
openharmony_ci c51e0eca77
!318 X86模拟器配置
Merge pull request !318 from yaofangyong/master
2024-06-27 06:34:28 +00:00
yaofangyong d873733517 x86
Signed-off-by: yaofangyong <2385605052@qq.com>
2024-06-25 19:34:37 +08:00
Madi a3026e13e8
!312 修改xts用例setCache和getMapCache
Merge pull request !312 from zgf/master
2024-06-19 13:58:26 +00:00
zgf 334b042086 修改xts用例setCache和getMapCache
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-06-19 21:49:08 +08:00
Madi 7c0fc08d9d
!311 增加gif图duration的默认值,以及默认播放次数
Merge pull request !311 from zgf/master
2024-06-19 11:37:42 +00:00
zgf f171b64e95 增加gif图duration的默认值,以及默认播放次数
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-06-19 19:24:51 +08:00
zgf 549658e321 修改CHANGELOG
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-06-19 19:00:09 +08:00
zgf 7b4f496150 1.修复复用场景下从内存获取图片后又清空了画布导致图片不显示,
2.svg解码单位改为px
3.获取组件宽高改用onSizeChange
4.修复复用占位图不显示

Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-06-14 15:03:00 +08:00
Madi d4a87f0c5e
!304 修复多线程图片加载出现空白问题
Merge pull request !304 from baofeng/master
2024-06-13 06:20:16 +00:00
baofeng f7ce1945b8 修复多线程图片加载出现空白问题
Signed-off-by: baofeng <baofeng6@h-partners.com>
2024-06-12 18:37:14 +08:00
openharmony_ci ee980fe094
!302 imageKnife降采样案例修改
Merge pull request !302 from 田双明/master
2024-06-11 08:20:16 +00:00
tsm fe80ce7a34 降采样案例修改
Signed-off-by: tsm <2418639820@qq.com>
2024-06-11 15:19:54 +08:00
sunao d6e3ebc253 修改门禁编译问题 修改点如下:修改src/main/cpp/boundscheck/CMakeLists.txt文件中的内容,修改src/main/cpp/util/DebugLog.h文件中hilog的大小写
Signed-off-by: sunao <sunao19@h-partners.com>
2024-06-07 17:18:10 +08:00
openharmony_ci 804049b36b
!292 修复preLoad接口失效
Merge pull request !292 from zgf/master
2024-06-03 07:52:15 +00:00
zgf bafd1a568f 修复preLoad接口失效
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-06-03 15:02:43 +08:00
openharmony_ci f7bb2f1999
!287 ImageKnife提供图片加载成功/失败的事件README补充
Merge pull request !287 from 任伟x/master
2024-05-27 09:31:50 +00:00
任伟x b777d40426 ImageKnife提供图片加载成功失败的事件README补充
Signed-off-by: 任伟x <renwei79@h-partners.com>
2024-05-27 16:58:59 +08:00
openharmony_ci 0d27e7a8cc
!281 修改readme文档
Merge pull request !281 from zhanghuan633/master
2024-05-24 08:43:48 +00:00
张欢 ce8b3cbb7a 修改readme文档
Signed-off-by: 张欢 <zhanghuan165@h-partners.com>
2024-05-24 16:19:49 +08:00
openharmony_ci 668bf251fd
!276 ImageKnife提供清理缓存能力
Merge pull request !276 from 任伟x/master
2024-05-23 06:56:58 +00:00
任伟x ee6e0acef6 ImageKnife提供清理缓存能力
Signed-off-by: 任伟x <renwei79@h-partners.com>
2024-05-22 17:28:30 +08:00
openharmony_ci 3ecc586559
!268 ImageKnife支持多种组合变换
Merge pull request !268 from zhanghanyong/master
2024-05-22 09:02:14 +00:00
zhang_hanyong 1e94a03d5b 支持多种组合变换
Signed-off-by: zhang_hanyong <zhang_hanyong@h-partners.com>
2024-05-21 11:02:53 +08:00
张欢 6d43923279 修复懒加载在多次点击出现卡死的问题
Signed-off-by: 张欢 <zhanghuan165@h-partners.com>
2024-05-20 15:25:19 +08:00
openharmony_ci 83e76dcc08
!260 ImageKnife提供图片加载成功/失败的事件
Merge pull request !260 from 任伟x/master
2024-05-16 02:15:01 +00:00
任伟x 275ee6bc0a ImageKnife提供图片加载成功失败的事件
Signed-off-by: 任伟x <renwei79@h-partners.com>
2024-05-15 16:55:29 +08:00
zgf 39f97e0a41 修复错误图绘制完后变成占位图
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-05-11 10:01:09 +08:00
openharmony_ci b74f6e68ec
!253 更新版本信息
Merge pull request !253 from 田双明/master
2024-05-10 01:18:28 +00:00
sijainguo 2731a7f8cc 版本信息修改
Signed-off-by: sijainguo <sijianguo5@h-partners.com>
2024-05-09 11:27:55 +08:00
openharmony_ci 8fbc60f907
!202 使用安全函数memset_s替代memset,memcpy_s替代memcpy
Merge pull request !202 from 刘海康/master
2024-05-08 00:35:51 +00:00
openharmony_ci 937f448fb7
!247 imageKnife降采样
Merge pull request !247 from 田双明/master
2024-05-07 03:48:56 +00:00
tsm d6a3f2df0e imageKnife 下采样
Signed-off-by: tsm <2418639820@qq.com>
2024-05-07 11:01:14 +08:00
openharmony_ci 49502f1143
!240 修改header图的存储标志位
Merge pull request !240 from taxuexunji/master
2024-05-06 03:02:10 +00:00
2206069183@qq.com 4f549b2f81 修改header图的存储标志位
Signed-off-by: 2206069183@qq.com <2206069183@qq.com>
2024-05-06 10:32:19 +08:00
openharmony_ci a27ca5b4c7
!234 ImageKnife组件修改配置字段srcEntrance替换为srcEntry
Merge pull request !234 from xiagengwen/master
2024-05-05 02:38:12 +00:00
Madi ac409d4ac9
!237 修复通过磁盘链接加载图片无法显示
Merge pull request !237 from zgf/master
2024-05-04 10:35:13 +00:00
Madi 98145712fa
!235 修复占位图、错误图、重试图从内存获取之后进入子线程导致内存泄露
Merge pull request !235 from zgf/master
2024-05-04 10:34:42 +00:00
zgf 08ba6360c7 修复通过磁盘链接加载图片无法显示
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-05-04 17:53:55 +08:00
zgf a6bbe8341a 修复占位图、错误图、重试图从内存获取之后进入子线程导致内存泄露
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
2024-05-04 17:09:21 +08:00
xiagengwen ceb5fe7010 ImageKnife组件修改配置字段srcEntrance替换为srcEntry
Signed-off-by: xiagengwen <xiagengwen1@h-partners.com>
2024-05-04 15:22:45 +08:00
openharmony_ci 4ee4760aed
!229 ImageKnife控制可视化区域图片
Merge pull request !229 from 17792399693/master
2024-04-30 02:50:06 +00:00
chongtiantian f54b5045c7 ImageKnife控制可视化区域图片
Signed-off-by: chongtiantian <chongtiantian1@h-partners.com>
2024-04-29 17:58:07 +08:00
openharmony_ci d5faaf74d2
!226 ImageKnife支持heic图片修改demo
Merge pull request !226 from taxuexunji/master
2024-04-29 06:59:54 +00:00
2206069183@qq.com 240a2658a7 修改heic图片展示demo
Signed-off-by: 2206069183@qq.com <2206069183@qq.com>
2024-04-29 10:19:22 +08:00
openharmony_ci bb57dc0f51
!223 【ImageKnife】加载图片支持自定义网络栈补充XTS用例以及优化按钮重复点击问题
Merge pull request !223 from zhanghanyong/master
2024-04-29 01:41:40 +00:00
zhang_hanyong b185bf1f18 ImageKnife加载图片支持自定义网络栈补充XTS用例以及优化按钮重复点击问题
Signed-off-by: zhang_hanyong <zhang_hanyong@h-partners.com>
2024-04-28 18:12:06 +08:00
liuhaikang 46b75226cf 使用安全函数memset_s替代memset,memcpy_s替代memcpy
Signed-off-by: liuhaikang <liuhaikang@huawei-partners.com>
2024-04-28 10:21:54 +08:00
openharmony_ci 97a5ca1ec2
!221 新增自定义key获取已缓存的图片单元测试
Merge pull request !221 from 任伟x/master
2024-04-25 02:10:08 +00:00
任伟x 68257fb666 Merge branch 'master' of gitee.com:openharmony-tpc/ImageKnife into master
Signed-off-by: 任伟x <renwei79@h-partners.com>
2024-04-24 08:17:28 +00:00
任伟x 06ab9131ed ImageKnife支持根据自定义key获取已缓存的图片-新增xts
Signed-off-by: 任伟x <renwei79@h-partners.com>
2024-04-24 16:05:48 +08:00
openharmony_ci befcd414ac
!219 ImageKnife控制重要图片请求加载优先级
Merge pull request !219 from 17792399693/master
2024-04-24 06:20:29 +00:00
chongtiantian 87f3dab4fa ImageKnife控制重要图片请求加载优先级
Signed-off-by: chongtiantian <chongtiantian1@h-partners.com>
2024-04-24 10:05:23 +08:00
openharmony_ci 32b29801bd
!217 适配复用场景触发懒加载onDataReloaded
Merge pull request !217 from zgf/master
2024-04-24 01:48:21 +00:00
zenggaofeng 9bc31bb138 适配复用场景触发懒加载onDataReloaded
Signed-off-by: zenggaofeng <zenggaofeng2@h-partners.com>
2024-04-23 20:32:37 +08:00
chenchen2019710 ec861fb89f 修改ImageKnife跳过网络,点击默认,图片没有传入宽高,无显示bug
Signed-off-by: chenchen2019710 <1173940354@qq.com>
2024-04-23 17:48:45 +08:00
openharmony_ci 5fdc066846
!215 【ImageKnife】加载图片支持自定义网络栈和图片加载组件
Merge pull request !215 from zhanghanyong/master
2024-04-23 08:26:42 +00:00
zhang_hanyong 9ff235a856 ImageKnife加载图片支持自定义网络栈和图片加载组件
Signed-off-by: zhang_hanyong <zhang_hanyong@h-partners.com>
2024-04-23 16:00:20 +08:00
openharmony_ci 906bfe55f1
!211 ImageKnife支持根据自定义key获取已缓存的图片
Merge pull request !211 from 任伟x/master
2024-04-23 03:45:27 +00:00
任伟x 6ae9982ec6 ImageKnife支持根据自定义key获取已缓存的图片
Signed-off-by: 任伟x <renwei79@h-partners.com>
2024-04-23 10:37:44 +08:00
openharmony_ci 83075cc204
!204 【ImageKnife】支持加载的网络gif图设置圆角
Merge pull request !204 from zhanghanyong/master
2024-04-20 07:03:51 +00:00
zhanghanyong 160d08d336 drawLifeCycle支持gif图
Signed-off-by: zhanghanyong <zhanghanyong@h-partners.com>
2024-04-19 17:35:00 +08:00
openharmony_ci 3e4f204027
!195 imageKnife支持heic图片(修改heic的demo,独立页面)
Merge pull request !195 from 袁莉/master
2024-04-19 09:02:31 +00:00
18829029633 43daaec752 imageKnife支持heic展示demo页面独立展示
Signed-off-by: 18829029633 <18829029633@163.com>
2024-04-19 16:09:25 +08:00
openharmony_ci 90ff9edf1d
!200 修改全局请求头覆盖request请求头
Merge pull request !200 from taxuexunji/master
2024-04-19 07:24:49 +00:00
2206069183@qq.com d4b537bd53 修改全局请求头覆盖request请求头
Signed-off-by: 2206069183@qq.com <2206069183@qq.com>
2024-04-19 14:50:32 +08:00
openharmony_ci f20aed06a5
!162 修复自定义DataFetch接口不生效问题
Merge pull request !162 from baofeng/master
2024-04-19 03:41:34 +00:00
baofeng f84b793eca [Issues: #I9DWXC]修复自定义DataFetch接口不生效问题
Signed-off-by: baofeng <baofeng6@h-partners.com>
2024-04-19 10:44:38 +08:00
zenggaofeng 95a2526408 OpenSource、OAT版权头修改
Signed-off-by: zenggaofeng <zenggaofeng2@h-partners.com>
2024-04-18 01:57:47 +00:00
Madi 2c4257f3f6
!197 gpu_transform安全编译开启Strip和Ftrapv
Merge pull request !197 from zhanghuan633/master
2024-04-17 12:11:42 +00:00
张欢 2fad9a284d gpu_transform安全编译开启Strip和Ftrapv
Signed-off-by: 张欢 <zhanghuan165@h-partners.com>
2024-04-17 17:48:04 +08:00
openharmony_ci a2a8700eb4
!194 新增gif图暂停播放恢复播放能力
Merge pull request !194 from zhanghanyong/master
2024-04-17 07:56:34 +00:00
zhang_hanyong db71776e62 新增gif图暂停播放恢复播放能力
Signed-off-by: zhang_hanyong <zhanghanyong@h-partners.com>
2024-04-16 19:38:16 +08:00
openharmony_ci ab7dd919f3
!182 imageKnife支持heic图片
Merge pull request !182 from 袁莉/master
2024-04-12 02:45:04 +00:00
18829029633 0a4063b953 imageKnife支持heic图片展示 2024-04-11 18:00:27 +08:00
Madi 1996127cb6
!181 webp格式图片,实现首页轮盘跳动动画
Merge pull request !181 from LuQian-KUN/master
2024-04-11 09:26:52 +00:00
LuQian-KUN 997f5faf0d webp格式图片,实现首页轮盘跳动动画
Signed-off-by: 'LuQian-KUN' <gaopengcheng11@h-partners.com>
2024-04-11 15:49:39 +08:00
openharmony_ci 80550c27a6
!177 修改ImageKnife跳过网络,从内存中获取图片 cacheType参数未使用bug
Merge pull request !177 from 面条侠/master
2024-04-10 09:28:53 +00:00
‘面条侠’ 0a3aac2b77 修改ImageKnife跳过网络,从内存中获取图片 cacheType参数未使用bug
Signed-off-by: ‘面条侠’ <‘wangxinxin51@h-partners.com’>
2024-04-10 17:01:17 +08:00
‘面条侠’ db4e10c580 修改ImageKnife跳过网络,从内存中获取图片 cacheType参数未使用bug
Signed-off-by: ‘面条侠’ <‘wangxinxin51@h-partners.com’>
2024-04-10 16:28:30 +08:00
‘面条侠’ b5aef4c48c 修改ImageKnife跳过网络,从内存中获取图片 cacheType参数未使用bug
Signed-off-by: ‘面条侠’ <‘wangxinxin51@h-partners.com’>
2024-04-10 16:22:07 +08:00
openharmony_ci 99e251c6bd
!172 排查性能优化点uuid,定时器以及磁盘读写
Merge pull request !172 from zgf/master
2024-04-09 11:12:41 +00:00
openharmony_ci b7eae6eefb
!163 新增gif播放次数
Merge pull request !163 from zgf/master
2024-04-09 06:57:49 +00:00
zenggaofeng ccb69591df 排查性能优化点uuid,定时器以及磁盘读写
Signed-off-by: zenggaofeng <zenggaofeng2@h-partners.com>
2024-04-09 14:28:27 +08:00
openharmony_ci 15b77e25c4
!169 跳过网络,从内存中取图片,接口说明文档
Merge pull request !169 from 面条侠/master
2024-04-08 06:36:33 +00:00
‘面条侠’ 0c239e1118 跳过网络,从内存中取图片,接口说明文档
Signed-off-by: ‘面条侠’ <‘wangxinxin51@h-partners.com’>
2024-04-08 10:59:22 +08:00
面条侠 b64661b9f9
update README.md.
Signed-off-by: 面条侠 <wangxinxin51@h-partners.com>
2024-04-08 02:57:50 +00:00
zenggaofeng f57fa66fab 新增gif播放次数
Signed-off-by: zenggaofeng <zenggaofeng2@h-partners.com>
2024-04-07 10:44:47 +08:00
longfeng 4d5728dc3a 支持x86编译
Signed-off-by: longfeng <longfeng20@huawei.com>
2024-04-01 16:18:47 +08:00
148 changed files with 3273 additions and 4707 deletions

View File

@ -0,0 +1,13 @@
### 该问题是怎么引起的?
### 重现步骤
### 报错信息

View File

@ -0,0 +1,47 @@
name: 缺陷反馈|Bug
description: 当您发现了一个缺陷,需要向社区反馈时,请使用此模板。
title: "[Bug]: "
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
感谢对OpenHarmony社区的支持与关注欢迎反馈缺陷。
- type: textarea
attributes:
label: 发生了什么问题?
description: 提供尽可能多的信息描述产生了什么问题。
placeholder: ""
validations:
required: true
- type: textarea
attributes:
label: 期望行为是什么?
description: 描述期望的行为应该是什么样子的。
placeholder: ""
validations:
required: true
- type: textarea
attributes:
label: 如何复现该缺陷
description: 提供尽可能多的信息描述如何复现该缺陷。
validations:
required: true
- type: textarea
attributes:
label: 其他补充信息
description: 补充下其他您认为需要提供的信息。
validations:
required: false
- type: checkboxes
attributes:
label: 版本或分支信息
description: 在哪些版本、分支存在该缺陷的?
options:
- label: master
- label: Release 3.2
- label: Release 3.1
- label: Release 3.0
- label: Release 2.x
validations:
required: true

View File

@ -0,0 +1 @@
blank_issues_enabled: false

View File

@ -0,0 +1,21 @@
name: 新需求|Feature
description: 您需要反馈或实现一个新需求时,使用此模板。
title: "[新需求]: "
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
感谢提出新需求。
- type: textarea
attributes:
label: 新需求提供了什么功能?
description: 请描述下新需求的功能是什么,解决了什么问题
validations:
required: true
- type: textarea
attributes:
label: 该需求带来的价值、应用场景?
description: 请描述下该需求的价值,应用场景等。
validations:
required: false

View File

@ -0,0 +1,15 @@
name: 问题咨询|Question
description: 如果您对OpenHarmony社区有疑问欢迎反馈咨询。
title: "[问题咨询]: "
labels: ["question"]
body:
- type: markdown
attributes:
value: |
感谢提出问题,我们将安排人答复!
- type: textarea
attributes:
label: 问题描述
description: 请描述下您的问题
validations:
required: true

View File

@ -0,0 +1,72 @@
name: 安全问题|Security Issue
description: 当您发现安全问题时,使用此模板反馈。
title: "[安全问题]: "
labels: ["SIG_Security"]
body:
- type: markdown
attributes:
value: |
感谢对OpenHarmony社区的支持与关注欢迎反馈安全问题。
- type: input
attributes:
label: 漏洞编号:
description: 请描述下漏洞编号。
placeholder: ""
validations:
required: false
- type: input
attributes:
label: 漏洞归属组件
description: 请描述下漏洞归属组件。
placeholder: ""
validations:
required: false
- type: input
attributes:
label: 漏洞归属版本
description: 请描述下漏洞归属版本。
placeholder: ""
validations:
required: false
- type: input
attributes:
label: CVSS V3.0分值
description: 请描述下CVSS V3.0分值。
placeholder: ""
validations:
required: false
- type: textarea
attributes:
label: 漏洞简述
description: 请提供下漏洞的描述信息。
placeholder: ""
validations:
required: true
- type: textarea
attributes:
label: 影响性分析说明
description: 请描述下该漏洞的影响。
placeholder: ""
validations:
required: false
- type: textarea
attributes:
label: 原理分析
description: 请分析下该漏洞的原理。
placeholder: ""
validations:
required: false
- type: input
attributes:
label: 受影响版本
description: 请描述下该漏洞的影响版本。
placeholder: ""
validations:
required: false
- type: textarea
attributes:
label: 规避方案或消减措施
description: 请描述下该漏洞的规避方案或消减措施。
placeholder: ""
validations:
required: false

View File

@ -0,0 +1,8 @@
### 一、修改说明
### 二、变更内容
### 三、测试建议

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "gpu_transform/src/main/cpp/boundscheck/third_party_bounds_checking_function"]
path = gpu_transform/src/main/cpp/boundscheck/third_party_bounds_checking_function
url = https://gitee.com/openharmony/third_party_bounds_checking_function.git

View File

@ -1,3 +1,54 @@
## 3.2.2-rc.1
- Support EXIF metadata carried by images as display orientation
## 3.2.2-rc.0
- Add ImageKnifeComponent to destroy network request interruption
- Code refactoring during the download of image resources stage
## 3.2.1
- Release official version
## 3.2.1-rc.0
- Fix bug: CropTransformation is used to crop the original image
- Fix bug: After calling the clear all file cache interfaces, the file cache becomes invalid
- Optimize the efficiency of file cache initialization.
- Add protection at the location where loadSrc is passed in the pixelmap type
## 3.2.0
- When successfully requesting the network, return the httpcode as well
- Fix bug: Network error code httpCode returns no data
- Modify implementation of ImageFit.Auto: do not modify image height
- Modify memory cache limit and file cache limit
- Fix record decodeEndTime in imageKinfaData
- Add image buffersize in memory cache
- Optimize the magic number of heif format image files
- Fix bug: The width and height of the downsampling component are inconsistent with the image resolution unit
## 3.2.0-rc.6
- Support LogUtil to turn off log
- Support set network request readTimeout and connectTimeout through ImageKnifeOption
## 3.2.0-rc.5
- Enhance: ImageFit.Auto support adaptive height after component width change
- Fix bug: call onLoadStart 2 times(import from 3.2.0-rc.0)
- Change the initial value of the PixelMap component of ImageKnife to ImageContent EMPTY
- Clear memory cache, cancel pixel map release
- Loading process log modification
- Change the network request readTimeout to 30s
## 3.2.0-rc.4
- Support ICO format images
- Fix bug: call reload problem in onLoadFailed
- Provide default downsampling strategy to prevent slow loading for large images
## 3.2.0-rc.3
- Fix bug: PixelMap size exceeds the maximum value of memory cache and is not cached
- Dealing with exception scenarios where imageSource.getImageInfo return undefined
- Fix inability to parse Resource format images of other modules
- Improve the error logs
- Fix callback onLoadFailed when taskpool exception occurs
- ImageKnife AnimatorComponent component adds rounded corner function
## 3.2.0-rc.2 ## 3.2.0-rc.2
- Added callback information for image loading - Added callback information for image loading
- Added the interface for obtaining the upper limit and size of the current cache and the number of images corresponding to the current cache - Added the interface for obtaining the upper limit and size of the current cache and the number of images corresponding to the current cache
@ -16,6 +67,33 @@
- Fixed bug for receive only the first onLoadStart for concurrent identical requests - Fixed bug for receive only the first onLoadStart for concurrent identical requests
- Modify the condition for determining whether to queue to be greater than or equal to maxRequests - Modify the condition for determining whether to queue to be greater than or equal to maxRequests
## 3.1.1-rc.1
- Photo reduction sampling
## 3.1.1-rc.0
- 重构代码抽取ImageKnifeDispatcher子线程requestJob相关代码到ImageKnifeLoader中降低函数复杂度
## 3.1.0
- 部分静态webp图片有delay属性导致识别成动图,改用getFrameCount识别
- 修复加载错误图后未去请求排队队列中的请求
- 子线程本地Resource参数类型转换成number
- 修改使用hilog记录日志默认打开debug级别的日志
- file格式图片fd同步close
- 解码pixelMap默认不可编辑图形变化可编辑
- 修改网络请求超时设置
## 3.1.0-rc.2
- 修复宽高不等svg图片显示有毛边
## 3.1.0-rc.1
- ImageKnifeAnimatorComponent新增开始、结束、暂停的回调事件
- 文件缓存数量负数和超过INT最大值时默认为INT最大值
## 3.1.0-rc.0
- ComponentV2装饰器适配
- imageKnifeOption={...}用法改为new ImageKnifeOption({...})
- animatorOption={...}用法改为new AnimatorOption({...})
## 3.0.3 ## 3.0.3
- Released version 3.0.3 - Released version 3.0.3

20
OAT.xml
View File

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- 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.
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
-->
<configuration> <configuration>
<oatconfig> <oatconfig>
<filefilterlist> <filefilterlist>
@ -10,6 +27,7 @@
<filteritem type="filename" name="hvigorw" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/> <filteritem type="filename" name="hvigorw" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigorw.bat" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/> <filteritem type="filename" name="hvigorw.bat" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigor-wrapper.js" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/> <filteritem type="filename" name="hvigor-wrapper.js" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name=".gitmodules" desc="git配置文件不添加版权头"/>
<filteritem type="filepath" name="library/src/main/ets/3rd_party/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/> <filteritem type="filepath" name="library/src/main/ets/3rd_party/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
</filefilter> </filefilter>
<filefilter name="defaultPolicyFilter" desc="Filters for compatibilitylicense header policies"> <filefilter name="defaultPolicyFilter" desc="Filters for compatibilitylicense header policies">
@ -20,6 +38,7 @@
<filteritem type="filename" name="hvigorw" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/> <filteritem type="filename" name="hvigorw" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigorw.bat" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/> <filteritem type="filename" name="hvigorw.bat" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name="hvigor-wrapper.js" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/> <filteritem type="filename" name="hvigor-wrapper.js" desc="hvigorw配置文件DevEco Studio自动生成不手动修改"/>
<filteritem type="filename" name=".gitmodules" desc="git配置文件不添加版权头"/>
<filteritem type="filepath" name="library/src/main/ets/3rd_party/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/> <filteritem type="filepath" name="library/src/main/ets/3rd_party/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
</filefilter> </filefilter>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies"> <filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
@ -31,6 +50,7 @@
<filteritem type="filename" name="*.gif" desc="gif图片格式文件,用于展示示例"/> <filteritem type="filename" name="*.gif" desc="gif图片格式文件,用于展示示例"/>
<filteritem type="filename" name="*.jpg" desc="jpg图片格式文件,用于展示示例"/> <filteritem type="filename" name="*.jpg" desc="jpg图片格式文件,用于展示示例"/>
<filteritem type="filename" name="*.jpeg" desc="jpeg图片格式文件,用于展示示例"/> <filteritem type="filename" name="*.jpeg" desc="jpeg图片格式文件,用于展示示例"/>
<filteritem type="filename" name="*.heic" desc="heic图片格式文件,用于展示示例"/>
<filteritem type="filename" name="*.json5" desc="hvigor配置文件"/> <filteritem type="filename" name="*.json5" desc="hvigor配置文件"/>
</filefilter> </filefilter>
<filefilter name="defaultFilter" desc="Files not to check"> <filefilter name="defaultFilter" desc="Files not to check">

View File

@ -2,9 +2,9 @@
{ {
"Name": "glide", "Name": "glide",
"License": "Apache License 2.0", "License": "Apache License 2.0",
"License File": "https://github.com/bumptech/glide/blob/master/LICENSE", "License File": "LICENSE",
"Version Number": "4.13.1", "Version Number": "4.13.1",
"Owner" : "bumptech", "Owner" : "xiafeng@huawei.com",
"Upstream URL": "https://github.com/bumptech/glide", "Upstream URL": "https://github.com/bumptech/glide",
"Description": "An image loading and caching library focused on smooth scrolling" "Description": "An image loading and caching library focused on smooth scrolling"
}, },
@ -12,9 +12,9 @@
{ {
"Name": "glide-transformations", "Name": "glide-transformations",
"License": "Apache License 2.0", "License": "Apache License 2.0",
"License File": "https://github.com/wasabeef/glide-transformations/blob/main/LICENSE", "License File": "LICENSE",
"Version Number": "4.3.0", "Version Number": "4.3.0",
"Owner" : "wasabeef", "Owner" : "xiafeng@huawei.com",
"Upstream URL": "https://github.com/wasabeef/glide-transformations", "Upstream URL": "https://github.com/wasabeef/glide-transformations",
"Description": " An transformation library providing a variety of image transformations for Glide. " "Description": " An transformation library providing a variety of image transformations for Glide. "
}, },
@ -22,9 +22,9 @@
{ {
"Name": "fresco", "Name": "fresco",
"License": "MIT License", "License": "MIT License",
"License File": "https://github.com/facebook/fresco/blob/main/LICENSE", "License File": "LICENSE",
"Version Number": "2.6.0", "Version Number": "2.6.0",
"Owner" : "facebook", "Owner" : "xiafeng@huawei.com",
"Upstream URL": "https://github.com/facebook/fresco", "Upstream URL": "https://github.com/facebook/fresco",
"Description": " An library for managing images and the memory they use. " "Description": " An library for managing images and the memory they use. "
}, },
@ -32,9 +32,9 @@
{ {
"Name": "UPNG.js", "Name": "UPNG.js",
"License": "MIT License", "License": "MIT License",
"License File": "https://github.com/photopea/UPNG.js/blob/master/LICENSE", "License File": "LICENSE",
"Version Number": "1.0.0", "Version Number": "1.0.0",
"Owner" : "photopea", "Owner" : "xiafeng@huawei.com",
"Upstream URL": "https://github.com/photopea/UPNG.js", "Upstream URL": "https://github.com/photopea/UPNG.js",
"Description": " Fast and advanced PNG (APNG) decoder and encoder (lossy / lossless) " "Description": " Fast and advanced PNG (APNG) decoder and encoder (lossy / lossless) "
}, },
@ -42,9 +42,9 @@
{ {
"Name": "Luban", "Name": "Luban",
"License": "Apache License 2.0", "License": "Apache License 2.0",
"License File": "https://github.com/Curzibn/Luban/blob/master/LICENSE", "License File": "LICENSE",
"Version Number": "1.1.8", "Version Number": "1.1.8",
"Owner" : " Curzibn", "Owner" : " xiafeng@huawei.com",
"Upstream URL": "https://github.com/Curzibn/Luban", "Upstream URL": "https://github.com/Curzibn/Luban",
"Description": " Luban(鲁班)—Image compression with efficiency very close to WeChat Moments/可能是最接近微信朋友圈的图片压缩算法 " "Description": " Luban(鲁班)—Image compression with efficiency very close to WeChat Moments/可能是最接近微信朋友圈的图片压缩算法 "
}, },
@ -54,16 +54,16 @@
"License": "Apache License 2.0", "License": "Apache License 2.0",
"License File": "https://github.com/Yalantis/uCrop/blob/develop/README.md", "License File": "https://github.com/Yalantis/uCrop/blob/develop/README.md",
"Version Number": "2.2.8", "Version Number": "2.2.8",
"Owner" : " Yalantis", "Owner" : " xiafeng@huawei.com",
"Upstream URL": "https://github.com/Yalantis/uCrop", "Upstream URL": "https://github.com/Yalantis/uCrop",
"Description": " Image Cropping Library " "Description": " Image Cropping Library "
}, },
{ {
"Name": "js-spark-md5", "Name": "js-spark-md5",
"License": "MIT", "License": "MIT",
"License File": "https://github.com/satazor/js-spark-md5/blob/master/LICENSE", "License File": "LICENSE",
"Version Number": "v3.0.2", "Version Number": "v3.0.2",
"Owner" : "satazor", "Owner" : "xiafeng@huawei.com",
"Upstream URL": "https://github.com/satazor/js-spark-md5", "Upstream URL": "https://github.com/satazor/js-spark-md5",
"Description": "Lightning fast normal and incremental md5 for javascript" "Description": "Lightning fast normal and incremental md5 for javascript"
} }

View File

@ -1,3 +1,9 @@
## 🚨 **重要提示 | IMPORTANT**
>
> **⚠️ 此代码仓已归档。新地址请访问 [ImageKnife](https://gitcode.com/openharmony-tpc/ImageKnife)。| ⚠️ This repository has been archived. For the new address, please visit [ImageKnife](https://gitcode.com/openharmony-tpc/ImageKnife).**
>
---
>
# ImageKnife # ImageKnife
ImageKnife is a specially crafted image loading and caching library for OpenHarmony, optimized for efficiency, lightness, and simplicity. ImageKnife is a specially crafted image loading and caching library for OpenHarmony, optimized for efficiency, lightness, and simplicity.
@ -361,6 +367,14 @@ This project has been verified in the following version:
DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release(5.0.0.66) DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release(5.0.0.66)
## About obfuscation
- Code obfuscation, please see[Code Obfuscation](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/source-obfuscation.md)
- If you want the imageknife library not to be obfuscated during code obfuscation, you need to add corresponding exclusion rules in the obfuscation rule configuration file obfuscation-rules.txt
```
-keep
./oh_modules/@ohos/imageknife
```
## How to Contribute ## How to Contribute
If you find any problem during the use, submit an [Issue](https://gitee.com/openharmony-tpc/ImageKnife/issues) or a [PR](https://gitee.com/openharmony-tpc/ImageKnife/issues) to us. If you find any problem during the use, submit an [Issue](https://gitee.com/openharmony-tpc/ImageKnife/issues) or a [PR](https://gitee.com/openharmony-tpc/ImageKnife/issues) to us.

View File

@ -1,3 +1,9 @@
## 🚨 **重要提示 | IMPORTANT**
>
> **⚠️ 此代码仓已归档。新地址请访问 [ImageKnife](https://gitcode.com/openharmony-tpc/ImageKnife)。| ⚠️ This repository has been archived. For the new address, please visit [ImageKnife](https://gitcode.com/openharmony-tpc/ImageKnife).**
>
---
>
# ImageKnife # ImageKnife
**专门为OpenHarmony打造的一款图像加载缓存库致力于更高效、更轻便、更简单。** **专门为OpenHarmony打造的一款图像加载缓存库致力于更高效、更轻便、更简单。**
@ -267,21 +273,21 @@ ImageKnifeAnimatorComponent({
#### 11.加载图片回调信息数据 示例 #### 11.加载图片回调信息数据 示例
``` ```
ImageKnifeComponent({ ImageKnifeOption: = new ImageKnifeOption({ ImageKnifeComponent({ ImageKnifeOption: = {
loadSrc: $r('app.media.pngSample'), loadSrc: $r('app.media.pngSample'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
onLoadListener: { onLoadListener: {
onLoadStart: (req) => { onLoadStart: (req) => {
let startCallBackData = JSON.stringify(req?.getImageKnifeData()); let startCallBackData = JSON.stringify(req?.imageKnifeData);
}, },
onLoadFailed: (res, req) => { onLoadFailed: (res, req) => {
let failedBackData = res + ";" + JSON.stringify(req?.getImageKnifeData()); let failedBackData = res + ";" + JSON.stringify(req?.imageKnifeData);
}, },
onLoadSuccess: (data, imageData, req) => { onLoadSuccess: (data, imageData, req) => {
let successBackData = JSON.stringify(req?.getImageKnifeData()); let successBackData = JSON.stringify(req?.imageKnifeData);
}, },
onLoadCancel: (res, req) => { onLoadCancel: (res, req) => {
let cancelBackData = res + ";" + JSON.stringify(req?.getImageKnifeData()); let cancelBackData = res + ";" + JSON.stringify(req?.imageKnifeData);
} }
}, },
border: { radius: 50 }, border: { radius: 50 },
@ -290,7 +296,7 @@ ImageKnifeComponent({ ImageKnifeOption: = new ImageKnifeOption({
let render_success = JSON.stringify(Date.now()) let render_success = JSON.stringify(Date.now())
} }
} }
}) }
}).width(100).height(100) }).width(100).height(100)
``` ```
#### 12.图片降采样 示例 #### 12.图片降采样 示例
@ -304,6 +310,33 @@ ImageKnifeComponent({
} }
}).width(300).height(300) }).width(300).height(300)
``` ```
#### 13.rcp自定义网络请求
```
ImageKnifeComponent({
loadSrc:"http//xx.xx",
customGetImage:custom
})
// 自定义下载方法
@Concurrent
async function custom(context: Context, src: string | PixelMap | Resource,headers?: Record<string,Object>): Promise<ArrayBuffer | undefined> {
return new Promise((resolve,reject)=>{
if (typeof src == "string") {
let session = GetSession.session
let req = new rcp.Request(src,"GET");
session.fetch(req).then((response)=>{
if(response.statusCode == 200) {
let buffer = response.body
resolve(buffer)
} else {
reject("rcp code:"+response.statusCode)
}
}).catch((err:BusinessError)=>{
reject("error rcp src:"+src+",err:"+JSON.stringify(err))
})
}
})
}
```
#### 复用场景 #### 复用场景
在aboutToRecycle生命周期清空组件内容通过watch监听触发图片的加载。 在aboutToRecycle生命周期清空组件内容通过watch监听触发图片的加载。
@ -328,39 +361,40 @@ ImageKnifeComponent({
### ImageKnifeOption参数列表 ### ImageKnifeOption参数列表
| 参数名称 | 入参内容 | 功能简介 | | 参数名称 | 入参内容 | 功能简介 |
|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------| |-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|
| loadSrc | string、PixelMap、Resource | 主图展示 | | loadSrc | string、PixelMap、Resource | 主图展示 |
| placeholderSrc | PixelMap、Resource | 占位图图展示(可选) | | placeholderSrc | PixelMap、Resource | 占位图图展示(可选) |
| errorholderSrc | PixelMap、Resource | 错误图展示(可选) | | errorholderSrc | PixelMap、Resource | 错误图展示(可选) |
| objectFit | ImageFit | 主图填充效果(可选) | | objectFit | ImageFit | 主图填充效果(可选) |
| placeholderObjectFit | ImageFit | 占位图填充效果(可选) | | placeholderObjectFit | ImageFit | 占位图填充效果(可选) |
| errorholderObjectFit | ImageFit | 错误图填充效果(可选) | | errorholderObjectFit | ImageFit | 错误图填充效果(可选) |
| writeCacheStrategy | CacheStrategyType | 写入缓存策略(可选) | | writeCacheStrategy | CacheStrategyType | 写入缓存策略(可选) |
| onlyRetrieveFromCache | boolean | 是否跳过网络和本地请求(可选) | | onlyRetrieveFromCache | boolean | 是否跳过网络和本地请求(可选) |
| customGetImage | customGetImage?:(context: Context, src: string、PixelMap、Resource ,headers?: Record<string, Object>) => Promise<ArrayBufferundefined> | 自定义下载图片(可选) | | Resource | 错误占位图数据源 | | customGetImage | customGetImage?:(context: Context, src: string、PixelMap、Resource ,headers?: Record<string, Object>) => Promise<ArrayBufferundefined> | 自定义下载图片(可选) | | Resource | 错误占位图数据源 |
| border | BorderOptions | 边框圆角(可选) | | border | BorderOptions | 边框圆角(可选) |
| priority | taskpool.Priority | 加载优先级(可选) | | priority | taskpool.Priority | 加载优先级(可选) |
| context | common.UIAbilityContext | 上下文(可选) | | context | common.UIAbilityContext | 上下文(可选) |
| progressListener | (progress: number)=>void | 进度(可选) | | progressListener | (progress: number)=>void | 进度(可选) |
| signature | String | 自定义缓存关键字(可选) | | signature | String | 自定义缓存关键字(可选) |
| headerOption | Array<HeaderOptions> | 设置请求头(可选) | | headerOption | Array<HeaderOptions> | 设置请求头(可选) |
| transformation | PixelMapTransformation | 图片变换(可选) | | transformation | PixelMapTransformation | 图片变换(可选) |
| drawingColorFilter | ColorFilter、drawing.ColorFilter | 图片变换(可选) | | drawingColorFilter | ColorFilter、drawing.ColorFilter | 颜色滤镜效果(可选) |
| onComplete | (event:EventImage、undefined) => void | 颜色滤镜效果(可选) | | onComplete | (event:EventImage、undefined) => void | 图片成功回调事件(可选) |
| onLoadListener | onLoadStart?: (req?: ImageKnifeRequest) => void,onLoadSuccess?: (data: string \| PixelMap \| undefined, imageData: ImageKnifeData, req?: ImageKnifeRequest) => void,onLoadFailed?: (err: string, req?: ImageKnifeRequest) => void,onLoadCancel?: (res: string, req?: ImageKnifeRequest) => void | 监听图片加载成功与失败 | | onLoadListener | onLoadStart?: (req?: ImageKnifeRequest) => void,onLoadSuccess?: (data: string \| PixelMap \| undefined, imageData: ImageKnifeData, req?: ImageKnifeRequest) => void,onLoadFailed?: (err: string, req?: ImageKnifeRequest) => void,onLoadCancel?: (res: string, req?: ImageKnifeRequest) => void | 监听图片加载成功与失败 |
| downsampleOf | DownsampleStrategy | 降采样(可选) | | downsampleOf | DownsampleStrategy | 降采样(可选) |
| httpOption | HttpRequestOption | 网络请求配置(可选) |
### 降采样类型 ### 降采样类型
| 类型 | 相关描述 | | 类型 | 相关描述 |
|---------------------|-------------------| |------------------------|-------------------|
| NONE | 不进行降采样 | | NONE | 不进行降采样 |
| AT_MOST | 请求尺寸大于实际尺寸不进行放大 | | AT_MOST | 请求尺寸大于实际尺寸不进行放大 |
| FIT_CENTER_MEMORY | 两边自适应内存优先 | | FIT_CENTER_MEMORY | 两边自适应内存优先 |
| FIT_CENTER_QUALITY | 两边自适应质量优先 | | FIT_CENTER_QUALITY | 两边自适应质量优先 |
| CENTER_OUTSIDE_MEMORY | 宽高缩放比最大的比例,进行缩放适配内存优先 | | CENTER_INSIDE_MEMORY | 宽高缩放比最大的比例,进行缩放适配内存优先 |
| CENTER_OUTSIDE_QUALITY | 宽高缩放比最大的比例,进行缩放适配质量优先 | | CENTER_INSIDE_QUALITY | 宽高缩放比最大的比例,进行缩放适配质量优先 |
| AT_LEAST | 根据宽高的最小的比例,进行适配 | | AT_LEAST | 根据宽高的最小的比例,进行适配 |
### ImageKnife接口 ### ImageKnife接口
@ -429,6 +463,14 @@ ImageKnifeComponent({
在下述版本验证通过: 在下述版本验证通过:
DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release(5.0.0.66) DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release(5.0.0.66)
## 关于混淆
- 代码混淆,请查看[代码混淆简介](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/source-obfuscation.md)
- 如果希望imageknife库在代码混淆过程中不会被混淆需要在混淆规则配置文件obfuscation-rules.txt中添加相应的排除规则
```
-keep
./oh_modules/@ohos/imageknife
```
## 贡献代码 ## 贡献代码
使用过程中发现任何问题都可以提 [issue](https://gitee.com/openharmony-tpc/ImageKnife/issues) 使用过程中发现任何问题都可以提 [issue](https://gitee.com/openharmony-tpc/ImageKnife/issues)
@ -440,5 +482,4 @@ DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release(5.0.0.66)
## 遗留问题 ## 遗留问题
- ImageKnifeAnimator组件无法设置ImageFit属性 - ImageKnifeAnimator组件无法设置ImageFit属性
- ImageKnifeAnimator组件设置border属性无法将图片变为圆角

View File

@ -7,9 +7,9 @@
{ {
"name": "default", "name": "default",
"signingConfig": "default", "signingConfig": "default",
"compileSdkVersion": "5.0.0(12)", "compileSdkVersion": 12,
"compatibleSdkVersion": "5.0.0(12)", "compatibleSdkVersion": 12,
"runtimeOS": "HarmonyOS", "runtimeOS": "OpenHarmony"
} }
], ],
"buildModeSet": [ "buildModeSet": [
@ -38,6 +38,10 @@
"name": "library", "name": "library",
"srcPath": "./library" "srcPath": "./library"
}, },
{
"name": "gpu_transform",
"srcPath": "./gpu_transform"
},
{ {
"name": "sharedlibrary", "name": "sharedlibrary",
"srcPath": "./sharedlibrary", "srcPath": "./sharedlibrary",

View File

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

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2024 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 { ImageKnifeComponent } from '@ohos/libraryimageknife';
import { display } from '@kit.ArkUI';
@Entry
@Component
struct AutoImageFit {
@State imageWidth: number = 200;
private maxWidth: number = px2vp(display.getDefaultDisplaySync().width);
build() {
Column() {
this.Slider()
Column() {
Text('Image')
Image('https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg')
.width('100%')
.objectFit(ImageFit.Auto)
Text('ImageKnife')
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg',
objectFit: ImageFit.Auto,
}
}).width('100%')
}.width(this.imageWidth).border({ width: 1 })
}
}
@Builder
Slider() {
Slider({
value: this.imageWidth,
min: 100,
max: this.maxWidth,
style: SliderStyle.OutSet
})
.blockColor(Color.White)
.width('100%')
.onChange((value: number) => {
this.imageWidth = value;
})
}
}

View File

@ -1,78 +0,0 @@
/*
* Copyright (C) 2024 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 { InfoItem } from './model/DataSourcePrefetching';
import { PageViewModel } from './model/PageViewModel';
import { ImageKnifeComponent, ImageKnife } from '@ohos/libraryimageknife';
import { CommonDataSource, GetSession } from './model/CommonDataSource';
import { rcp } from '@kit.RemoteCommunicationKit';
import { BusinessError } from '@kit.BasicServicesKit';
@Entry
@Component
export struct CustomNetImagePage {
@State hotCommendList:CommonDataSource<InfoItem> = new CommonDataSource<InfoItem>([])
aboutToAppear(): void {
ImageKnife.getInstance().setMaxRequests(32)
this.hotCommendList.addData(this.hotCommendList.totalCount(),PageViewModel.getItems())
}
aboutToDisappear(): void {
ImageKnife.getInstance().setMaxRequests(8)
}
build() {
Column() {
WaterFlow() {
LazyForEach(this.hotCommendList,(item: InfoItem)=>{
FlowItem() {
Column(){
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: item.albumUrl,
placeholderSrc: $r("app.media.loading"),
errorholderSrc: $r("app.media.failed"),
customGetImage:custom
}
}).width("50%").height(200)
}
}.height(200)
.backgroundColor("#95efd2")
},(item: string) => item)
}.columnsTemplate("1fr 1fr")
.columnsGap(10)
.rowsGap(5)
.backgroundColor(0xFAEEE0)
.width("100%").height("100%")
}
}
}
// 自定义下载方法
@Concurrent
async function custom(context: Context, src: string | PixelMap | Resource,headers?: Record<string,Object>): Promise<ArrayBuffer | undefined> {
return new Promise((resolve,reject)=>{
if (typeof src == "string") {
let session = GetSession.session
let req = new rcp.Request(src,"GET");
session.fetch(req).then((response)=>{
if(response.statusCode == 200) {
let buffer = response.body
resolve(buffer)
} else {
reject("rcp code:"+response.statusCode)
}
}).catch((err:BusinessError)=>{
reject("error rcp src:"+src+",err:"+JSON.stringify(err))
})
}
})
}

View File

@ -24,8 +24,8 @@ import { FileTypeUtil } from '@ohos/imageknife/src/main/ets/utils/FileTypeUtil';
struct DownSamplePage { struct DownSamplePage {
@State imageKnifeOption: ImageKnifeOption = { @State imageKnifeOption: ImageKnifeOption = {
loadSrc: $r('app.media.startIcon'), loadSrc: $r('app.media.startIcon'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain objectFit: ImageFit.Contain
} }
isBrightness: boolean = false isBrightness: boolean = false
@ -33,14 +33,14 @@ struct DownSamplePage {
@State afterSampling: number = 0 @State afterSampling: number = 0
@State SamplingList: SamplingType[] = [ @State SamplingList: SamplingType[] = [
new SamplingType(7, "AT_LEAST"), new SamplingType(7, 'AT_LEAST'),
new SamplingType(1, "AT_MOST"), new SamplingType(1, 'AT_MOST'),
new SamplingType(2, "FIT_CENTER_MEMORY"), new SamplingType(2, 'FIT_CENTER_MEMORY'),
new SamplingType(4, "FIT_CENTER_QUALITY"), new SamplingType(4, 'FIT_CENTER_QUALITY'),
new SamplingType(5, "CENTER_OUTSIDE_MEMORY"), new SamplingType(5, 'CENTER_INSIDE_MEMORY'),
new SamplingType(6, "CENTER_OUTSIDE_QUALITY"), new SamplingType(6, 'CENTER_INSIDE_QUALITY'),
new SamplingType(0, "NONE"), new SamplingType(0, 'NONE'),
] ]
@State checked: boolean = false @State checked: boolean = false
@ -49,8 +49,8 @@ struct DownSamplePage {
if (value === 'NONE') { if (value === 'NONE') {
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: $r('app.media.pngSample'), loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
downsampleOf: DownsampleStrategy.NONE downsampleOf: DownsampleStrategy.NONE
} }
@ -59,8 +59,8 @@ struct DownSamplePage {
} else if (value === 'AT_MOST') { } else if (value === 'AT_MOST') {
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: $r('app.media.pngSample'), loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
downsampleOf: DownsampleStrategy.AT_MOST downsampleOf: DownsampleStrategy.AT_MOST
} }
@ -69,8 +69,8 @@ struct DownSamplePage {
} else if (value === 'FIT_CENTER_MEMORY') { } else if (value === 'FIT_CENTER_MEMORY') {
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: $r('app.media.pngSample'), loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
downsampleOf: DownsampleStrategy.FIT_CENTER_MEMORY downsampleOf: DownsampleStrategy.FIT_CENTER_MEMORY
} }
@ -79,38 +79,38 @@ struct DownSamplePage {
} else if (value === 'FIT_CENTER_QUALITY') { } else if (value === 'FIT_CENTER_QUALITY') {
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: $r('app.media.pngSample'), loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
downsampleOf: DownsampleStrategy.FIT_CENTER_QUALITY downsampleOf: DownsampleStrategy.FIT_CENTER_QUALITY
} }
this.originalPixMap($r('app.media.pngSample')) this.originalPixMap($r('app.media.pngSample'))
this.afterSamplingFunc($r('app.media.pngSample')) this.afterSamplingFunc($r('app.media.pngSample'))
} else if (value === 'CENTER_OUTSIDE_MEMORY') { } else if (value === 'CENTER_INSIDE_MEMORY') {
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: $r('app.media.pngSample'), loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
downsampleOf: DownsampleStrategy.CENTER_OUTSIDE_MEMORY downsampleOf: DownsampleStrategy.CENTER_INSIDE_MEMORY
} }
this.originalPixMap($r('app.media.pngSample')) this.originalPixMap($r('app.media.pngSample'))
this.afterSamplingFunc($r('app.media.pngSample')) this.afterSamplingFunc($r('app.media.pngSample'))
} else if (value === 'CENTER_OUTSIDE_QUALITY') { } else if (value === 'CENTER_INSIDE_QUALITY') {
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: $r('app.media.pngSample'), loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
downsampleOf: DownsampleStrategy.CENTER_OUTSIDE_QUALITY downsampleOf: DownsampleStrategy.CENTER_INSIDE_QUALITY
} }
this.originalPixMap($r('app.media.pngSample')) this.originalPixMap($r('app.media.pngSample'))
this.afterSamplingFunc($r('app.media.pngSample')) this.afterSamplingFunc($r('app.media.pngSample'))
} else { } else {
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: $r('app.media.pngSample'), loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
downsampleOf: DownsampleStrategy.AT_LEAST downsampleOf: DownsampleStrategy.AT_LEAST
} }
@ -145,9 +145,12 @@ struct DownSamplePage {
// 创建pixelMap // 创建pixelMap
imageSource.createPixelMap(decodingOptions).then((pixelMap: image.PixelMap) => { imageSource.createPixelMap(decodingOptions).then((pixelMap: image.PixelMap) => {
imageSource.release()
this.afterSampling = pixelMap.getPixelBytesNumber() this.afterSampling = pixelMap.getPixelBytesNumber()
pixelMap.release()
}).catch((err: BusinessError) => { }).catch((err: BusinessError) => {
console.error("Failed to create PixelMap") imageSource.release()
console.error('Failed to create PixelMap')
}); });
} }
@ -160,9 +163,12 @@ struct DownSamplePage {
} }
// 创建pixelMap // 创建pixelMap
imageSource.createPixelMap(decodingOptions).then((pixelMap: image.PixelMap) => { imageSource.createPixelMap(decodingOptions).then((pixelMap: image.PixelMap) => {
imageSource.release()
this.beforeSampling = pixelMap.getPixelBytesNumber() this.beforeSampling = pixelMap.getPixelBytesNumber()
pixelMap.release()
}).catch((err: BusinessError) => { }).catch((err: BusinessError) => {
console.error("Failed to create PixelMap") imageSource.release()
console.error('Failed to create PixelMap')
}); });
} }
getResourceString(res:Resource){ getResourceString(res:Resource){
@ -191,8 +197,8 @@ struct DownSamplePage {
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: this.imageKnifeOption imageKnifeOption: this.imageKnifeOption
}) })
.height(300) .height(px2vp(300))
.width(300) .width(px2vp(300))
.borderWidth(1) .borderWidth(1)
.borderColor(Color.Pink) .borderColor(Color.Pink)
} }

View File

@ -0,0 +1,93 @@
/*
* Copyright (C) 2024 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 { ImageKnifeComponent } from '@ohos/libraryimageknife'
@Entry
@Component
struct ErrorMessageDownload {
@State httpCode: string = ''
@State httpError: string = ''
@State storageError: string = ''
@State fileError: string = ''
@State notPic: string = ''
build() {
Column() {
Text(this.httpCode)
ImageKnifeComponent({
imageKnifeOption:{
loadSrc:'https://gitee.com/openharmony-tpc/ImageKnife/issues/1111111',
errorholderSrc:$r('app.media.failed'),
onLoadListener:{
onLoadFailed:(err)=>{
this.httpCode = err
}
}
}
}).width(100).height(100).margin({bottom:10})
Text(this.httpError)
ImageKnifeComponent({
imageKnifeOption:{
loadSrc:'https://xx.xx.xx',
errorholderSrc:$r('app.media.failed'),
onLoadListener:{
onLoadFailed:(err)=>{
this.httpError = err
}
}
}
}).width(100).height(100).margin({bottom:10})
Text(this.storageError)
ImageKnifeComponent({
imageKnifeOption:{
loadSrc:'/data/storage/el2/base/haps/entry/cache/a/b',
errorholderSrc:$r('app.media.failed'),
onLoadListener:{
onLoadFailed:(err)=>{
this.storageError = err
}
}
}
}).width(100).height(100).margin({bottom:10})
Text(this.fileError)
ImageKnifeComponent({
imageKnifeOption:{
loadSrc:'file://xx.xx.xx',
errorholderSrc:$r('app.media.failed'),
onLoadListener:{
onLoadFailed:(err)=>{
this.fileError = err
}
}
}
}).width(100).height(100).margin({bottom:10})
Text(this.notPic)
ImageKnifeComponent({
imageKnifeOption:{
loadSrc:'xx.xx.xx',
errorholderSrc:$r('app.media.failed'),
onLoadListener:{
onLoadFailed:(err)=>{
this.notPic = err
}
}
}
}).width(100).height(100).margin({bottom:10})
}
}
}

View File

@ -12,82 +12,91 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { AnimatorOption, ImageKnifeAnimatorComponent } from "@ohos/libraryimageknife" import { AnimatorOption, ImageKnifeAnimatorComponent, ImageKnifeOption } from '@ohos/libraryimageknife'
@Entry @Entry
@Component @Component
struct ImageAnimatorPage { struct ImageAnimatorPage {
@State animatorOption: AnimatorOption = { @State animatorOption: AnimatorOption = {
state: AnimationStatus.Running, state: AnimationStatus.Running,
iterations: 1, iterations: -1,
onFinish:()=>{ onFinish: () => {
console.log("ImageKnifeAnimatorComponent animatorOption onFinish") console.log('ImageKnifeAnimatorComponent animatorOption onFinish')
}, },
onStart:()=>{ onStart: () => {
console.log("ImageKnifeAnimatorComponent animatorOption onStart") console.log('ImageKnifeAnimatorComponent animatorOption onStart')
}, },
onPause:()=>{ onPause: () => {
console.log("ImageKnifeAnimatorComponent animatorOption onPause") console.log('ImageKnifeAnimatorComponent animatorOption onPause')
}, },
onCancel:()=>{ onCancel: () => {
console.log("ImageKnifeAnimatorComponent animatorOption onCancel") console.log('ImageKnifeAnimatorComponent animatorOption onCancel')
}, },
onRepeat:()=>{ onRepeat: () => {
console.log("ImageKnifeAnimatorComponent animatorOption onRepeat") console.log('ImageKnifeAnimatorComponent animatorOption onRepeat')
} }
} }
@State animatorOption1: AnimatorOption = { @State animatorOptionFirstFrame: AnimatorOption = {
state: AnimationStatus.Initial state: AnimationStatus.Initial
} }
@State animatorOption2: AnimatorOption = { @State animatorOptionLastFrame: AnimatorOption = {
state: AnimationStatus.Initial, state: AnimationStatus.Initial,
reverse: true reverse: true
} }
@State imageKnifeOption: ImageKnifeOption = {
loadSrc: 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658',
placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r('app.media.failed')
}
build() { build() {
Column(){ Column() {
Flex(){ Row() {
Button($r('app.string.Play')).onClick(()=>{ Button($r('app.string.Play')).onClick(() => {
this.animatorOption.state = AnimationStatus.Running this.animatorOption.state = AnimationStatus.Running
}) })
Button($r('app.string.Pause')).onClick(()=>{ Button($r('app.string.Pause')).onClick(() => {
this.animatorOption.state = AnimationStatus.Paused this.animatorOption.state = AnimationStatus.Paused
}) })
Button($r('app.string.Stop')).onClick(()=>{ Button($r('app.string.Stop')).onClick(() => {
this.animatorOption.state = AnimationStatus.Stopped this.animatorOption.state = AnimationStatus.Stopped
}) })
Button($r('app.string.Infinite_loop')).onClick(()=>{ }
Row() {
Button($r('app.string.Infinite_loop')).onClick(() => {
this.animatorOption.iterations = -1 this.animatorOption.iterations = -1
}) })
Button($r('app.string.Play_once')).onClick(()=>{ Button($r('app.string.Play_once')).onClick(() => {
this.animatorOption.iterations = 1 this.animatorOption.iterations = 1
}) })
Button($r('app.string.Play_twice')).onClick(()=>{ Button($r('app.string.Play_twice')).onClick(() => {
this.animatorOption.iterations = 2 this.animatorOption.iterations = 2
}) })
} }
ImageKnifeAnimatorComponent({ ImageKnifeAnimatorComponent({
imageKnifeOption:{ imageKnifeOption: this.imageKnifeOption,
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658", animatorOption: this.animatorOption
placeholderSrc:$r('app.media.loading'), }).width(300).height(300).backgroundColor(Color.Orange).margin({ top: 30 })
errorholderSrc:$r('app.media.failed')
},animatorOption:this.animatorOption Row({ space: 10 }) {
}).width(300).height(300).backgroundColor(Color.Orange).margin({top:30}) Column() {
Text($r('app.string.Display_the_first_frame')).fontSize(20) Text($r('app.string.Display_the_first_frame')).fontSize(20)
ImageKnifeAnimatorComponent({ ImageKnifeAnimatorComponent({
imageKnifeOption:{ imageKnifeOption: this.imageKnifeOption,
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658", animatorOption: this.animatorOptionFirstFrame
placeholderSrc:$r('app.media.loading'), }).width(120).height(120).backgroundColor(Color.Orange)
errorholderSrc:$r('app.media.failed') }
},animatorOption:this.animatorOption1
}).width(200).height(200).backgroundColor(Color.Orange).margin({top:30}) Column() {
Text($r('app.string.Display_the_last_frame')).fontSize(20) Text($r('app.string.Display_the_last_frame')).fontSize(20)
ImageKnifeAnimatorComponent({ ImageKnifeAnimatorComponent({
imageKnifeOption:{ imageKnifeOption: this.imageKnifeOption,
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658", animatorOption: this.animatorOptionLastFrame
placeholderSrc:$r('app.media.loading'), }).width(120).height(120).backgroundColor(Color.Orange)
errorholderSrc:$r('app.media.failed') }
},animatorOption:this.animatorOption2 }.margin({ top: 50 }).padding(10)
}).width(200).height(200).backgroundColor(Color.Orange).margin({top:30}) }.width('100%').height('100%')
}.width("100%").height("100%")
} }
} }

View File

@ -19,6 +19,7 @@ import { ImageKnifeRequest,ImageKnife,ImageKnifeComponent } from '@ohos/libraryi
@Entry @Entry
@Component @Component
struct ImageKnifeReload { struct ImageKnifeReload {
@State index: number = 0
aboutToAppear(): void { aboutToAppear(): void {
NetWatchState.init() NetWatchState.init()
} }
@ -26,7 +27,7 @@ struct ImageKnifeReload {
Column() { Column() {
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption:{ imageKnifeOption:{
loadSrc:"https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp", loadSrc:'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
placeholderSrc:$r('app.media.loading'), placeholderSrc:$r('app.media.loading'),
errorholderSrc:$r('app.media.failed'), errorholderSrc:$r('app.media.failed'),
onLoadListener:{ onLoadListener:{
@ -38,7 +39,7 @@ struct ImageKnifeReload {
}).width(200).height(200) }).width(200).height(200)
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption:{ imageKnifeOption:{
loadSrc:"https://img-blog.csdn.net/20140514114029140", loadSrc:'https://img-blog.csdn.net/20140514114029140',
placeholderSrc:$r('app.media.loading'), placeholderSrc:$r('app.media.loading'),
errorholderSrc:$r('app.media.failed'), errorholderSrc:$r('app.media.failed'),
onLoadListener:{ onLoadListener:{
@ -48,8 +49,24 @@ struct ImageKnifeReload {
} }
} }
}).width(200).height(200).margin({top:10}) }).width(200).height(200).margin({top:10})
}.width("100%") Text("重试5次" + this.index)
.height("100%") ImageKnifeComponent({
imageKnifeOption:{
loadSrc:'https://img-blog.csdn.net/20140514114029140',
placeholderSrc:$r('app.media.loading'),
errorholderSrc:$r('app.media.failed'),
onLoadListener:{
onLoadFailed:(err,request) => {
this.index++
if(request != undefined && this.index < 5) {
ImageKnife.getInstance().reload(request)
}
}
}
}
}).width(200).height(200).margin({top:10})
}.width('100%')
.height('100%')
} }
} }
@ -63,7 +80,7 @@ class NetWatchState {
NetWatchState.netConnection.register(()=>{ NetWatchState.netConnection.register(()=>{
}) })
// 订阅网络能力变化事件。调用register后才能接收到此事件通知 // 订阅网络能力变化事件。调用register后才能接收到此事件通知
NetWatchState.netConnection.on("netCapabilitiesChange",(data:connection.NetCapabilityInfo)=>{ NetWatchState.netConnection.on('netCapabilitiesChange',(data:connection.NetCapabilityInfo)=>{
if(NetWatchState.requestList.length > 0 && data.netHandle.netId >= 100) { if(NetWatchState.requestList.length > 0 && data.netHandle.netId >= 100) {
NetWatchState.requestList.forEach((request)=>{ NetWatchState.requestList.forEach((request)=>{
ImageKnife.getInstance().reload(request) ImageKnife.getInstance().reload(request)

View File

@ -39,8 +39,8 @@ import { collections } from '@kit.ArkTS'
struct ImageTransformation { struct ImageTransformation {
@State imageKnifeOption: ImageKnifeOption = { @State imageKnifeOption: ImageKnifeOption = {
loadSrc: $r('app.media.pngSample'), loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain objectFit: ImageFit.Contain
} }
@State isRound: boolean = false; @State isRound: boolean = false;
@ -398,13 +398,13 @@ struct ImageTransformation {
transformations.push(new CropSquareTransformation()); transformations.push(new CropSquareTransformation());
} }
if (this.isCropTop) { if (this.isCropTop) {
transformations.push(new CropTransformation(25, 25, 0)); transformations.push(new CropTransformation(100, 100, 0));
} }
if (this.isCropCenter) { if (this.isCropCenter) {
transformations.push(new CropTransformation(25, 25, 1)); transformations.push(new CropTransformation(100, 100, 1));
} }
if (this.isCropBottom) { if (this.isCropBottom) {
transformations.push(new CropTransformation(25, 25, 2)); transformations.push(new CropTransformation(100, 100, 2));
} }
if (this.isSepia) { if (this.isSepia) {
transformations.push(new SepiaTransformation()); transformations.push(new SepiaTransformation());
@ -414,8 +414,8 @@ struct ImageTransformation {
} }
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: $r('app.media.pngSample'), loadSrc: $r('app.media.pngSample'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
border: { radius: this.isRound ? { topLeft: 50, bottomRight: 50 } : 0 }, border: { radius: this.isRound ? { topLeft: 50, bottomRight: 50 } : 0 },
transformation: transformations.length > 0 ? new MultiTransTransformation(transformations) : undefined transformation: transformations.length > 0 ? new MultiTransTransformation(transformations) : undefined

View File

@ -50,16 +50,21 @@ struct Index {
uri: 'pages/SetMaxRequestPage', uri: 'pages/SetMaxRequestPage',
}); });
}) })
Button($r('app.string.Single_CallBack')).margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/SingleImageCallBack',
});
})
Button($r('app.string.Multiple_CallBack')).margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/MultipleImageCallBack',
});
})
Button($r('app.string.Test_multiple_images')).margin({top:10}).onClick(()=>{ Button($r('app.string.Test_multiple_images')).margin({top:10}).onClick(()=>{
router.push({ router.push({
uri: 'pages/TestCommonImage', uri: 'pages/TestCommonImage',
}); });
}) })
Button($r('app.string.Customize_RCP_network')).margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/CustomNetImagePage',
});
})
Button($r('app.string.Test_Task_error')).margin({top:10}).onClick(()=>{ Button($r('app.string.Test_Task_error')).margin({top:10}).onClick(()=>{
router.push({ router.push({
uri: 'pages/TestTaskResourcePage', uri: 'pages/TestTaskResourcePage',
@ -77,19 +82,24 @@ struct Index {
}); });
}) })
Button($r('app.string.Test_LocalImageShow')).margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/LocalImage',
});
})
Button($r('app.string.Error_Message')).margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/ErrorMessageDownload',
});
})
Button($r('app.string.Test_custom_download')).margin({top:10}).onClick(()=>{ Button($r('app.string.Test_custom_download')).margin({top:10}).onClick(()=>{
router.push({ router.push({
uri: 'pages/TestSetCustomImagePage', uri: 'pages/TestSetCustomImagePage',
}); });
}) })
// Button(this.getResourceString($r('app.string.Multiple_images')) + " + LazyForEach").margin({top:10}).onClick(()=>{ Button(this.getResourceString($r('app.string.Multiple_images')) + ' + reuse + LazyForeach').margin({top:10}).onClick(()=>{
// router.push({
// uri: 'pages/ManyPhotoShowPage',
//
// });
// })
Button(this.getResourceString($r('app.string.Multiple_images')) + " + reuse + LazyForeach").margin({top:10}).onClick(()=>{
router.push({ router.push({
uri: 'pages/UserPage', uri: 'pages/UserPage',
@ -106,13 +116,19 @@ struct Index {
}); });
}) })
Button($r('app.string.Auto_ImageFit')).margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/AutoImageFit',
});
})
Button($r('app.string.Image_scaling')).margin({top:10}).onClick(()=>{ Button($r('app.string.Image_scaling')).margin({top:10}).onClick(()=>{
router.push({ router.push({
uri: 'pages/TransformPage', uri: 'pages/TransformPage',
}); });
}) })
Button(this.getResourceString($r('app.string.Message_list')) + " + List").margin({top:10}).onClick(()=>{ Button(this.getResourceString($r('app.string.Message_list')) + ' + List').margin({top:10}).onClick(()=>{
router.push({ router.push({
uri: 'pages/TestImageFlash', uri: 'pages/TestImageFlash',
@ -208,6 +224,11 @@ struct Index {
}); });
}) })
Button($r('app.string.test_exif')).margin({ top: 10 }).onClick(() => {
router.push({
uri: 'pages/TestImageExif',
});
})
} }
} .width('100%') } .width('100%')
.height('100%') .height('100%')

View File

@ -37,13 +37,13 @@ export struct LazyForEachCache {
} }
}).width(100).height(100) }).width(100).height(100)
Text(`${index}`) Text(`${index}`)
}.border({ width: 5 , color: "#000000"}) }.border({ width: 5 , color: '#000000'})
} }
}) })
} }
.cachedCount(5) .cachedCount(5)
.width("100%") .width('100%')
.height("100%") .height('100%')
.margin({ left: 10, right: 10 }) .margin({ left: 10, right: 10 })
.layoutWeight(1) .layoutWeight(1)
} }

View File

@ -37,13 +37,13 @@ export struct LazyForEachCount {
} }
}).width(100).height(100) }).width(100).height(100)
Text(`${index}`) Text(`${index}`)
}.border({ width: 5 , color: "#000000"}) }.border({ width: 5 , color: '#000000'})
} }
}) })
} }
.cachedCount(30) .cachedCount(30)
.width("100%") .width('100%')
.height("100%") .height('100%')
.margin({ left: 10, right: 10 }) .margin({ left: 10, right: 10 })
.layoutWeight(1) .layoutWeight(1)
} }

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { ImageKnifeComponent, ImageKnifeOption } from "@ohos/libraryimageknife" import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife'
import matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
@Entry @Entry
@ -22,13 +22,13 @@ struct LoadStatePage {
starTime:number = new Date().getTime() starTime:number = new Date().getTime()
@State ImageKnifeOption: ImageKnifeOption = { @State ImageKnifeOption: ImageKnifeOption = {
loadSrc: $r("app.media.rabbit"), loadSrc: $r('app.media.rabbit'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
onLoadListener: { onLoadListener: {
onLoadFailed: (err) => { onLoadFailed: (err) => {
console.error("Load Failed Reason: " + err); console.error('Load Failed Reason: ' + err);
}, },
onLoadSuccess: (data) => { onLoadSuccess: (data) => {
return data; return data;
@ -39,10 +39,10 @@ struct LoadStatePage {
@State imageKnifeOption1: ImageKnifeOption = { @State imageKnifeOption1: ImageKnifeOption = {
loadSrc: $r('app.media.startIcon') loadSrc: $r('app.media.startIcon')
} }
@State message: string = "" @State message: string = ''
@State currentWidth: number = 200 @State currentWidth: number = 200
@State currentHeight: number = 200 @State currentHeight: number = 200
@State typeValue: string = "" @State typeValue: string = ''
build() { build() {
Column() { Column() {
Text($r('app.string.TIPS')) Text($r('app.string.TIPS'))
@ -51,20 +51,20 @@ struct LoadStatePage {
Button($r('app.string.Test_failure_success')) Button($r('app.string.Test_failure_success'))
.onClick(() => { .onClick(() => {
this.ImageKnifeOption = { this.ImageKnifeOption = {
loadSrc: "https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png", loadSrc: 'https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png',
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
onLoadListener: { onLoadListener: {
onLoadStart:()=>{ onLoadStart:()=>{
this.starTime = new Date().getTime() this.starTime = new Date().getTime()
console.info("Load start: "); console.info('Load start: ');
}, },
onLoadFailed: (err) => { onLoadFailed: (err) => {
console.error("Load Failed Reason: " + err + " cost " + (new Date().getTime() - this.starTime) + " milliseconds"); console.error('Load Failed Reason: ' + err + ' cost ' + (new Date().getTime() - this.starTime) + ' milliseconds');
}, },
onLoadSuccess: (data,imageData) => { onLoadSuccess: (data,imageData) => {
console.info("Load Successful: cost " + (new Date().getTime() - this.starTime) + " milliseconds"); console.info('Load Successful: cost ' + (new Date().getTime() - this.starTime) + ' milliseconds');
this.currentWidth = imageData.imageWidth! this.currentWidth = imageData.imageWidth!
this.currentHeight = imageData.imageHeight! this.currentHeight = imageData.imageHeight!
this.typeValue = imageData.type! this.typeValue = imageData.type!
@ -73,7 +73,7 @@ struct LoadStatePage {
}, },
border: { radius: 50 }, border: { radius: 50 },
onComplete:(event)=>{ onComplete:(event)=>{
console.error("Load onComplete width:"+event?.width , " height:"+event?.height , " componentWidth:"+event?.componentWidth," componentHeight:" + event?.componentHeight); console.error('Load onComplete width:'+event?.width , ' height:'+event?.height , ' componentWidth:'+event?.componentWidth,' componentHeight:' + event?.componentHeight);
} }
} }
}) })
@ -86,13 +86,13 @@ struct LoadStatePage {
.margin({ top: 20 }) .margin({ top: 20 })
Button($r('app.string.Custom_download_failed')).onClick(()=>{ Button($r('app.string.Custom_download_failed')).onClick(()=>{
this.imageKnifeOption1 = { this.imageKnifeOption1 = {
loadSrc: "abc", loadSrc: 'abc',
placeholderSrc:$r('app.media.loading'), placeholderSrc:$r('app.media.loading'),
errorholderSrc:$r('app.media.failed'), errorholderSrc:$r('app.media.failed'),
customGetImage:custom, customGetImage:custom,
onLoadListener: { onLoadListener: {
onLoadFailed:(err)=>{ onLoadFailed:(err)=>{
this.message = "err:" + err this.message = 'err:' + err
} }
} }
} }
@ -110,7 +110,7 @@ struct LoadStatePage {
// 自定义下载方法 // 自定义下载方法
@Concurrent @Concurrent
async function custom(context: Context, src: string | PixelMap | Resource,headers?: Record<string,Object>): Promise<ArrayBuffer | undefined> { async function custom(context: Context, src: string | PixelMap | Resource,headers?: Record<string,Object>): Promise<ArrayBuffer | undefined> {
console.info("ImageKnife:: custom download" + src) console.info('ImageKnife:: custom download' + src)
// 举例写死从本地文件读取,也可以自己请求网络图片 // 举例写死从本地文件读取,也可以自己请求网络图片
return undefined return undefined
} }

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2024 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 { ImageKnifeComponent } from '@ohos/libraryimageknife';
import fs from '@ohos.file.fs';
@Entry
@Component
struct LocalImage {
scroller: Scroller = new Scroller;
localFile: string = getContext(this).filesDir + '/icon.png'
aboutToAppear(): void {
// 拷贝本地文件
let icon: Uint8Array = getContext(this).resourceManager.getMediaContentSync($r('app.media.startIcon'));
let file = fs.openSync(this.localFile, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
fs.writeSync(file.fd, icon.buffer);
fs.fsyncSync(file.fd);
fs.closeSync(file);
}
build() {
Scroll(this.scroller) {
Column() {
Text($r('app.string.local_r_file'))
.fontSize(30)
.fontWeight(FontWeight.Bold)
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $r('app.media.startIcon'),
objectFit: ImageFit.Contain
}
}).width(100).height(100)
Text($r('app.string.local_rawfile'))
.fontSize(30)
.fontWeight(FontWeight.Bold)
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $rawfile('image/startIcon.png'),
objectFit: ImageFit.Contain
}
}).width(100).height(100)
Text($r('app.string.Under_context_file'))
.fontSize(30)
.fontWeight(FontWeight.Bold)
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: this.localFile,
objectFit: ImageFit.Contain
}
}).width(100).height(100)
Text($r('app.string.local_other_module'))
.fontSize(30)
.fontWeight(FontWeight.Bold)
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $r('[sharedlibrary].media.startIcon'),
objectFit: ImageFit.Contain
}
}).width(100).height(100)
}
.width('100%')
}
.height('100%')
}
}

View File

@ -21,15 +21,19 @@ struct LongImagePage {
build() { build() {
Scroll() { Scroll() {
// Image("https://wx2.sinaimg.cn/mw690/006HyQKGgy1hnqp08dw09j30u04twu0x.jpg").objectFit(ImageFit.Auto).height(300) // Image('https://wx2.sinaimg.cn/mw690/006HyQKGgy1hnqp08dw09j30u04twu0x.jpg').objectFit(ImageFit.Auto).height(300)
// Image($r("app.media.aaa")).objectFit(ImageFit.Auto).width(200) // Image($r('app.media.aaa')).objectFit(ImageFit.Auto).width(200)
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc:"https://wx2.sinaimg.cn/mw690/006HyQKGgy1hnqp08dw09j30u04twu0x.jpg", loadSrc:'https://wx2.sinaimg.cn/mw690/006HyQKGgy1hnqp08dw09j30u04twu0x.jpg',
//src:$r("app.media.aaa"), //src:$r('app.media.aaa'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.failed"), errorholderSrc: $r('app.media.failed'),
httpOption: {
connectTimeout: 60000,
readTimeout: 60000
},
objectFit: ImageFit.Auto objectFit: ImageFit.Auto
} }
}) })

File diff suppressed because it is too large Load Diff

View File

@ -36,20 +36,20 @@ struct MaxRequest1 {
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: item, loadSrc: item,
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.failed"), errorholderSrc: $r('app.media.failed'),
} }
}).width("50%").height(160) }).width('50%').height(160)
} }
}.height(200) }.height(200)
.backgroundColor("#95efd2") .backgroundColor('#95efd2')
},(item: string) => item) },(item: string) => item)
}.columnsTemplate("1fr 1fr") }.columnsTemplate('1fr 1fr')
.cachedCount(8) .cachedCount(8)
.columnsGap(10) .columnsGap(10)
.rowsGap(5) .rowsGap(5)
.backgroundColor(0xFAEEE0) .backgroundColor(0xFAEEE0)
.width("100%").height("100%") .width('100%').height('100%')
} }
} }
} }

View File

@ -36,20 +36,20 @@ struct MaxRequest2 {
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: item, loadSrc: item,
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.failed"), errorholderSrc: $r('app.media.failed'),
} }
}).width("50%").height(160) }).width('50%').height(160)
} }
}.height(200) }.height(200)
.backgroundColor("#95efd2") .backgroundColor('#95efd2')
},(item: string) => item) },(item: string) => item)
}.columnsTemplate("1fr 1fr") }.columnsTemplate('1fr 1fr')
.cachedCount(20) .cachedCount(20)
.columnsGap(10) .columnsGap(10)
.rowsGap(5) .rowsGap(5)
.backgroundColor(0xFAEEE0) .backgroundColor(0xFAEEE0)
.width("100%").height("100%") .width('100%').height('100%')
} }
} }
} }

View File

@ -36,20 +36,20 @@ struct MaxRequest3 {
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: item, loadSrc: item,
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.failed"), errorholderSrc: $r('app.media.failed'),
} }
}).width("50%").height(160) }).width('50%').height(160)
} }
}.height(200) }.height(200)
.backgroundColor("#95efd2") .backgroundColor('#95efd2')
},(item: string) => item) },(item: string) => item)
}.columnsTemplate("1fr 1fr") }.columnsTemplate('1fr 1fr')
.cachedCount(40) .cachedCount(40)
.columnsGap(10) .columnsGap(10)
.rowsGap(5) .rowsGap(5)
.backgroundColor(0xFAEEE0) .backgroundColor(0xFAEEE0)
.width("100%").height("100%") .width('100%').height('100%')
} }
} }
} }

View File

@ -0,0 +1,151 @@
/*
* Copyright (C) 2024 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 { ImageKnifeComponent,ImageKnifeOption } from '@ohos/libraryimageknife';
import { CommonDataSource } from './model/CommonDataSource'
@Entry
@Component
struct MultipleImageCallBack {
@State hotCommendList: CommonDataSource<string> = new CommonDataSource<string>([])
@State componentIndex: number = 0
@State startIndex: number = 0
@State successIndex: number = 0
@State failIndex: number = 0
@State cancelJobIndex: number = 0
@State cancelLoadIndex: number = 0
@State memoryIndex: number = 0
@State fileCacheIndex: number = 0
@State netIndex: number = 0
@State checkText: string = ''
private data: Array<string> = []
aboutToAppear(): void {
for (let index = 0; index < 100; index++) {
this.data.push(`https://img-blog.csdn.net/20140514114029140?${index}`)
}
this.hotCommendList.addData(this.hotCommendList.totalCount(), this.data)
}
build() {
Column() {
Row() {
Column() {
Text('图片总数:' + this.componentIndex)
Text('开始回调:' + this.startIndex)
Text('成功回调:' + this.successIndex)
Text('失败回调:' + this.failIndex)
Text('队列取消回调:' + this.cancelJobIndex)
Text('加载取消回调:' + this.cancelLoadIndex)
Text('内存数量:' + this.memoryIndex)
Text('文件数量:' + this.fileCacheIndex)
Text('网络数量:' + this.netIndex)
}.width('50%')
Column() {
Button('check')
.onClick(()=>{
this.checkText = ''
if (this.componentIndex !== this.startIndex + this.cancelJobIndex) {
this.checkText = this.checkText + '图片总数!=开始+队列取消,'
}
if(this.startIndex !== this.successIndex + this.failIndex + this.cancelLoadIndex) {
this.checkText = this.checkText + '开始回调!=成功+失败+加载取消,'
}
if(this.successIndex !== this.memoryIndex + this.fileCacheIndex + this.netIndex) {
this.checkText = this.checkText + '成功回调!=内存+文件+网络,'
}
if(this.componentIndex !== this.successIndex + this.failIndex + this.cancelJobIndex + this.cancelLoadIndex) {
this.checkText = this.checkText + '图片总数!=成功+失败+加载取消+队列取消,'
}
if(this.checkText == '') {
this.checkText = 'check正确'
}
})
Text(this.checkText)
}.width('50%')
}.width('100%')
Column() {
WaterFlow() {
LazyForEach(this.hotCommendList, (item: string,index: number) => {
FlowItem() {
Column() {
Text(index + '')
ImageComponent({
imageKnifeOption: {
loadSrc: item,
placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r('app.media.failed'),
onLoadListener: {
onLoadStart:()=>{
this.startIndex++
console.log('image load multiple loadStart:' + this.startIndex)
},
onLoadSuccess:(pixelmap,imageData,request)=>{
this.successIndex++
let memory = request?.imageKnifeData?.timeInfo?.memoryCheckEndTime ? 1 : 0
let fileCache = request?.imageKnifeData?.timeInfo?.diskCheckEndTime ? 1 : 0
let net = request?.imageKnifeData?.timeInfo?.netRequestEndTime ? 1 : 0
memory = memory - fileCache
fileCache = fileCache - net
this.memoryIndex = this.memoryIndex + memory
this.fileCacheIndex = this.fileCacheIndex + fileCache
this.netIndex = this.netIndex + net
console.log('image load multiple loadSuccess:' + this.successIndex)
},
onLoadFailed:()=>{
this.failIndex++
console.log('image load multiple loadFail:' + this.failIndex)
},
onLoadCancel:(message,request)=>{
let flag = request?.imageKnifeData?.timeInfo?.netRequestStartTime ? true : false
if (flag) {
this.cancelLoadIndex++
} else {
this.cancelJobIndex++
}
console.log('image load multiple cancelJobIndex:' + this.cancelJobIndex,'cancelLoadIndex' + this.cancelLoadIndex)
}
}
},index:this.componentIndex
}).width('50%').height(160)
}
}.height(200)
.backgroundColor('#95efd2')
}, (item: string) => item)
}
.cachedCount(0)
.columnsTemplate('1fr 1fr')
.columnsGap(10)
.rowsGap(5)
.backgroundColor(0xFAEEE0)
.width('100%')
}
.height('80%')
}.width('100%')
.height('100%')
}
}
@Component
struct ImageComponent {
@State imageKnifeOption: ImageKnifeOption = new ImageKnifeOption()
@Link index: number
aboutToAppear(): void {
this.index++
}
build() {
ImageKnifeComponent({
imageKnifeOption: this.imageKnifeOption
})
}
}

View File

@ -18,9 +18,9 @@ import { ImageKnife, ImageKnifeComponent, ImageKnifeOption } from '@ohos/library
@Component @Component
struct ObjectFitPage { struct ObjectFitPage {
@State imageKnifeOption: ImageKnifeOption = { @State imageKnifeOption: ImageKnifeOption = {
loadSrc: $r("app.media.app_icon"), loadSrc: $r('app.media.app_icon'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Fill objectFit: ImageFit.Fill
} }
@ -29,9 +29,9 @@ struct ObjectFitPage {
Button($r('app.string.Main_image_Fill')).onClick(()=>{ Button($r('app.string.Main_image_Fill')).onClick(()=>{
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: $r("app.media.app_icon"), loadSrc: $r('app.media.app_icon'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Fill objectFit: ImageFit.Fill
} }
}) })
@ -41,9 +41,9 @@ struct ObjectFitPage {
await ImageKnife.getInstance().removeAllFileCache() await ImageKnife.getInstance().removeAllFileCache()
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: "https://wx2.sinaimg.cn/mw690/006HyQKGgy1hnqp08dw09j30u04twu0x.jpg", loadSrc: 'https://wx2.sinaimg.cn/mw690/006HyQKGgy1hnqp08dw09j30u04twu0x.jpg',
placeholderSrc: $r("app.media.app_icon"), placeholderSrc: $r('app.media.app_icon'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Fill, objectFit: ImageFit.Fill,
placeholderObjectFit: ImageFit.Contain placeholderObjectFit: ImageFit.Contain
} }
@ -52,9 +52,9 @@ struct ObjectFitPage {
Button($r('app.string.Error_graph_None')).margin({top:10}).onClick(() => { Button($r('app.string.Error_graph_None')).margin({top:10}).onClick(() => {
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: "http://xxxxx", loadSrc: 'http://xxxxx',
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Fill, objectFit: ImageFit.Fill,
errorholderObjectFit: ImageFit.None errorholderObjectFit: ImageFit.None
} }

View File

@ -19,21 +19,21 @@ import { router } from '@kit.ArkUI'
struct PrefetchAndCacheCount { struct PrefetchAndCacheCount {
build() { build() {
Column() { Column() {
Button("cacheCount == 5") Button('cacheCount == 5')
.onClick(()=>{ .onClick(()=>{
router.pushUrl({url:"pages/LazyForEachCache"}) router.pushUrl({url:'pages/LazyForEachCache'})
}) })
Button("cacheCount == 30") Button('cacheCount == 30')
.margin({top:10}) .margin({top:10})
.onClick(()=>{ .onClick(()=>{
router.pushUrl({url:"pages/LazyForEachCount"}) router.pushUrl({url:'pages/LazyForEachCount'})
}) })
Button("prefetch + preload") Button('prefetch + preload')
.margin({top:10}) .margin({top:10})
.onClick(()=>{ .onClick(()=>{
router.pushUrl({url:"pages/PrefetchAndPreload"}) router.pushUrl({url:'pages/PrefetchAndPreload'})
}) })
}.width("100%") }.width('100%')
.height("100%") .height('100%')
} }
} }

View File

@ -37,7 +37,7 @@ export struct PrefetchAndPreload {
} }
}).width(100).height(100) }).width(100).height(100)
Text(`${index}`) Text(`${index}`)
}.border({ width: 5 , color: "#000000"}) }.border({ width: 5 , color: '#000000'})
} }
.reuseId('imageKnife') .reuseId('imageKnife')
}) })
@ -47,8 +47,8 @@ export struct PrefetchAndPreload {
// 列表滚动触发visibleAreaChanged实时更新预取范围触发调用prefetch、cancel接口 // 列表滚动触发visibleAreaChanged实时更新预取范围触发调用prefetch、cancel接口
this.prefetcher.visibleAreaChanged(start, end) this.prefetcher.visibleAreaChanged(start, end)
}) })
.width("100%") .width('100%')
.height("100%") .height('100%')
.margin({ left: 10, right: 10 }) .margin({ left: 10, right: 10 })
.layoutWeight(1) .layoutWeight(1)
} }

View File

@ -1,3 +1,17 @@
/*
* Copyright (C) 2024 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 '@kit.ArkUI' import { router } from '@kit.ArkUI'
@Entry @Entry
@ -5,19 +19,19 @@ import { router } from '@kit.ArkUI'
struct SetMaxRequestPage { struct SetMaxRequestPage {
build() { build() {
Column() { Column() {
Button("maxRequest = 8") Button('maxRequest = 8')
.onClick(()=>{ .onClick(()=>{
router.pushUrl({url:"pages/MaxRequest1"}) router.pushUrl({url:'pages/MaxRequest1'})
}) })
Button("maxRequest = 20") Button('maxRequest = 20')
.onClick(()=>{ .onClick(()=>{
router.pushUrl({url:"pages/MaxRequest2"}) router.pushUrl({url:'pages/MaxRequest2'})
}).margin({top:20}) }).margin({top:20})
Button("maxRequest = 32") Button('maxRequest = 32')
.onClick(()=>{ .onClick(()=>{
router.pushUrl({url:"pages/MaxRequest2"}) router.pushUrl({url:'pages/MaxRequest2'})
}).margin({top:20}) }).margin({top:20})
}.width("100%") }.width('100%')
.height("100%") .height('100%')
} }
} }

View File

@ -1,13 +1,13 @@
/* /*
* Copyright (C) 2024 Huawei Device Co., Ltd. * Copyright (C) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
@ -21,12 +21,12 @@ struct SignatureTestPage {
@State imageKnifeOption1: ImageKnifeOption = @State imageKnifeOption1: ImageKnifeOption =
{ {
loadSrc: $r('app.media.icon'), loadSrc: $r('app.media.icon'),
placeholderSrc:$r("app.media.loading"), placeholderSrc:$r('app.media.loading'),
}; };
@State imageKnifeOption2: ImageKnifeOption = @State imageKnifeOption2: ImageKnifeOption =
{ {
loadSrc: $r('app.media.icon'), loadSrc: $r('app.media.icon'),
placeholderSrc:$r("app.media.loading"), placeholderSrc:$r('app.media.loading'),
}; };
build() { build() {
@ -39,8 +39,8 @@ struct SignatureTestPage {
.onClick(() => { .onClick(() => {
this.imageKnifeOption1 = { this.imageKnifeOption1 = {
loadSrc: 'https://img-blog.csdn.net/20140514114029140', loadSrc: 'https://img-blog.csdn.net/20140514114029140',
placeholderSrc:$r("app.media.loading"), placeholderSrc:$r('app.media.loading'),
signature: "1" signature: '1'
} }
}).margin({ top: 5, left: 3 }) }).margin({ top: 5, left: 3 })
ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }).width(300).height(300) ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }).width(300).height(300)
@ -52,7 +52,7 @@ struct SignatureTestPage {
.onClick(() => { .onClick(() => {
this.imageKnifeOption2 = { this.imageKnifeOption2 = {
loadSrc: 'https://img-blog.csdn.net/20140514114029140', loadSrc: 'https://img-blog.csdn.net/20140514114029140',
placeholderSrc:$r("app.media.loading"), placeholderSrc:$r('app.media.loading'),
signature: new Date().getTime().toString() signature: new Date().getTime().toString()
} }
}).margin({ top: 5, left: 3 }) }).margin({ top: 5, left: 3 })
@ -66,7 +66,7 @@ struct SignatureTestPage {
} }
aboutToAppear() { aboutToAppear() {
console.log("唯一标识页面:" + new Date().getTime().toString()) console.log('唯一标识页面:' + new Date().getTime().toString())
} }
} }

View File

@ -20,20 +20,20 @@ import { common2D, drawing } from '@kit.ArkGraphics2D';
@Entry @Entry
@Component @Component
struct SingleImage { struct SingleImage {
resource: string = "app.media.svgSample" resource: string = 'app.media.svgSample'
scroller: Scroller = new Scroller; scroller: Scroller = new Scroller;
localFile: string = getContext(this).filesDir + "/icon.png" localFile: string = getContext(this).filesDir + '/icon.png'
@State pixelMap:PixelMap | undefined = undefined; @State pixelMap:PixelMap | undefined = undefined;
@State DrawingColorFilter: ColorFilter | undefined = undefined @State DrawingColorFilter: ColorFilter | undefined = undefined
private color: common2D.Color = { alpha: 255, red: 255, green: 0, blue: 0 }; private color: common2D.Color = { alpha: 255, red: 255, green: 0, blue: 0 };
aboutToAppear(): void { aboutToAppear(): void {
// 拷贝本地文件 // 拷贝本地文件
let icon: Uint8Array = getContext(this).resourceManager.getMediaContentSync($r("app.media.startIcon")); let icon: Uint8Array = getContext(this).resourceManager.getMediaContentSync($r('app.media.startIcon'));
let file = fs.openSync(this.localFile, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE); let file = fs.openSync(this.localFile, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
fs.writeSync(file.fd, icon.buffer); fs.writeSync(file.fd, icon.buffer);
fs.fsyncSync(file.fd); fs.fsyncSync(file.fd);
fs.closeSync(file); fs.closeSync(file);
this.changePic(getContext().resourceManager.getMediaContentSync( $r("app.media.aaa")) this.changePic(getContext().resourceManager.getMediaContentSync( $r('app.media.aaa'))
.buffer as ArrayBuffer); .buffer as ArrayBuffer);
@ -47,23 +47,31 @@ struct SingleImage {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: $r("app.media.svgSample"), loadSrc: $r(this.resource),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.failed"), errorholderSrc: $r('app.media.failed'),
objectFit: ImageFit.Contain objectFit: ImageFit.Contain
} }
}).width(100).height(100) }).width(100).height(100)
.onClick(()=>{ .onClick(()=>{
this.DrawingColorFilter = drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN); this.DrawingColorFilter = drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN);
}) })
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $r('[sharedlibrary].media.pngSample'),
placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r('app.media.failed'),
objectFit: ImageFit.Contain
}
}).width(100).height(100)
Text($r('app.string.Under_context_file')) Text($r('app.string.Under_context_file'))
.fontSize(30) .fontSize(30)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: this.localFile, loadSrc: this.localFile,
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.failed"), errorholderSrc: $r('app.media.failed'),
objectFit: ImageFit.Contain objectFit: ImageFit.Contain
} }
}).width(100).height(100) }).width(100).height(100)
@ -72,13 +80,13 @@ struct SingleImage {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc:"https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png", loadSrc:'https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png',
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.failed"), errorholderSrc: $r('app.media.failed'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
progressListener:(progress:number)=>{console.info("ImageKnife:: call back progress = " + progress)}, progressListener:(progress:number)=>{console.info('ImageKnife:: call back progress = ' + progress)},
// 通过https协议进行连接时默认使用系统预设CA证书。若希望使用自定义证书进行https连接则需要将自定义证书上传至应用沙箱目录中并在caPath中指定该证书所在的应用沙箱路径 // 通过https协议进行连接时默认使用系统预设CA证书。若希望使用自定义证书进行https连接则需要将自定义证书上传至应用沙箱目录中并在caPath中指定该证书所在的应用沙箱路径
// caPath: "/data/storage/el1/bundle/ca.pem", // caPath: '/data/storage/el1/bundle/ca.pem',
} }
}).width(100).height(100) }).width(100).height(100)
Text($r('app.string.Custom_network_download')) Text($r('app.string.Custom_network_download'))
@ -86,13 +94,13 @@ struct SingleImage {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: "https://file.atomgit.com/uploads/user/1704857786989_8994.jpeg", loadSrc: 'https://file.atomgit.com/uploads/user/1704857786989_8994.jpeg',
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.failed"), errorholderSrc: $r('app.media.failed'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
headerOption:[{ headerOption:[{
key:"refer", key:'refer',
value:"xx.xx.xx.xx" value:'xx.xx.xx.xx'
}], }],
customGetImage: custom, customGetImage: custom,
transformation: new BlurTransformation(10) transformation: new BlurTransformation(10)
@ -104,8 +112,8 @@ struct SingleImage {
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: this.pixelMap!, loadSrc: this.pixelMap!,
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.failed"), errorholderSrc: $r('app.media.failed'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
} }
}).width(100).height(100) }).width(100).height(100)
@ -122,6 +130,7 @@ struct SingleImage {
editable: true, editable: true,
} }
imageSource.createPixelMap(decodingOptions,(err,pixelMap)=>{ imageSource.createPixelMap(decodingOptions,(err,pixelMap)=>{
imageSource.release()
this.pixelMap = pixelMap; this.pixelMap = pixelMap;
}) })
} }
@ -131,10 +140,10 @@ struct SingleImage {
// 自定义下载方法 // 自定义下载方法
@Concurrent @Concurrent
async function custom(context: Context, src: string | PixelMap | Resource,headers?: Record<string,Object>): Promise<ArrayBuffer | undefined> { async function custom(context: Context, src: string | PixelMap | Resource,headers?: Record<string,Object>): Promise<ArrayBuffer | undefined> {
let refer = headers!["refer"] as string let refer = headers!['refer'] as string
console.info("ImageKnife:: custom download" + src,"refer:"+refer) console.info('ImageKnife:: custom download' + src,'refer:'+refer)
// 举例写死从本地文件读取,也可以自己请求网络图片 // 举例写死从本地文件读取,也可以自己请求网络图片
let buffer = context.resourceManager.getMediaContentSync($r("app.media.startIcon").id).buffer as ArrayBuffer let buffer = context.resourceManager.getMediaContentSync($r('app.media.startIcon').id).buffer as ArrayBuffer
return buffer return buffer
} }

View File

@ -0,0 +1,126 @@
/*
* Copyright (C) 2024 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 { ImageKnifeComponent,ImageKnifeOption } from '@ohos/libraryimageknife';
import { CommonDataSource } from './model/CommonDataSource'
@Entry
@Component
struct SingleImageCallBack {
@State hotCommendList: CommonDataSource<string> = new CommonDataSource<string>([])
@State componentIndex: number = 0
@State startIndex: number = 0
@State successIndex: number = 0
@State failIndex: number = 0
@State cancelJobIndex: number = 0
@State cancelLoadIndex: number = 0
@State memoryIndex: number = 0
@State fileCacheIndex: number = 0
@State netIndex: number = 0
@State checkText: string = ''
build() {
Column() {
Row() {
Column() {
Text('图片总数:' + this.componentIndex)
Text('开始回调:' + this.startIndex)
Text('成功回调:' + this.successIndex)
Text('失败回调:' + this.failIndex)
Text('队列取消回调:' + this.cancelJobIndex)
Text('加载取消回调:' + this.cancelLoadIndex)
Text('内存数量:' + this.memoryIndex)
Text('文件数量:' + this.fileCacheIndex)
Text('网络数量:' + this.netIndex)
}.width('50%')
Column() {
Button('check')
.onClick(()=>{
this.checkText = ''
if (this.componentIndex !== this.startIndex + this.cancelJobIndex) {
this.checkText = this.checkText + '图片总数!=开始+队列取消,'
}
if(this.startIndex !== this.successIndex + this.failIndex + this.cancelLoadIndex) {
this.checkText = this.checkText + '开始回调!=成功+失败+加载取消,'
}
if(this.successIndex !== this.memoryIndex + this.fileCacheIndex + this.netIndex) {
this.checkText = this.checkText + '成功回调!=内存+文件+网络,'
}
if(this.componentIndex !== this.successIndex + this.failIndex + this.cancelJobIndex + this.cancelLoadIndex) {
this.checkText = this.checkText + '图片总数!=成功+失败+加载取消+队列取消,'
}
if(this.checkText == '') {
this.checkText = 'check正确'
}
})
Text(this.checkText)
}.width('50%')
}.width('100%')
Column() {
ImageComponent({
imageKnifeOption: {
loadSrc: 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r('app.media.failed'),
onLoadListener: {
onLoadStart: () => {
this.startIndex++
console.log('image load multiple loadStart:' + this.startIndex)
},
onLoadSuccess: (pixelmap, imageData, request) => {
this.successIndex++
let memory = request?.imageKnifeData?.timeInfo?.memoryCheckEndTime ? 1 : 0
let fileCache = request?.imageKnifeData?.timeInfo?.diskCheckEndTime ? 1 : 0
let net = request?.imageKnifeData?.timeInfo?.netRequestEndTime ? 1 : 0
memory = memory - fileCache
fileCache = fileCache - net
this.memoryIndex = this.memoryIndex + memory
this.fileCacheIndex = this.fileCacheIndex + fileCache
this.netIndex = this.netIndex + net
console.log('image load multiple loadSuccess:' + this.successIndex)
},
onLoadFailed: () => {
this.failIndex++
console.log('image load multiple loadFail:' + this.failIndex)
},
onLoadCancel: (message,request) => {
let flag = request?.imageKnifeData?.type ? true : false
if (flag) {
this.cancelLoadIndex++
} else {
this.cancelJobIndex++
}
console.log('image load multiple cancelJobIndex:' + this.cancelJobIndex,'cancelLoadIndex' + this.cancelLoadIndex)
}
}
},index:this.componentIndex
}).width(300).height(300)
}
.height('80%')
}.width('100%')
.height('100%')
}
}
@Component
struct ImageComponent {
@State imageKnifeOption: ImageKnifeOption = new ImageKnifeOption()
@Link index: number
aboutToAppear(): void {
this.index++
}
build() {
ImageKnifeComponent({
imageKnifeOption: this.imageKnifeOption
})
}
}

View File

@ -27,11 +27,11 @@ struct TestCacheDataPage {
@State markersNumText: string = getContext(this).resourceManager.getStringSync($r('app.string.memory')) @State markersNumText: string = getContext(this).resourceManager.getStringSync($r('app.string.memory'))
@State markersSizeText: string = getContext(this).resourceManager.getStringSync($r('app.string.memory')) @State markersSizeText: string = getContext(this).resourceManager.getStringSync($r('app.string.memory'))
@State ImageKnifeOption: ImageKnifeOption = { @State ImageKnifeOption: ImageKnifeOption = {
loadSrc: "", loadSrc: '',
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
onLoadListener: { onLoadListener: {
onLoadFailed: (err) => { onLoadFailed: (err) => {
console.error("Load Failed Reason: " + err); console.error('Load Failed Reason: ' + err);
}, },
onLoadSuccess: (data) => { onLoadSuccess: (data) => {
return data; return data;
@ -41,7 +41,7 @@ struct TestCacheDataPage {
} }
aboutToAppear(): void { aboutToAppear(): void {
ImageKnife.getInstance().initFileCache(getContext(this), 256, 256 * 1024 * 1024, "ImageKnifeCache1") ImageKnife.getInstance().initFileCache(getContext(this), 256, 256 * 1024 * 1024, 'ImageKnifeCache1')
} }
build() { build() {
@ -56,7 +56,7 @@ struct TestCacheDataPage {
Button($r('app.string.load_memory')) Button($r('app.string.load_memory'))
.onClick(() => { .onClick(() => {
this.ImageKnifeOption = { this.ImageKnifeOption = {
loadSrc: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg", loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg',
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
writeCacheStrategy: CacheStrategy.Memory, writeCacheStrategy: CacheStrategy.Memory,
border: { radius: 50 }, border: { radius: 50 },
@ -65,7 +65,7 @@ struct TestCacheDataPage {
Button($r('app.string.load_disk')) Button($r('app.string.load_disk'))
.onClick(() => { .onClick(() => {
this.ImageKnifeOption = { this.ImageKnifeOption = {
loadSrc: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg", loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg',
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
writeCacheStrategy: CacheStrategy.File, writeCacheStrategy: CacheStrategy.File,
border: { radius: 50 }, border: { radius: 50 },

View File

@ -102,7 +102,7 @@ struct TestChangeColorPage {
Text($r('app.string.test_svg_color')).margin({ top: 30 }) Text($r('app.string.test_svg_color')).margin({ top: 30 })
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: $r("app.media.ic_test_change_color_svg"), loadSrc: $r('app.media.ic_test_change_color_svg'),
drawingColorFilter: drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN) drawingColorFilter: drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN)
} }
}).width(110).height(110) }).width(110).height(110)

View File

@ -32,21 +32,21 @@ struct TestCommonImage {
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: item, loadSrc: item,
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.failed"), errorholderSrc: $r('app.media.failed'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
signature: "aaa" signature: 'aaa'
} }
}).width("50%").height(200) }).width('50%').height(200)
} }
}.height(200) }.height(200)
.backgroundColor("#95efd2") .backgroundColor('#95efd2')
},(item: string) => item) },(item: string) => item)
}.columnsTemplate("1fr 1fr") }.columnsTemplate('1fr 1fr')
.columnsGap(10) .columnsGap(10)
.rowsGap(5) .rowsGap(5)
.backgroundColor(0xFAEEE0) .backgroundColor(0xFAEEE0)
.width("100%").height("100%") .width('100%').height('100%')
} }
} }
} }

View File

@ -20,24 +20,24 @@ struct TestErrorHolderPage {
build() { build() {
Column() { Column() {
Text("ImageKnifeComponent1").fontSize(20) Text('ImageKnifeComponent1').fontSize(20)
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: "abc", loadSrc: 'abc',
errorholderSrc:$r('app.media.failed') errorholderSrc:$r('app.media.failed')
} }
}).width(200).height(200) }).width(200).height(200)
Text("ImageKnifeComponent2").fontSize(20) Text('ImageKnifeComponent2').fontSize(20)
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: "abc", loadSrc: 'abc',
errorholderSrc:$r('app.media.startIcon') errorholderSrc:$r('app.media.startIcon')
} }
}).width(200).height(200) }).width(200).height(200)
Text("ImageKnifeComponent2").fontSize(20) Text('ImageKnifeComponent2').fontSize(20)
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: { imageKnifeOption: {
loadSrc: "abc", loadSrc: 'abc',
errorholderSrc:$r('app.media.mask_starfish') errorholderSrc:$r('app.media.mask_starfish')
} }
}).width(200).height(200) }).width(200).height(200)

View File

@ -18,12 +18,12 @@ import { ImageKnifeComponent,ImageKnifeOption } from '@ohos/libraryimageknife'
@Component @Component
struct TestPrefetchToFileCachePage { struct TestPrefetchToFileCachePage {
@State imageKnifeOption: ImageKnifeOption = { @State imageKnifeOption: ImageKnifeOption = {
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658", loadSrc:'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658',
placeholderSrc:$r('app.media.loading'), placeholderSrc:$r('app.media.loading'),
headerOption:[ headerOption:[
{ {
key:"abc", key:'abc',
value:"单个" value:'单个'
} }
] ]
} }

View File

@ -12,14 +12,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { IndexComponent } from "@ohos/libraryimageknife" import { IndexComponent } from '@ohos/libraryimageknife'
@Entry @Entry
@Component @Component
struct TestHspPreLoadImage { struct TestHspPreLoadImage {
build() { build() {
Column() { Column() {
IndexComponent() IndexComponent()
}.width("100%").height('100%') }.width('100%').height('100%')
} }
} }

View File

@ -0,0 +1,92 @@
/*
* Copyright (C) 2025 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 { ImageKnifeComponent } from '@ohos/libraryimageknife';
import fs from '@ohos.file.fs';
@Entry
@Component
struct LocalImage {
scroller: Scroller = new Scroller;
build() {
Scroll(this.scroller) {
Column() {
Column() {
Text($r('app.string.base_image'))
.fontSize(20)
.fontWeight(FontWeight.Bold)
Row() {
Image($rawfile('rotate/rotate.jpg')).width(100).height(100).margin({ right: 10 })
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $rawfile('rotate/rotate.jpg'),
objectFit: ImageFit.Contain
}
}).width(100).height(100)
}
}
.margin({ bottom: 20 })
Column() {
Text($r('app.string.rotate_mirror'))
.fontSize(20)
.fontWeight(FontWeight.Bold)
Row() {
Image($rawfile('rotate/rotate_mirror.jpg')).width(100).height(100).margin({ right: 10 })
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $rawfile('rotate/rotate_mirror.jpg'),
objectFit: ImageFit.Contain
}
}).width(100).height(100)
}
}.margin({ bottom: 20 })
Column() {
Text($r('app.string.rotate_rotate90'))
.fontSize(20)
.fontWeight(FontWeight.Bold)
Row() {
Image($rawfile('rotate/rotate_rotate90.jpg')).width(100).height(100).margin({ right: 10 })
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $rawfile('rotate/rotate_rotate90.jpg'),
objectFit: ImageFit.Contain
}
}).width(100).height(100)
}
}.margin({ bottom: 20 })
Column() {
Text($r('app.string.rotate_mirror_rotate270'))
.fontSize(20)
.fontWeight(FontWeight.Bold)
Row() {
Image($rawfile('rotate/rotate_mirror_rotate270.jpg')).width(100).height(100).margin({ right: 10 })
ImageKnifeComponent({
imageKnifeOption: {
loadSrc: $rawfile('rotate/rotate_mirror_rotate270.jpg'),
objectFit: ImageFit.Contain
}
}).width(100).height(100)
}
}
}
.width('100%')
}
.height('100%')
}
}

View File

@ -35,47 +35,47 @@ export class MsgModel {
export struct MsgItem { export struct MsgItem {
count: number = 0 count: number = 0
private data: Array<string> = [ private data: Array<string> = [
"http://e.hiphotos.baidu.com/image/pic/item/a1ec08fa513d2697e542494057fbb2fb4316d81e.jpg", 'http://e.hiphotos.baidu.com/image/pic/item/a1ec08fa513d2697e542494057fbb2fb4316d81e.jpg',
"http://c.hiphotos.baidu.com/image/pic/item/30adcbef76094b36de8a2fe5a1cc7cd98d109d99.jpg", 'http://c.hiphotos.baidu.com/image/pic/item/30adcbef76094b36de8a2fe5a1cc7cd98d109d99.jpg',
"http://h.hiphotos.baidu.com/image/pic/item/7c1ed21b0ef41bd5f2c2a9e953da81cb39db3d1d.jpg", 'http://h.hiphotos.baidu.com/image/pic/item/7c1ed21b0ef41bd5f2c2a9e953da81cb39db3d1d.jpg',
"http://g.hiphotos.baidu.com/image/pic/item/55e736d12f2eb938d5277fd5d0628535e5dd6f4a.jpg", 'http://g.hiphotos.baidu.com/image/pic/item/55e736d12f2eb938d5277fd5d0628535e5dd6f4a.jpg',
"http://e.hiphotos.baidu.com/image/pic/item/4e4a20a4462309f7e41f5cfe760e0cf3d6cad6ee.jpg", 'http://e.hiphotos.baidu.com/image/pic/item/4e4a20a4462309f7e41f5cfe760e0cf3d6cad6ee.jpg',
"http://b.hiphotos.baidu.com/image/pic/item/9d82d158ccbf6c81b94575cfb93eb13533fa40a2.jpg", 'http://b.hiphotos.baidu.com/image/pic/item/9d82d158ccbf6c81b94575cfb93eb13533fa40a2.jpg',
"http://e.hiphotos.baidu.com/image/pic/item/4bed2e738bd4b31c1badd5a685d6277f9e2ff81e.jpg", 'http://e.hiphotos.baidu.com/image/pic/item/4bed2e738bd4b31c1badd5a685d6277f9e2ff81e.jpg',
"http://g.hiphotos.baidu.com/image/pic/item/0d338744ebf81a4c87a3add4d52a6059252da61e.jpg", 'http://g.hiphotos.baidu.com/image/pic/item/0d338744ebf81a4c87a3add4d52a6059252da61e.jpg',
"http://a.hiphotos.baidu.com/image/pic/item/f2deb48f8c5494ee5080c8142ff5e0fe99257e19.jpg", 'http://a.hiphotos.baidu.com/image/pic/item/f2deb48f8c5494ee5080c8142ff5e0fe99257e19.jpg',
"http://f.hiphotos.baidu.com/image/pic/item/4034970a304e251f503521f5a586c9177e3e53f9.jpg", 'http://f.hiphotos.baidu.com/image/pic/item/4034970a304e251f503521f5a586c9177e3e53f9.jpg',
"http://b.hiphotos.baidu.com/image/pic/item/279759ee3d6d55fbb3586c0168224f4a20a4dd7e.jpg", 'http://b.hiphotos.baidu.com/image/pic/item/279759ee3d6d55fbb3586c0168224f4a20a4dd7e.jpg',
"http://img2.xkhouse.com/bbs/hfhouse/data/attachment/forum/corebbs/2009-11/2009113011534566298.jpg", 'http://img2.xkhouse.com/bbs/hfhouse/data/attachment/forum/corebbs/2009-11/2009113011534566298.jpg',
"http://a.hiphotos.baidu.com/image/pic/item/e824b899a9014c087eb617650e7b02087af4f464.jpg", 'http://a.hiphotos.baidu.com/image/pic/item/e824b899a9014c087eb617650e7b02087af4f464.jpg',
"http://c.hiphotos.baidu.com/image/pic/item/9c16fdfaaf51f3de1e296fa390eef01f3b29795a.jpg", 'http://c.hiphotos.baidu.com/image/pic/item/9c16fdfaaf51f3de1e296fa390eef01f3b29795a.jpg',
"http://d.hiphotos.baidu.com/image/pic/item/b58f8c5494eef01f119945cbe2fe9925bc317d2a.jpg", 'http://d.hiphotos.baidu.com/image/pic/item/b58f8c5494eef01f119945cbe2fe9925bc317d2a.jpg',
"http://h.hiphotos.baidu.com/image/pic/item/902397dda144ad340668b847d4a20cf430ad851e.jpg", 'http://h.hiphotos.baidu.com/image/pic/item/902397dda144ad340668b847d4a20cf430ad851e.jpg',
"http://b.hiphotos.baidu.com/image/pic/item/359b033b5bb5c9ea5c0e3c23d139b6003bf3b374.jpg", 'http://b.hiphotos.baidu.com/image/pic/item/359b033b5bb5c9ea5c0e3c23d139b6003bf3b374.jpg',
"http://a.hiphotos.baidu.com/image/pic/item/8d5494eef01f3a292d2472199d25bc315d607c7c.jpg", 'http://a.hiphotos.baidu.com/image/pic/item/8d5494eef01f3a292d2472199d25bc315d607c7c.jpg',
"http://b.hiphotos.baidu.com/image/pic/item/e824b899a9014c08878b2c4c0e7b02087af4f4a3.jpg", 'http://b.hiphotos.baidu.com/image/pic/item/e824b899a9014c08878b2c4c0e7b02087af4f4a3.jpg',
"http://g.hiphotos.baidu.com/image/pic/item/6d81800a19d8bc3e770bd00d868ba61ea9d345f2.jpg", 'http://g.hiphotos.baidu.com/image/pic/item/6d81800a19d8bc3e770bd00d868ba61ea9d345f2.jpg',
] ]
build(){ build(){
if (this.count % 2 == 0 && this.count <6){ if (this.count % 2 == 0 && this.count <6){
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption:{ imageKnifeOption:{
loadSrc:$r("app.media.startIcon"), loadSrc:$r('app.media.startIcon'),
placeholderSrc:$r("app.media.loading") placeholderSrc:$r('app.media.loading')
},syncLoad:true },syncLoad:true
}) })
}else if (this.count > 6 && this.count - 6 < this.data.length){ }else if (this.count > 6 && this.count - 6 < this.data.length){
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption:{ imageKnifeOption:{
loadSrc:this.data[this.count - 6], loadSrc:this.data[this.count - 6],
placeholderSrc:$r("app.media.loading") placeholderSrc:$r('app.media.loading')
},syncLoad:true },syncLoad:true
}) })
}else { }else {
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption:{ imageKnifeOption:{
loadSrc:$r("app.media.pngSample"), loadSrc:$r('app.media.pngSample'),
placeholderSrc:$r("app.media.loading") placeholderSrc:$r('app.media.loading')
},syncLoad:true },syncLoad:true
}) })
} }
@ -103,10 +103,10 @@ struct ImageTestPage {
build(){ build(){
Column(){ Column(){
Row(){ Row(){
Button("addItem").onClick(()=> { Button('addItem').onClick(()=> {
this.handAdd() this.handAdd()
}) })
Button("remove").onClick(()=> { Button('remove').onClick(()=> {
this.list.splice(0,1) this.list.splice(0,1)
}) })
} }

View File

@ -20,38 +20,38 @@ import { router } from '@kit.ArkUI';
@Component @Component
struct TestImageKnifeCallbackPage { struct TestImageKnifeCallbackPage {
@State imageKnifeOption: ImageKnifeOption = { @State imageKnifeOption: ImageKnifeOption = {
loadSrc: "", loadSrc: '',
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
border: { radius: 50 } border: { radius: 50 }
}; };
@State currentWidth: number = 200 @State currentWidth: number = 200
@State currentHeight: number = 200 @State currentHeight: number = 200
@State url: string | undefined = "" @State url: string | undefined = ''
@State imageType: string | undefined = "" @State imageType: string | undefined = ''
@State imageWidth: number | undefined = 0 @State imageWidth: number | undefined = 0
@State imageHeight: number | undefined = 0 @State imageHeight: number | undefined = 0
@State imageSize: number | undefined = 0 @State imageSize: number | undefined = 0
@State componentWidth: number | undefined = 0 @State componentWidth: number | undefined = 0
@State componentHeight: number | undefined = 0 @State componentHeight: number | undefined = 0
@State frameNum: number | undefined = 0 @State frameNum: number | undefined = 0
@State decodeSize: string | undefined = "" @State decodeSize: string | undefined = ''
@State err_msg: string | undefined = "" @State errMsg: string | undefined = ''
@State err_phase: string | undefined = "" @State errPhase: string | undefined = ''
@State err_code: number | undefined = 0 @State errCode: number | undefined = 0
@State http_code: number | undefined = 0 @State httpCode: number | undefined = 0
@State reqStartTime: string | undefined = "" @State reqStartTime: string | undefined = ''
@State reqEndTime: string | undefined = "" @State reqEndTime: string | undefined = ''
@State reqCancelTime: string | undefined = "" @State reqCancelTime: string | undefined = ''
@State memoryStartTime: string | undefined = "" @State memoryStartTime: string | undefined = ''
@State memoryEndTime: string | undefined = "" @State memoryEndTime: string | undefined = ''
@State diskStartTime: string | undefined = "" @State diskStartTime: string | undefined = ''
@State diskEndTime: string | undefined = "" @State diskEndTime: string | undefined = ''
@State netStartTime: string | undefined = "" @State netStartTime: string | undefined = ''
@State netEndTime: string | undefined = "" @State netEndTime: string | undefined = ''
@State decodeStartTime: string | undefined = "" @State decodeStartTime: string | undefined = ''
@State decodeEndTime: string | undefined = "" @State decodeEndTime: string | undefined = ''
@State renderTime: string | undefined = ""
@State showChild: boolean = true; @State showChild: boolean = true;
@State requestFrom: string = '';
build() { build() {
Column() { Column() {
@ -61,10 +61,10 @@ struct TestImageKnifeCallbackPage {
Text($r('app.string.componentWH', this.componentWidth, this.componentHeight)).fontSize(14) Text($r('app.string.componentWH', this.componentWidth, this.componentHeight)).fontSize(14)
Text($r('app.string.img_frame', this.frameNum)).fontSize(14) Text($r('app.string.img_frame', this.frameNum)).fontSize(14)
Text($r('app.string.img_content_size', this.decodeSize)).fontSize(14) Text($r('app.string.img_content_size', this.decodeSize)).fontSize(14)
Text($r('app.string.err_msg', this.err_msg)).fontSize(14) Text($r('app.string.err_msg', this.errMsg)).fontSize(14)
Text($r('app.string.err_phase', this.err_phase)).fontSize(14) Text($r('app.string.err_phase', this.errPhase)).fontSize(14)
Text($r('app.string.err_code', this.err_code)).fontSize(14) Text($r('app.string.err_code', this.errCode)).fontSize(14)
Text($r('app.string.http_code', this.http_code)).fontSize(14) Text($r('app.string.http_code', this.httpCode)).fontSize(14)
Text($r('app.string.req_start_time', this.reqStartTime)).fontSize(14) Text($r('app.string.req_start_time', this.reqStartTime)).fontSize(14)
Text($r('app.string.req_end_time', this.reqEndTime)).fontSize(14) Text($r('app.string.req_end_time', this.reqEndTime)).fontSize(14)
Text($r('app.string.req_cancel_time', this.reqCancelTime)).fontSize(14) Text($r('app.string.req_cancel_time', this.reqCancelTime)).fontSize(14)
@ -76,7 +76,7 @@ struct TestImageKnifeCallbackPage {
Text($r('app.string.net_end_time', this.netEndTime)).fontSize(14) Text($r('app.string.net_end_time', this.netEndTime)).fontSize(14)
Text($r('app.string.decode_start_time', this.decodeStartTime)).fontSize(14) Text($r('app.string.decode_start_time', this.decodeStartTime)).fontSize(14)
Text($r('app.string.decode_end_time', this.decodeEndTime)).fontSize(14) Text($r('app.string.decode_end_time', this.decodeEndTime)).fontSize(14)
Text($r('app.string.render_time', this.renderTime)).fontSize(14) Text($r('app.string.request_data_from', this.requestFrom)).fontSize(14)
Scroll() { Scroll() {
Column() { Column() {
@ -87,28 +87,23 @@ struct TestImageKnifeCallbackPage {
.onClick(() => { .onClick(() => {
this.destroy(); this.destroy();
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/10/v3/qaEzwkU0QeKb1yehnP2Xig/q7fxAlgMQKup-HUBayRLGQ.jpg", loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/10/v3/qaEzwkU0QeKb1yehnP2Xig/q7fxAlgMQKup-HUBayRLGQ.jpg',
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
onLoadListener: { onLoadListener: {
onLoadStart: (data) => { onLoadStart: (data) => {
this.analyzeStartCallBackData(data); this.analyzeStartCallBackData(data);
}, },
onLoadFailed: (res, req) => { onLoadFailed: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
}, },
onLoadSuccess: (data, imageData, req) => { onLoadSuccess: (data, imageData, req) => {
this.analyzeSuccessCallBackData(req?.getImageKnifeData()); this.analyzeSuccessCallBackData(req?.imageKnifeData);
}, },
onLoadCancel: (res, req) => { onLoadCancel: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
} }
}, },
border: { radius: 50 }, border: { radius: 50 },
onComplete: (event) => {
if (event && event.loadingStatus == 0) {
this.renderTime = this.formatDate(Date.now());
}
}
} }
}) })
@ -124,21 +119,16 @@ struct TestImageKnifeCallbackPage {
this.analyzeStartCallBackData(data); this.analyzeStartCallBackData(data);
}, },
onLoadFailed: (res, req) => { onLoadFailed: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
}, },
onLoadSuccess: (data, imageData, req) => { onLoadSuccess: (data, imageData, req) => {
this.analyzeSuccessCallBackData(req?.getImageKnifeData()); this.analyzeSuccessCallBackData(req?.imageKnifeData);
}, },
onLoadCancel: (res, req) => { onLoadCancel: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
} }
}, },
border: { radius: 50 }, border: { radius: 50 },
onComplete: (event) => {
if (event && event.loadingStatus == 0) {
this.renderTime = this.formatDate(Date.now());
}
}
} }
}) })
Button($r('app.string.local_pic')) Button($r('app.string.local_pic'))
@ -153,21 +143,16 @@ struct TestImageKnifeCallbackPage {
this.analyzeStartCallBackData(data); this.analyzeStartCallBackData(data);
}, },
onLoadFailed: (res, req) => { onLoadFailed: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
}, },
onLoadSuccess: (data, imageData, req) => { onLoadSuccess: (data, imageData, req) => {
this.analyzeSuccessCallBackData(req?.getImageKnifeData()); this.analyzeSuccessCallBackData(req?.imageKnifeData);
}, },
onLoadCancel: (res, req) => { onLoadCancel: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
} }
}, },
border: { radius: 50 }, border: { radius: 50 },
onComplete: (event) => {
if (event && event.loadingStatus == 0) {
this.renderTime = this.formatDate(Date.now());
}
}
} }
}) })
} }
@ -178,28 +163,23 @@ struct TestImageKnifeCallbackPage {
.onClick(() => { .onClick(() => {
this.destroy(); this.destroy();
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: "https://img-blog.csdn.net/20140514114039140", loadSrc: 'https://img-blog.csdn.net/20140514114039140',
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
onLoadListener: { onLoadListener: {
onLoadStart: (data) => { onLoadStart: (data) => {
this.analyzeStartCallBackData(data); this.analyzeStartCallBackData(data);
}, },
onLoadFailed: (res, req) => { onLoadFailed: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
}, },
onLoadSuccess: (data, imageData, req) => { onLoadSuccess: (data, imageData, req) => {
this.analyzeSuccessCallBackData(req?.getImageKnifeData()); this.analyzeSuccessCallBackData(req?.imageKnifeData);
}, },
onLoadCancel: (res, req) => { onLoadCancel: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
} }
}, },
border: { radius: 50 }, border: { radius: 50 },
onComplete: (event) => {
if (event && event.loadingStatus == 0) {
this.renderTime = this.formatDate(Date.now());
}
}
} }
}) })
@ -215,21 +195,16 @@ struct TestImageKnifeCallbackPage {
this.analyzeStartCallBackData(data); this.analyzeStartCallBackData(data);
}, },
onLoadFailed: (res, req) => { onLoadFailed: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
}, },
onLoadSuccess: (data, imageData, req) => { onLoadSuccess: (data, imageData, req) => {
this.analyzeSuccessCallBackData(req?.getImageKnifeData()); this.analyzeSuccessCallBackData(req?.imageKnifeData);
}, },
onLoadCancel: (res, req) => { onLoadCancel: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
} }
}, },
border: { radius: 50 }, border: { radius: 50 },
onComplete: (event) => {
if (event && event.loadingStatus == 0) {
this.renderTime = this.formatDate(Date.now());
}
}
} }
}) })
Button($r('app.string.share_load_failed')) Button($r('app.string.share_load_failed'))
@ -244,21 +219,16 @@ struct TestImageKnifeCallbackPage {
this.analyzeStartCallBackData(data); this.analyzeStartCallBackData(data);
}, },
onLoadFailed: (res, req) => { onLoadFailed: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
}, },
onLoadSuccess: (data, imageData, req) => { onLoadSuccess: (data, imageData, req) => {
this.analyzeSuccessCallBackData(req?.getImageKnifeData()); this.analyzeSuccessCallBackData(req?.imageKnifeData);
}, },
onLoadCancel: (res, req) => { onLoadCancel: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
} }
}, },
border: { radius: 50 }, border: { radius: 50 },
onComplete: (event) => {
if (event && event.loadingStatus == 0) {
this.renderTime = this.formatDate(Date.now());
}
}
} }
}) })
} }
@ -268,7 +238,7 @@ struct TestImageKnifeCallbackPage {
.onClick(() => { .onClick(() => {
this.destroy(); this.destroy();
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg", loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg',
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
onLoadListener: { onLoadListener: {
onLoadStart: (data) => { onLoadStart: (data) => {
@ -276,21 +246,16 @@ struct TestImageKnifeCallbackPage {
this.analyzeStartCallBackData(data); this.analyzeStartCallBackData(data);
}, },
onLoadFailed: (res, req) => { onLoadFailed: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
}, },
onLoadSuccess: (data, imageData, req) => { onLoadSuccess: (data, imageData, req) => {
this.analyzeSuccessCallBackData(req?.getImageKnifeData()); this.analyzeSuccessCallBackData(req?.imageKnifeData);
}, },
onLoadCancel: (res, req) => { onLoadCancel: (res, req) => {
this.analyzeFailedBackData(res, req?.getImageKnifeData()); this.analyzeFailedBackData(res, req?.imageKnifeData);
} }
}, },
border: { radius: 50 }, border: { radius: 50 },
onComplete: (event) => {
if (event && event.loadingStatus == 0) {
this.renderTime = this.formatDate(Date.now());
}
}
} }
}) })
@ -331,7 +296,7 @@ struct TestImageKnifeCallbackPage {
} }
analyzeStartCallBackData(req: ImageKnifeRequest | undefined) { analyzeStartCallBackData(req: ImageKnifeRequest | undefined) {
let data = req?.getImageKnifeData(); let data = req?.imageKnifeData;
if (data) { if (data) {
if (typeof req?.imageKnifeOption.loadSrc == 'string') { if (typeof req?.imageKnifeOption.loadSrc == 'string') {
this.url = req?.imageKnifeOption.loadSrc; this.url = req?.imageKnifeOption.loadSrc;
@ -341,6 +306,7 @@ struct TestImageKnifeCallbackPage {
this.reqStartTime = this.formatDate(data.timeInfo?.requestStartTime); this.reqStartTime = this.formatDate(data.timeInfo?.requestStartTime);
this.memoryStartTime = this.formatDate(data.timeInfo?.memoryCheckStartTime); this.memoryStartTime = this.formatDate(data.timeInfo?.memoryCheckStartTime);
this.memoryEndTime = this.formatDate(data.timeInfo?.memoryCheckEndTime); this.memoryEndTime = this.formatDate(data.timeInfo?.memoryCheckEndTime);
this.requestFrom = '';
} }
} }
@ -350,6 +316,7 @@ struct TestImageKnifeCallbackPage {
this.imageHeight = data.imageHeight; this.imageHeight = data.imageHeight;
this.imageSize = data.bufSize; this.imageSize = data.bufSize;
this.frameNum = data.frameCount; this.frameNum = data.frameCount;
this.httpCode = data.httpCode
this.decodeSize = JSON.stringify(data.decodeImages); this.decodeSize = JSON.stringify(data.decodeImages);
this.imageType = data.type; this.imageType = data.type;
this.reqEndTime = this.formatDate(data.timeInfo?.requestEndTime); this.reqEndTime = this.formatDate(data.timeInfo?.requestEndTime);
@ -359,15 +326,23 @@ struct TestImageKnifeCallbackPage {
this.netEndTime = this.formatDate(data.timeInfo?.netRequestEndTime); this.netEndTime = this.formatDate(data.timeInfo?.netRequestEndTime);
this.decodeStartTime = this.formatDate(data.timeInfo?.diskCheckStartTime); this.decodeStartTime = this.formatDate(data.timeInfo?.diskCheckStartTime);
this.decodeEndTime = this.formatDate(data.timeInfo?.diskCheckEndTime); this.decodeEndTime = this.formatDate(data.timeInfo?.diskCheckEndTime);
if (data.timeInfo?.netRequestEndTime !== undefined) {
this.requestFrom = 'Http request';
} else if (data.timeInfo?.diskCheckEndTime !== undefined) {
this.requestFrom = 'File Cache';
} else {
this.requestFrom = 'Memory Cache';
}
} }
} }
analyzeFailedBackData(res: string, data: ImageKnifeData | undefined) { analyzeFailedBackData(res: string, data: ImageKnifeData | undefined) {
if (data) { if (data) {
this.err_msg = res; this.errMsg = res;
this.err_phase = data.errorInfo?.phase; this.errPhase = data.errorInfo?.phase;
this.err_code = data.errorInfo?.code; this.errCode = data.errorInfo?.code;
this.http_code = data.errorInfo?.httpCode; this.httpCode = data.httpCode;
this.reqEndTime = this.formatDate(data.timeInfo?.requestEndTime); this.reqEndTime = this.formatDate(data.timeInfo?.requestEndTime);
this.diskStartTime = this.formatDate(data.timeInfo?.diskCheckStartTime); this.diskStartTime = this.formatDate(data.timeInfo?.diskCheckStartTime);
this.diskEndTime = this.formatDate(data.timeInfo?.diskCheckEndTime); this.diskEndTime = this.formatDate(data.timeInfo?.diskCheckEndTime);
@ -376,37 +351,37 @@ struct TestImageKnifeCallbackPage {
this.decodeStartTime = this.formatDate(data.timeInfo?.diskCheckStartTime); this.decodeStartTime = this.formatDate(data.timeInfo?.diskCheckStartTime);
this.decodeEndTime = this.formatDate(data.timeInfo?.diskCheckEndTime); this.decodeEndTime = this.formatDate(data.timeInfo?.diskCheckEndTime);
this.reqCancelTime = this.formatDate(data.timeInfo?.requestCancelTime) this.reqCancelTime = this.formatDate(data.timeInfo?.requestCancelTime)
this.requestFrom = '';
} }
} }
destroy() { destroy() {
this.currentWidth = 200 this.currentWidth = 200
this.currentHeight = 200 this.currentHeight = 200
this.url = "" this.url = ''
this.imageType = "" this.imageType = ''
this.imageWidth = 0 this.imageWidth = 0
this.imageHeight = 0 this.imageHeight = 0
this.imageSize = 0 this.imageSize = 0
this.componentWidth = 0 this.componentWidth = 0
this.componentHeight = 0 this.componentHeight = 0
this.frameNum = 0 this.frameNum = 0
this.decodeSize = "" this.decodeSize = ''
this.err_msg = "" this.errMsg = ''
this.err_phase = "" this.errPhase = ''
this.err_code = 0 this.errCode = 0
this.http_code = 0 this.httpCode = 0
this.reqStartTime = "" this.reqStartTime = ''
this.reqEndTime = "" this.reqEndTime = ''
this.reqCancelTime = "" this.reqCancelTime = ''
this.memoryStartTime = "" this.memoryStartTime = ''
this.memoryEndTime = "" this.memoryEndTime = ''
this.diskStartTime = "" this.diskStartTime = ''
this.diskEndTime = "" this.diskEndTime = ''
this.netStartTime = "" this.netStartTime = ''
this.netEndTime = "" this.netEndTime = ''
this.decodeStartTime = "" this.decodeStartTime = ''
this.decodeEndTime = "" this.decodeEndTime = ''
this.renderTime = ""
this.showChild = true; this.showChild = true;
} }
} }

View File

@ -22,30 +22,30 @@ struct TestIsUrlExist {
placeholderSrc: $r('app.media.loading'), placeholderSrc: $r('app.media.loading'),
errorholderSrc:$r('app.media.failed') errorholderSrc:$r('app.media.failed')
} }
@State source: PixelMap | string | Resource = $r("app.media.startIcon") @State source: PixelMap | string | Resource = $r('app.media.startIcon')
@State source1: PixelMap | string | Resource = $r("app.media.startIcon") @State source1: PixelMap | string | Resource = $r('app.media.startIcon')
build() { build() {
Column() { Column() {
Flex() { Flex() {
Button($r('app.string.Preloading_GIF')).onClick(() => { Button($r('app.string.Preloading_GIF')).onClick(() => {
this.imageKnifeOption.loadSrc = this.imageKnifeOption.loadSrc =
"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658" 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658'
}) })
Button($r('app.string.Retrieve_GIF_from_memory')).onClick(() => { Button($r('app.string.Retrieve_GIF_from_memory')).onClick(() => {
ImageKnife.getInstance() ImageKnife.getInstance()
.getCacheImage("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658", .getCacheImage('https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658',
CacheStrategy.Memory) CacheStrategy.Memory)
.then((data) => { .then((data) => {
this.source = data !== undefined ? data.source : $r("app.media.startIcon") this.source = data !== undefined ? data.source : $r('app.media.startIcon')
}) })
}) })
Button($r('app.string.Retrieve_GIF_from_disk')).onClick(() => { Button($r('app.string.Retrieve_GIF_from_disk')).onClick(() => {
ImageKnife.getInstance() ImageKnife.getInstance()
.getCacheImage("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658", .getCacheImage('https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658',
CacheStrategy.File) CacheStrategy.File)
.then((data) => { .then((data) => {
this.source1 = data !== undefined ? data.source : $r("app.media.startIcon") this.source1 = data !== undefined ? data.source : $r('app.media.startIcon')
}) })
}) })
} }

View File

@ -16,9 +16,9 @@
import { ImageKnifeComponent} from '@ohos/libraryimageknife'; import { ImageKnifeComponent} from '@ohos/libraryimageknife';
class ArrayElement { class ArrayElement {
src: string = ""; public src: string = '';
w: number = 0; public w: number = 0;
h: number = 0; public h: number = 0;
} }
@Entry @Entry
@ -27,27 +27,27 @@ struct TestListImageKnifeCallbackPage {
private wid: number = 200; private wid: number = 200;
private hig: number = 200; private hig: number = 200;
private dataArray: ESObject[] = [ private dataArray: ESObject[] = [
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg',
"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658", 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/78/v3/qQJpAtRGQe2e_VhbGHDgIw/b3zlit99S6GybD3XdNwqJw.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/78/v3/qQJpAtRGQe2e_VhbGHDgIw/b3zlit99S6GybD3XdNwqJw.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/55/v3/5DZ2LLqYSsK85-shqgLveQ/7ZXcyCWNTvOzQP5FFLBGkg.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/55/v3/5DZ2LLqYSsK85-shqgLveQ/7ZXcyCWNTvOzQP5FFLBGkg.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/25/v3/jgB2ekkTRX-3yTYZalnANQ/xff_x9cbSPqb7fbNwgJa7A.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/25/v3/jgB2ekkTRX-3yTYZalnANQ/xff_x9cbSPqb7fbNwgJa7A.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fb/v3/alXwXLHKSyCAIWt_ydgD2g/BCCuu25TREOitQxM7eYOEw.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fb/v3/alXwXLHKSyCAIWt_ydgD2g/BCCuu25TREOitQxM7eYOEw.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/63/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/63/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/16/v3/fm2tO4TsRH6mv_D_nSSd5w/FscLpLwQQ-KuV7oaprFK2Q.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/16/v3/fm2tO4TsRH6mv_D_nSSd5w/FscLpLwQQ-KuV7oaprFK2Q.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/89/v3/UAUvtPHqRD-GWWANsEC57Q/zcRJCQebQ322Aby4jzmwmQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/89/v3/UAUvtPHqRD-GWWANsEC57Q/zcRJCQebQ322Aby4jzmwmQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/30/v3/tUUzzx73R4yp8G--lMhuWQ/EBbcu_dLTT-Jj68XAh6mtA.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/30/v3/tUUzzx73R4yp8G--lMhuWQ/EBbcu_dLTT-Jj68XAh6mtA.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/37/v3/12rH1yiEQmK9wlOOcy5avQ/RzBXiEBRRqOC7LRkwNj6VA.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/37/v3/12rH1yiEQmK9wlOOcy5avQ/RzBXiEBRRqOC7LRkwNj6VA.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/9a/v3/TpRN4AIzRoyUXIqWdKoE0g/ShOnD_tfS46HDbpSWhbCkQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/9a/v3/TpRN4AIzRoyUXIqWdKoE0g/ShOnD_tfS46HDbpSWhbCkQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/03/v3/H3X17s8eTdS2w56JgbB5jQ/a45sT-j8Sbe8sSQXTzeYvQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/03/v3/H3X17s8eTdS2w56JgbB5jQ/a45sT-j8Sbe8sSQXTzeYvQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/10/v3/qaEzwkU0QeKb1yehnP2Xig/q7fxAlgMQKup-HUBayRLGQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/10/v3/qaEzwkU0QeKb1yehnP2Xig/q7fxAlgMQKup-HUBayRLGQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/96/v3/rMJJoAflTDSWa1z2pHs2wg/8dOqD0GlQBOCL5AvQok9FQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/96/v3/rMJJoAflTDSWa1z2pHs2wg/8dOqD0GlQBOCL5AvQok9FQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/ed/v3/KMO4D6D2QGuVOCLX4AhOFA/ef51xAaLQuK7BsnuD9abog.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/ed/v3/KMO4D6D2QGuVOCLX4AhOFA/ef51xAaLQuK7BsnuD9abog.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/d9/v3/FSZH0aTdSqWxeAaxoPvi0g/RqxPxUCXQFiTMBfKTF9kkw.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/d9/v3/FSZH0aTdSqWxeAaxoPvi0g/RqxPxUCXQFiTMBfKTF9kkw.jpg',
"https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB", 'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg', 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg',
'https://img-blog.csdn.net/20140514114029140', 'https://img-blog.csdn.net/20140514114029140',
'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp', 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
@ -78,17 +78,19 @@ struct TestListImageKnifeCallbackPage {
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
onLoadListener: { onLoadListener: {
onLoadStart: (data) => { onLoadStart: (data) => {
console.log("listCache start:{ url:"+data?.imageKnifeOption.loadSrc +",componentWidth:"+data?.componentWidth+",componentHeight:"+data?.componentHeight+"}," console.log('listCache start:{ url:' + data?.imageKnifeOption.loadSrc +
+ JSON.stringify(data?.getImageKnifeData())) ',componentWidth:' + data?.componentWidth +
',componentHeight:' + data?.componentHeight +
'},' + JSON.stringify(data?.imageKnifeData))
}, },
onLoadFailed: (res, req) => { onLoadFailed: (res, req) => {
console.log("listCache onLoadFailed:res:" + res + ";" + JSON.stringify(req?.getImageKnifeData())) console.log('listCache onLoadFailed:res:' + res + ';' + JSON.stringify(req?.imageKnifeData))
}, },
onLoadSuccess: (data, imageData,req) => { onLoadSuccess: (data, imageData,req) => {
console.log("listCache onLoadSuccess:" + JSON.stringify(req?.getImageKnifeData())) console.log('listCache onLoadSuccess:' + JSON.stringify(req?.imageKnifeData))
}, },
onLoadCancel: (res, req) => { onLoadCancel: (res, req) => {
console.log("listCache onLoadCancel:res:" + res + ";" + JSON.stringify(req?.getImageKnifeData())) console.log('listCache onLoadCancel:res:' + res + ';' + JSON.stringify(req?.imageKnifeData))
} }
}, },
border: { radius: 50 }, border: { radius: 50 },

View File

@ -22,9 +22,9 @@ struct TestLoadCancelListenerPage {
@State currentWidth: number = 200 @State currentWidth: number = 200
@State currentHeight: number = 200 @State currentHeight: number = 200
@State showChild: boolean = true; @State showChild: boolean = true;
@State text: string = ""; @State text: string = '';
@State ImageKnifeOption: ImageKnifeOption = { @State ImageKnifeOption: ImageKnifeOption = {
loadSrc: "", loadSrc: '',
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
border: { radius: 50 } border: { radius: 50 }
}; };
@ -37,7 +37,7 @@ struct TestLoadCancelListenerPage {
.onClick(() => { .onClick(() => {
this.clearCache(); this.clearCache();
this.ImageKnifeOption = { this.ImageKnifeOption = {
loadSrc: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg", loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg',
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
onLoadListener: { onLoadListener: {
onLoadStart: () => { onLoadStart: () => {
@ -45,7 +45,7 @@ struct TestLoadCancelListenerPage {
}, },
onLoadCancel: (res) => { onLoadCancel: (res) => {
this.text = res this.text = res
console.log("TestLoadCancelListenerPage----onLoadCancel> url:" + res) console.log('TestLoadCancelListenerPage----onLoadCancel> url:' + res)
} }
}, },
border: { radius: 50 } border: { radius: 50 }
@ -54,10 +54,10 @@ struct TestLoadCancelListenerPage {
Button($r('app.string.component_display')) Button($r('app.string.component_display'))
.margin(20).onClick(() => { .margin(20).onClick(() => {
this.text = ""; this.text = '';
this.showChild = true; this.showChild = true;
this.ImageKnifeOption = { this.ImageKnifeOption = {
loadSrc: "", loadSrc: '',
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
border: { radius: 50 } border: { radius: 50 }
} }
@ -75,7 +75,7 @@ struct TestLoadCancelListenerPage {
}, },
onLoadCancel: (res) => { onLoadCancel: (res) => {
this.text = res this.text = res
console.log("TestLoadCancelListenerPage----onLoadCancel> url:" + res) console.log('TestLoadCancelListenerPage----onLoadCancel> url:' + res)
} }
}, },
border: { radius: 50 } border: { radius: 50 }

View File

@ -24,22 +24,22 @@ struct TestPrefetchToFileCachePage {
} }
async preload(url:string) { async preload(url:string) {
let fileCachePath = await ImageKnife.getInstance().preLoadCache(url) let fileCachePath = await ImageKnife.getInstance().preLoadCache(url)
console.log("preload-fileCachePath=="+ fileCachePath) console.log('preload-fileCachePath=='+ fileCachePath)
} }
async preload1(url:string) { async preload1(url:string) {
let fileCachePath = await ImageKnife.getInstance().preLoadCache({ loadSrc: url }) let fileCachePath = await ImageKnife.getInstance().preLoadCache({ loadSrc: url })
console.log("preload-fileCachePath1=="+ fileCachePath) console.log('preload-fileCachePath1=='+ fileCachePath)
} }
build() { build() {
Column() { Column() {
Button($r('app.string.Preloading_images_to_file_cache_using_URL')).margin({top:10}).onClick(async ()=>{ Button($r('app.string.Preloading_images_to_file_cache_using_URL')).margin({top:10}).onClick(async ()=>{
await this.preload("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658") await this.preload('https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658')
}) })
Button($r('app.string.Preloading_images_to_file_cache_using_option')).margin({top:10}).onClick(async ()=>{ Button($r('app.string.Preloading_images_to_file_cache_using_option')).margin({top:10}).onClick(async ()=>{
await this.preload1("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658") await this.preload1('https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658')
}) })
Button($r('app.string.Load_image_offline_after_preloading')).margin({top:10}).onClick(()=>{ Button($r('app.string.Load_image_offline_after_preloading')).margin({top:10}).onClick(()=>{
this.imageKnifeOption.loadSrc = "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658" this.imageKnifeOption.loadSrc = 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658'
}) })
ImageKnifeComponent({ ImageKnifeComponent({
imageKnifeOption: this.imageKnifeOption imageKnifeOption: this.imageKnifeOption

View File

@ -22,33 +22,33 @@ struct TestRemoveCache {
placeholderSrc: $r('app.media.loading'), placeholderSrc: $r('app.media.loading'),
errorholderSrc:$r('app.media.failed') errorholderSrc:$r('app.media.failed')
} }
@State source: PixelMap | string | Resource = $r("app.media.startIcon"); @State source: PixelMap | string | Resource = $r('app.media.startIcon');
@State source1: PixelMap | string | Resource = $r("app.media.startIcon"); @State source1: PixelMap | string | Resource = $r('app.media.startIcon');
@State url: string = ''; @State url: string = '';
build() { build() {
Column() { Column() {
Flex() { Flex() {
Button($r('app.string.Preloading_GIF')).onClick(() => { Button($r('app.string.Preloading_GIF')).onClick(() => {
this.imageKnifeOption.loadSrc = "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658"; this.imageKnifeOption.loadSrc = 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658';
this.url = "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658"; this.url = 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658';
}) })
.margin({left:10}) .margin({left:10})
Button($r('app.string.Retrieve_GIF_from_memory')).onClick(() => { Button($r('app.string.Retrieve_GIF_from_memory')).onClick(() => {
ImageKnife.getInstance() ImageKnife.getInstance()
.getCacheImage("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658", .getCacheImage('https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658',
CacheStrategy.Memory) CacheStrategy.Memory)
.then((data) => { .then((data) => {
this.source = data !== undefined ? data.source : $r("app.media.startIcon"); this.source = data !== undefined ? data.source : $r('app.media.startIcon');
}) })
}) })
.margin({left:10}) .margin({left:10})
Button($r('app.string.Retrieve_GIF_from_disk')).onClick(() => { Button($r('app.string.Retrieve_GIF_from_disk')).onClick(() => {
ImageKnife.getInstance() ImageKnife.getInstance()
.getCacheImage("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658", .getCacheImage('https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658',
CacheStrategy.File) CacheStrategy.File)
.then((data) => { .then((data) => {
this.source1 = data !== undefined ? data.source : $r("app.media.startIcon"); this.source1 = data !== undefined ? data.source : $r('app.media.startIcon');
}) })
}) })
.margin({left:10}) .margin({left:10})

View File

@ -32,21 +32,21 @@ struct TestSetCustomImagePage {
} }
build() { build() {
Column() { Column() {
Button(this.getResourceString($r('app.string.Custom_network_download')) + " a").onClick(()=>{ Button(this.getResourceString($r('app.string.Custom_network_download')) + ' a').onClick(()=>{
this.imageKnifeOption ={ this.imageKnifeOption ={
loadSrc: "aaa", loadSrc: 'aaa',
placeholderSrc: $r('app.media.loading') placeholderSrc: $r('app.media.loading')
} }
}) })
Button(this.getResourceString($r('app.string.Custom_network_download')) + " b").onClick(()=>{ Button(this.getResourceString($r('app.string.Custom_network_download')) + ' b').onClick(()=>{
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: "bbb", loadSrc: 'bbb',
placeholderSrc: $r('app.media.loading') placeholderSrc: $r('app.media.loading')
} }
}) })
Button(this.getResourceString($r('app.string.Custom_network_download')) + " c").onClick(()=>{ Button(this.getResourceString($r('app.string.Custom_network_download')) + ' c').onClick(()=>{
this.imageKnifeOption = { this.imageKnifeOption = {
loadSrc: "ccc", loadSrc: 'ccc',
placeholderSrc: $r('app.media.loading') placeholderSrc: $r('app.media.loading')
} }
}) })
@ -55,14 +55,14 @@ struct TestSetCustomImagePage {
}).width(300) }).width(300)
.height(300) .height(300)
} }
.width("100%") .width('100%')
.height("100%") .height('100%')
} }
} }
@Concurrent @Concurrent
async function custom(context: Context, src: string | PixelMap | Resource,headers?: Record<string,Object>): Promise<ArrayBuffer | undefined> { async function custom(context: Context, src: string | PixelMap | Resource,headers?: Record<string,Object>): Promise<ArrayBuffer | undefined> {
console.info("ImageKnife:: custom download" + src) console.info('ImageKnife:: custom download' + src)
// 举例写死从本地文件读取,也可以自己请求网络图片 // 举例写死从本地文件读取,也可以自己请求网络图片
let buffer = context.resourceManager.getMediaContentSync($r("app.media.pngSample").id).buffer as ArrayBuffer let buffer = context.resourceManager.getMediaContentSync($r('app.media.pngSample').id).buffer as ArrayBuffer
return buffer return buffer
} }

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { ImageKnifeComponent, ImageKnifeOption } from "@ohos/libraryimageknife" import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife'
@ComponentV2 @ComponentV2
export struct ZuImage { export struct ZuImage {
@ -43,7 +43,7 @@ export struct ZuImage {
@ComponentV2 @ComponentV2
struct TestTaskResourcePage { struct TestTaskResourcePage {
@Local stateMenus: Array<string> = [ @Local stateMenus: Array<string> = [
"https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB", 'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg', 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg',
'https://img-blog.csdn.net/20140514114029140', 'https://img-blog.csdn.net/20140514114029140',
'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp', 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
@ -53,7 +53,7 @@ struct TestTaskResourcePage {
Column({ space: 8 }) { Column({ space: 8 }) {
ZuImage({ ZuImage({
src: item, src: item,
placeholderSrc: $r("app.media.loading") placeholderSrc: $r('app.media.loading')
}).width(44) }).width(44)
.height(44) .height(44)
} }
@ -66,7 +66,7 @@ struct TestTaskResourcePage {
this._buildItem(item) this._buildItem(item)
} }
}) })
}.width("100%") }.width('100%')
.columnsTemplate('1fr 1fr 1fr 1fr 1fr') .columnsTemplate('1fr 1fr 1fr 1fr 1fr')
.rowsGap(24) .rowsGap(24)
.padding({ .padding({

View File

@ -48,7 +48,7 @@ struct TestWriteCacheStage {
}).width(200).height(200).margin({top:10}) }).width(200).height(200).margin({top:10})
Button($r('app.string.Write_memory')).margin({top:10}).onClick(async ()=>{ Button($r('app.string.Write_memory')).margin({top:10}).onClick(async ()=>{
this.imageKnifeOption2 = { this.imageKnifeOption2 = {
loadSrc:"https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB", loadSrc:'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
placeholderSrc:$r('app.media.loading'), placeholderSrc:$r('app.media.loading'),
errorholderSrc:$r('app.media.failed'), errorholderSrc:$r('app.media.failed'),
writeCacheStrategy:CacheStrategy.Memory writeCacheStrategy:CacheStrategy.Memory

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { ImageKnifeComponent, ImageKnifeOption } from "@ohos/libraryimageknife" import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife'
import matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
@ -22,9 +22,9 @@ struct TransformPage {
private custom_scale:number = 1 private custom_scale:number = 1
@State matrix1:object = matrix4.identity().scale({ x: 1, y: 1 }) @State matrix1:object = matrix4.identity().scale({ x: 1, y: 1 })
@State ImageKnifeOption: ImageKnifeOption = { @State ImageKnifeOption: ImageKnifeOption = {
loadSrc: $r("app.media.rabbit"), loadSrc: $r('app.media.rabbit'),
placeholderSrc: $r("app.media.loading"), placeholderSrc: $r('app.media.loading'),
errorholderSrc: $r("app.media.app_icon"), errorholderSrc: $r('app.media.app_icon'),
objectFit: ImageFit.Contain, objectFit: ImageFit.Contain,
border: { radius: 50 } border: { radius: 50 }
} }

View File

@ -22,8 +22,8 @@ class MyImageOption extends ImageKnifeOption {
@Component @Component
export struct UserAvatar { export struct UserAvatar {
@Prop @Watch('userInfoUpdate') userInfo: string = "" @Prop @Watch('userInfoUpdate') userInfo: string = ''
// @Prop userInfo: string = "" // @Prop userInfo: string = ''
imgSize: number = 100 imgSize: number = 100
radius: number = 12 radius: number = 12
borderSize: number = 0 borderSize: number = 0
@ -87,12 +87,12 @@ export struct UserAvatar {
// Image(this.userInfo) // Image(this.userInfo)
// Text((this.imageKnifeOption.loadSrc as string).split('/')[8]) // Text((this.imageKnifeOption.loadSrc as string).split('/')[8])
// .position({ x: 0, y: 0 }) // .position({ x: 0, y: 0 })
// .zIndex(9) // .zIndex(9)
// .fontSize(12) // .fontSize(12)
// .fontColor('#ff0000') // .fontColor('#ff0000')
} }
} }
} }

View File

@ -20,58 +20,58 @@ import { UserAvatar } from './User'
struct Index { struct Index {
@State hotCommendList:CommonDataSource<string> = new CommonDataSource<string>([]) @State hotCommendList:CommonDataSource<string> = new CommonDataSource<string>([])
private data:string[] = [ private data:string[] = [
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e2/v3/4zI1Xm_3STmV30aZXWRrKw/6aN7WodDRUiBApgffiLPCg.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e2/v3/4zI1Xm_3STmV30aZXWRrKw/6aN7WodDRUiBApgffiLPCg.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/42/v3/2dSQCqERTP2TTPyssOMEbQ/zL1ebnKKQ_ilqTDcwCAkOw.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/42/v3/2dSQCqERTP2TTPyssOMEbQ/zL1ebnKKQ_ilqTDcwCAkOw.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/78/v3/qQJpAtRGQe2e_VhbGHDgIw/b3zlit99S6GybD3XdNwqJw.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/78/v3/qQJpAtRGQe2e_VhbGHDgIw/b3zlit99S6GybD3XdNwqJw.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/55/v3/5DZ2LLqYSsK85-shqgLveQ/7ZXcyCWNTvOzQP5FFLBGkg.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/55/v3/5DZ2LLqYSsK85-shqgLveQ/7ZXcyCWNTvOzQP5FFLBGkg.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/25/v3/jgB2ekkTRX-3yTYZalnANQ/xff_x9cbSPqb7fbNwgJa7A.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/25/v3/jgB2ekkTRX-3yTYZalnANQ/xff_x9cbSPqb7fbNwgJa7A.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fb/v3/alXwXLHKSyCAIWt_ydgD2g/BCCuu25TREOitQxM7eYOEw.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fb/v3/alXwXLHKSyCAIWt_ydgD2g/BCCuu25TREOitQxM7eYOEw.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/63/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/63/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/16/v3/fm2tO4TsRH6mv_D_nSSd5w/FscLpLwQQ-KuV7oaprFK2Q.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/16/v3/fm2tO4TsRH6mv_D_nSSd5w/FscLpLwQQ-KuV7oaprFK2Q.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/89/v3/UAUvtPHqRD-GWWANsEC57Q/zcRJCQebQ322Aby4jzmwmQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/89/v3/UAUvtPHqRD-GWWANsEC57Q/zcRJCQebQ322Aby4jzmwmQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/30/v3/tUUzzx73R4yp8G--lMhuWQ/EBbcu_dLTT-Jj68XAh6mtA.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/30/v3/tUUzzx73R4yp8G--lMhuWQ/EBbcu_dLTT-Jj68XAh6mtA.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/37/v3/12rH1yiEQmK9wlOOcy5avQ/RzBXiEBRRqOC7LRkwNj6VA.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/37/v3/12rH1yiEQmK9wlOOcy5avQ/RzBXiEBRRqOC7LRkwNj6VA.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/9a/v3/TpRN4AIzRoyUXIqWdKoE0g/ShOnD_tfS46HDbpSWhbCkQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/9a/v3/TpRN4AIzRoyUXIqWdKoE0g/ShOnD_tfS46HDbpSWhbCkQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/03/v3/H3X17s8eTdS2w56JgbB5jQ/a45sT-j8Sbe8sSQXTzeYvQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/03/v3/H3X17s8eTdS2w56JgbB5jQ/a45sT-j8Sbe8sSQXTzeYvQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/10/v3/qaEzwkU0QeKb1yehnP2Xig/q7fxAlgMQKup-HUBayRLGQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/10/v3/qaEzwkU0QeKb1yehnP2Xig/q7fxAlgMQKup-HUBayRLGQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/96/v3/rMJJoAflTDSWa1z2pHs2wg/8dOqD0GlQBOCL5AvQok9FQ.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/96/v3/rMJJoAflTDSWa1z2pHs2wg/8dOqD0GlQBOCL5AvQok9FQ.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/ed/v3/KMO4D6D2QGuVOCLX4AhOFA/ef51xAaLQuK7BsnuD9abog.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/ed/v3/KMO4D6D2QGuVOCLX4AhOFA/ef51xAaLQuK7BsnuD9abog.jpg',
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/d9/v3/FSZH0aTdSqWxeAaxoPvi0g/RqxPxUCXQFiTMBfKTF9kkw.jpg", 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/d9/v3/FSZH0aTdSqWxeAaxoPvi0g/RqxPxUCXQFiTMBfKTF9kkw.jpg',
"https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB", 'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB',
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg', 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg',
'https://img-blog.csdn.net/20140514114029140', 'https://img-blog.csdn.net/20140514114029140',
'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp', 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
] ]
aboutToAppear(): void { aboutToAppear(): void {
this.hotCommendList.addData(this.hotCommendList.totalCount(),this.data) this.hotCommendList.addData(this.hotCommendList.totalCount(),this.data)
AppStorage.set("WeLink_Mob_fontSize_multiple",1) AppStorage.set('WeLink_Mob_fontSize_multiple',1)
} }
build() { build() {
Column() { Column() {
Button("bigger").onClick(()=>{ Button('bigger').onClick(()=>{
AppStorage.set("WeLink_Mob_fontSize_multiple",1.6) AppStorage.set('WeLink_Mob_fontSize_multiple',1.6)
}) })
Button("small").onClick(()=>{ Button('small').onClick(()=>{
AppStorage.set("WeLink_Mob_fontSize_multiple",0.8) AppStorage.set('WeLink_Mob_fontSize_multiple',0.8)
}) })
List(){ List(){
LazyForEach(this.hotCommendList,(item:string)=>{ LazyForEach(this.hotCommendList,(item:string)=>{
ListItem(){ ListItem(){
ReuseImage({ ReuseImage({
userInfo:item userInfo:item
}).width("100%").height("100%").backgroundColor(Color.Yellow) }).width('100%').height('100%').backgroundColor(Color.Yellow)
}.width(200).height(200).margin({bottom:5}) }.width(200).height(200).margin({bottom:5})
}) })
} }
// .cachedCount(20) // .cachedCount(20)
.width("100%") .width('100%')
.height("100%") .height('100%')
.backgroundColor(0xFAEEE0) .backgroundColor(0xFAEEE0)
}.width('100%').height("100%") }.width('100%').height('100%')
} }
} }
@ -79,7 +79,7 @@ struct Index {
@Reusable @Reusable
@Component @Component
struct ReuseImage { struct ReuseImage {
@State userInfo:string = "" @State userInfo:string = ''
aboutToReuse(params: ESObject): void { aboutToReuse(params: ESObject): void {
this.userInfo = params.userInfo this.userInfo = params.userInfo
} }
@ -89,6 +89,6 @@ struct ReuseImage {
UserAvatar({ UserAvatar({
userInfo:this.userInfo userInfo:this.userInfo
}) })
}.width("100%").height("100%") }.width('100%').height('100%')
} }
} }

View File

@ -1,13 +1,13 @@
/* /*
* Copyright (C) 2024 Huawei Device Co., Ltd. * Copyright (C) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.

View File

@ -12,8 +12,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { statfs } from '@kit.CoreFileKit'
import { rcp } from '@kit.RemoteCommunicationKit'
export class CommonDataSource <T> implements IDataSource { export class CommonDataSource <T> implements IDataSource {
private dataArray: T[] = [] private dataArray: T[] = []
@ -54,7 +52,4 @@ export class CommonDataSource <T> implements IDataSource {
listener.onDataAdd(index) listener.onDataAdd(index)
}) })
} }
}
export class GetSession {
static session:rcp.Session = rcp.createSession()
} }

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {ImageKnife, ImageKnifeRequest} from "@ohos/libraryimageknife" import {ImageKnife, ImageKnifeRequest} from '@ohos/libraryimageknife'
import { IDataSourcePrefetching } from '@kit.ArkUI'; import { IDataSourcePrefetching } from '@kit.ArkUI';
import { HashMap } from '@kit.ArkTS'; import { HashMap } from '@kit.ArkTS';
@ -61,7 +61,7 @@ export default class DataSourcePrefetchingImageKnife implements IDataSourcePrefe
} }
async prefetch(index: number): Promise<void> { async prefetch(index: number): Promise<void> {
let item = this.dataArray[index] let item = this.dataArray[index]
if (typeof item.albumUrl == "string") { if (typeof item.albumUrl == 'string') {
// 图片预加载 // 图片预加载
let request = ImageKnife.getInstance().preload({ let request = ImageKnife.getInstance().preload({
loadSrc:item.albumUrl, loadSrc:item.albumUrl,

View File

@ -17,127 +17,127 @@ import { InfoItem } from './DataSourcePrefetching'
export class PageViewModel { export class PageViewModel {
private static dataArray: Array<InfoItem> = [ private static dataArray: Array<InfoItem> = [
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e2/v3/4zI1Xm_3STmV30aZXWRrKw/6aN7WodDRUiBApgffiLPCg.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e2/v3/4zI1Xm_3STmV30aZXWRrKw/6aN7WodDRUiBApgffiLPCg.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/42/v3/2dSQCqERTP2TTPyssOMEbQ/zL1ebnKKQ_ilqTDcwCAkOw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/42/v3/2dSQCqERTP2TTPyssOMEbQ/zL1ebnKKQ_ilqTDcwCAkOw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/78/v3/qQJpAtRGQe2e_VhbGHDgIw/b3zlit99S6GybD3XdNwqJw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/78/v3/qQJpAtRGQe2e_VhbGHDgIw/b3zlit99S6GybD3XdNwqJw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/55/v3/5DZ2LLqYSsK85-shqgLveQ/7ZXcyCWNTvOzQP5FFLBGkg.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/55/v3/5DZ2LLqYSsK85-shqgLveQ/7ZXcyCWNTvOzQP5FFLBGkg.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/25/v3/jgB2ekkTRX-3yTYZalnANQ/xff_x9cbSPqb7fbNwgJa7A.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/25/v3/jgB2ekkTRX-3yTYZalnANQ/xff_x9cbSPqb7fbNwgJa7A.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fb/v3/alXwXLHKSyCAIWt_ydgD2g/BCCuu25TREOitQxM7eYOEw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fb/v3/alXwXLHKSyCAIWt_ydgD2g/BCCuu25TREOitQxM7eYOEw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/63/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/63/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/16/v3/fm2tO4TsRH6mv_D_nSSd5w/FscLpLwQQ-KuV7oaprFK2Q.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/16/v3/fm2tO4TsRH6mv_D_nSSd5w/FscLpLwQQ-KuV7oaprFK2Q.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/89/v3/UAUvtPHqRD-GWWANsEC57Q/zcRJCQebQ322Aby4jzmwmQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/89/v3/UAUvtPHqRD-GWWANsEC57Q/zcRJCQebQ322Aby4jzmwmQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/30/v3/tUUzzx73R4yp8G--lMhuWQ/EBbcu_dLTT-Jj68XAh6mtA.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/30/v3/tUUzzx73R4yp8G--lMhuWQ/EBbcu_dLTT-Jj68XAh6mtA.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/37/v3/12rH1yiEQmK9wlOOcy5avQ/RzBXiEBRRqOC7LRkwNj6VA.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/37/v3/12rH1yiEQmK9wlOOcy5avQ/RzBXiEBRRqOC7LRkwNj6VA.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/9a/v3/TpRN4AIzRoyUXIqWdKoE0g/ShOnD_tfS46HDbpSWhbCkQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/9a/v3/TpRN4AIzRoyUXIqWdKoE0g/ShOnD_tfS46HDbpSWhbCkQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/03/v3/H3X17s8eTdS2w56JgbB5jQ/a45sT-j8Sbe8sSQXTzeYvQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/03/v3/H3X17s8eTdS2w56JgbB5jQ/a45sT-j8Sbe8sSQXTzeYvQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/10/v3/qaEzwkU0QeKb1yehnP2Xig/q7fxAlgMQKup-HUBayRLGQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/10/v3/qaEzwkU0QeKb1yehnP2Xig/q7fxAlgMQKup-HUBayRLGQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/96/v3/rMJJoAflTDSWa1z2pHs2wg/8dOqD0GlQBOCL5AvQok9FQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/96/v3/rMJJoAflTDSWa1z2pHs2wg/8dOqD0GlQBOCL5AvQok9FQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/ed/v3/KMO4D6D2QGuVOCLX4AhOFA/ef51xAaLQuK7BsnuD9abog.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/ed/v3/KMO4D6D2QGuVOCLX4AhOFA/ef51xAaLQuK7BsnuD9abog.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/d9/v3/FSZH0aTdSqWxeAaxoPvi0g/RqxPxUCXQFiTMBfKTF9kkw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/d9/v3/FSZH0aTdSqWxeAaxoPvi0g/RqxPxUCXQFiTMBfKTF9kkw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/8a/v3/ZKzYV5BJTuCk5hCE0y_xNA/8JT95OQnSZSd6_xQQUONhQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/8a/v3/ZKzYV5BJTuCk5hCE0y_xNA/8JT95OQnSZSd6_xQQUONhQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/1/v3/sTXb_I7URBKjdMyLDYa19w/qpcwa_FNQmi3-EzjbGsJ8A.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/1/v3/sTXb_I7URBKjdMyLDYa19w/qpcwa_FNQmi3-EzjbGsJ8A.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e5/v3/m7wFvw_eQIuDV0Mk0IKi8g/gJU4migzTHKYk5KrgdZbBw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e5/v3/m7wFvw_eQIuDV0Mk0IKi8g/gJU4migzTHKYk5KrgdZbBw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3f/v3/k_UWbB5_RGW7JemQZ0OQdw/_DUdmaZRQyG-Oyvkb663Bw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3f/v3/k_UWbB5_RGW7JemQZ0OQdw/_DUdmaZRQyG-Oyvkb663Bw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/39/v3/rFRN7G_VSo-p4mBjTZtkRw/gBwTI-ieSIqSsSmLNBEcgw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/39/v3/rFRN7G_VSo-p4mBjTZtkRw/gBwTI-ieSIqSsSmLNBEcgw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/04/v3/6K8BPYKVQFOr7KCuAG9nog/qKd3pZlrQy2M-feB3ycVPA.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/04/v3/6K8BPYKVQFOr7KCuAG9nog/qKd3pZlrQy2M-feB3ycVPA.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/7d/v3/f0GQFzm1T6eduVeMUhO3Wg/-4cvzIJiRCegjIno3ofIbQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/7d/v3/f0GQFzm1T6eduVeMUhO3Wg/-4cvzIJiRCegjIno3ofIbQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e4/v3/C0xxsSeySxW-2iYR5OEbpQ/f1GlaD3zTeKPX8Vd-M1oVQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e4/v3/C0xxsSeySxW-2iYR5OEbpQ/f1GlaD3zTeKPX8Vd-M1oVQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/c2/v3/32LCyXN4TuWKWcdf9gAwWw/ej14_BCJQNCaWOKoI9aZAw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/c2/v3/32LCyXN4TuWKWcdf9gAwWw/ej14_BCJQNCaWOKoI9aZAw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fd/v3/LyYJMdMmQNaC5GyBYEZ5Pw/uFLiovypRSagKyIS-UJPVw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fd/v3/LyYJMdMmQNaC5GyBYEZ5Pw/uFLiovypRSagKyIS-UJPVw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/15/v3/MHM9KaWGTgubn6M8-B_6nw/1YO9JyYhTHSBWsoiqYkGZw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/15/v3/MHM9KaWGTgubn6M8-B_6nw/1YO9JyYhTHSBWsoiqYkGZw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/4c/v3/UdYfbv1_QYqn_ulDHp89OA/VkjexMluTqGO3yt3gPK1DA.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/4c/v3/UdYfbv1_QYqn_ulDHp89OA/VkjexMluTqGO3yt3gPK1DA.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e8/v3/N8blT_7qSK-tRtahIyov7g/M_kjGEEmSzOlTc47Zrfozg.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e8/v3/N8blT_7qSK-tRtahIyov7g/M_kjGEEmSzOlTc47Zrfozg.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/28/v3/VS_h3m4YRrSgbgxnqE3vtQ/h-2Q1Qy2SSGEuXM36-Rq_w.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/28/v3/VS_h3m4YRrSgbgxnqE3vtQ/h-2Q1Qy2SSGEuXM36-Rq_w.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/2e/v3/R-BaM5ToRNGq5rwtNTcnww/Q2e01VHiR2y9KtFaZmpmNQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/2e/v3/R-BaM5ToRNGq5rwtNTcnww/Q2e01VHiR2y9KtFaZmpmNQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/88/v3/3djkAJKKTdC539XqMdstSg/wHO7DxvXQS2xbt2Y_-4BNg.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/88/v3/3djkAJKKTdC539XqMdstSg/wHO7DxvXQS2xbt2Y_-4BNg.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fb/v3/guw4eiggR3uWjscFTxITYg/TzRB35iPTdCztrZUUaNuFg.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fb/v3/guw4eiggR3uWjscFTxITYg/TzRB35iPTdCztrZUUaNuFg.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/93/v3/UvSh_f1LT66i0-3hvsYN_A/eYnE3Z8YT5Sk7F-vS2ZmCQ.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/93/v3/UvSh_f1LT66i0-3hvsYN_A/eYnE3Z8YT5Sk7F-vS2ZmCQ.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/5/v3/tv8Vqf9hQrKpozGeZWg2mw/VEICB-bmQYi0Iv6TGADbhw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/5/v3/tv8Vqf9hQrKpozGeZWg2mw/VEICB-bmQYi0Iv6TGADbhw.jpg'
}, },
{ {
albumUrl: "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/30/v3/4v1Ot5BRR6OFVQ9MGn9Xxg/xrPgRn0LS1ep-r7ewIuwiw.jpg" albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/30/v3/4v1Ot5BRR6OFVQ9MGn9Xxg/xrPgRn0LS1ep-r7ewIuwiw.jpg'
}, },
] ]
static getItems() { static getItems() {

View File

@ -5,8 +5,11 @@
"description": "$string:module_desc", "description": "$string:module_desc",
"mainElement": "EntryAbility", "mainElement": "EntryAbility",
"deviceTypes": [ "deviceTypes": [
"phone", "default",
"tablet", "tablet",
"tv",
"wearable",
"car",
"2in1" "2in1"
], ],
"deliveryWithInstall": true, "deliveryWithInstall": true,

View File

@ -40,6 +40,10 @@
"name": "Test_SingleImage", "name": "Test_SingleImage",
"value": "SingleImage" "value": "SingleImage"
}, },
{
"name": "Test_LocalImageShow",
"value": "LocalImageShow"
},
{ {
"name": "Test_custom_download", "name": "Test_custom_download",
"value": "Global custom download" "value": "Global custom download"
@ -106,11 +110,11 @@
}, },
{ {
"name": "Display_the_first_frame", "name": "Display_the_first_frame",
"value": "Display the first frame of the animation" "value": "first frame"
}, },
{ {
"name": "Display_the_last_frame", "name": "Display_the_last_frame",
"value": "Display the last frame of the animation" "value": "last frame"
}, },
{ {
"name": "Play", "name": "Play",
@ -140,10 +144,26 @@
"name": "Local_SVG", "name": "Local_SVG",
"value": "Local SVG image" "value": "Local SVG image"
}, },
{
"name": "local_r_file",
"value": "Local $r file"
},
{
"name": "local_rawfile",
"value": "Local rawfile"
},
{ {
"name": "Under_context_file", "name": "Under_context_file",
"value": "Files under context file" "value": "Files under context file"
}, },
{
"name": "local_other_module",
"value": "Local other module"
},
{
"name": "in_other_module",
"value": "in other module"
},
{ {
"name": "Network_images", "name": "Network_images",
"value": "Network images" "value": "Network images"
@ -562,11 +582,11 @@
}, },
{ {
"name": "img_frame", "name": "img_frame",
"value": "the number of frames of the picture:%d " "value": "the frames of the animator:%d "
}, },
{ {
"name": "img_content_size", "name": "img_content_size",
"value": "picture decoded width and height size:%s " "value": "decoded width and height size of image:%s "
}, },
{ {
"name": "err_msg", "name": "err_msg",
@ -586,15 +606,15 @@
}, },
{ {
"name": "req_start_time", "name": "req_start_time",
"value": "image request start time point:%s " "value": "request start time:%s "
}, },
{ {
"name": "req_end_time", "name": "req_end_time",
"value": "the point in time at which the image request ends:%s " "value": "request end time:%s "
}, },
{ {
"name": "req_cancel_time", "name": "req_cancel_time",
"value": "the point at which the image request is cancelled:%s " "value": "request cancel time:%s "
}, },
{ {
"name": "memory_start_time", "name": "memory_start_time",
@ -629,8 +649,8 @@
"value": "decoding end time point:%s " "value": "decoding end time point:%s "
}, },
{ {
"name": "render_time", "name": "request_data_from",
"value": "render successful time:%s " "value": "request from:%s "
}, },
{ {
"name": "Image_Downsampling_Functionality", "name": "Image_Downsampling_Functionality",
@ -647,6 +667,46 @@
{ {
"name": "After_the_sampling", "name": "After_the_sampling",
"value": "Size after downsampling" "value": "Size after downsampling"
},
{
"name": "adjust_size",
"value": "Adjust size"
},
{
"name": "Auto_ImageFit",
"value": "ImageFit.Auto:Auto ImageFit Height"
},
{
"name": "Single_CallBack",
"value": "Single image callback"
},
{
"name": "Multiple_CallBack",
"value": "Multiple image callback"
},
{
"name": "Error_Message",
"value": "error message"
},
{
"name": "test_exif",
"value": "Test display orientation base on the EXIF metadata "
},
{
"name": "base_image",
"value": "The image don't carry rotation information"
},
{
"name": "rotate_mirror",
"value": "Mirror horizontal"
},
{
"name": "rotate_rotate90",
"value": "Rotate 90°"
},
{
"name": "rotate_mirror_rotate270",
"value": "Mirror horizontal and rotate 270°"
} }
] ]
} }

View File

@ -3,7 +3,6 @@
"pages/Index", "pages/Index",
"pages/ListPage", "pages/ListPage",
"pages/SingleImage", "pages/SingleImage",
"pages/ManyPhotoShowPage",
"pages/LongImagePage", "pages/LongImagePage",
"pages/TransformPage", "pages/TransformPage",
"pages/UserPage", "pages/UserPage",
@ -32,13 +31,18 @@
"pages/TestCacheDataPage", "pages/TestCacheDataPage",
"pages/TestChangeColorPage", "pages/TestChangeColorPage",
"pages/TestLoadCancelListenerPage", "pages/TestLoadCancelListenerPage",
"pages/CustomNetImagePage",
"pages/SetMaxRequestPage", "pages/SetMaxRequestPage",
"pages/MaxRequest1", "pages/MaxRequest1",
"pages/MaxRequest2", "pages/MaxRequest2",
"pages/MaxRequest3", "pages/MaxRequest3",
"pages/TestImageKnifeCallbackPage", "pages/TestImageKnifeCallbackPage",
"pages/TestListImageKnifeCallbackPage", "pages/TestListImageKnifeCallbackPage",
"pages/DownSamplePage" "pages/DownSamplePage",
"pages/AutoImageFit",
"pages/SingleImageCallBack",
"pages/MultipleImageCallBack",
"pages/LocalImage",
"pages/ErrorMessageDownload",
"pages/TestImageExif"
] ]
} }

View File

@ -1,380 +0,0 @@
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "label"
},
{
"name": "app_permission_WRITE_IMAGEVIDEO",
"value": "获取写入媒体资源权限"
},
{
"name": "app_permission_READ_IMAGEVIDEO",
"value": "获取读媒体资源权限"
},
{
"name": "Test_ImageAnimator",
"value": "Test ImageAnimator component"
},
{
"name": "Test_multiple_images",
"value": "Test loading multiple identical images"
},
{
"name": "Test_Task_error",
"value": "Test placeholder map Task error"
},
{
"name": "Test_HSP",
"value": "Test HSP scene preloading"
},
{
"name": "Test_SingleImage",
"value": "SingleImage"
},
{
"name": "Test_custom_download",
"value": "Global custom download"
},
{
"name": "Multiple_images",
"value": "Multiple images"
},
{
"name": "Display_long_image",
"value": "Display long image"
},
{
"name": "Image_scaling",
"value": "Image scaling"
},
{
"name": "Message_list",
"value": "Message list"
},
{
"name": "Custom_cache_key",
"value": "Custom cache key"
},
{
"name": "Preloading_images_to_cache",
"value": "Preloading images to file cache"
},
{
"name": "Retrieve_image_display_from_cache",
"value": "Retrieve image display from cache"
},
{
"name": "Test_single_request_header",
"value": "Test a single request header"
},
{
"name": "Test_write_cache_strategy",
"value": "Test write cache strategy"
},
{
"name": "Image_Transformation",
"value": "Image Transformation"
},
{
"name": "Different_ObjectFit",
"value": "Different ObjectFit"
},
{
"name": "Test_image_loading_success_or_failure_events",
"value": "Test image loading success/failure events"
},
{
"name": "Test_removing_image_cache_interface",
"value": "Test removing image cache interface"
},
{
"name": "Test_error_image_display",
"value": "Test error image display"
},
{
"name": "Test_media_URL",
"value": "Test media URL"
},
{
"name": "Display_the_first_frame",
"value": "Display the first frame of the animation"
},
{
"name": "Display_the_last_frame",
"value": "Display the last frame of the animation"
},
{
"name": "Play",
"value": "Play"
},
{
"name": "Pause",
"value": "Pause"
},
{
"name": "Stop",
"value": "Stop"
},
{
"name": "Infinite_loop",
"value": "Infinite loop"
},
{
"name": "Play_once",
"value": "Play once"
},
{
"name": "Play_twice",
"value": "Play twice"
},
{
"name": "Local_SVG",
"value": "Local SVG image"
},
{
"name": "Under_context_file",
"value": "Files under context file"
},
{
"name": "Network_images",
"value": "Network images"
},
{
"name": "Custom_network_download",
"value": "Custom network download"
},
{
"name": "PixelMap_loads_images",
"value": "PixelMap loads images"
},
{
"name": "Enlarge",
"value": "Enlarge"
},
{
"name": "Reduce",
"value": "Reduce"
},
{
"name": "Click_on_add",
"value": "Click on the size to add 50"
},
{
"name": "Click_on_reduce",
"value": "Click to reduce size by 50"
},
{
"name": "The_key_fixed_1",
"value": "The key is fixed at 1"
},
{
"name": "The_key_changes_timestamp",
"value": "Key changes every time: timestamp"
},
{
"name": "Load",
"value": "Load"
},
{
"name": "Preloading_images_to_file_cache_using_URL",
"value": "Preloading images to file cache using URL"
},
{
"name": "Preloading_images_to_file_cache_using_option",
"value": "Preloading images to file cache using option"
},
{
"name": "Load_image_offline_after_preloading",
"value": "Load image (can be loaded offline after preloading)"
},
{
"name": "Preloading_GIF",
"value": "Preloading GIF"
},
{
"name": "Retrieve_GIF_from_memory",
"value": "Retrieve GIF from memory cache"
},
{
"name": "Retrieve_GIF_from_disk",
"value": "Retrieve GIF from disk cache"
},
{
"name": "Preloading_static_images",
"value": "Preloading static images"
},
{
"name": "Retrieve_images_from_memory",
"value": "Retrieve images from memory cache"
},
{
"name": "Retrieve_images_from_disk",
"value": "Retrieve images from memory disk"
},
{
"name": "Write_memory_and_file",
"value": "Write to memory and file cache"
},
{
"name": "Write_memory",
"value": "Write to memory cache"
},
{
"name": "Write_file",
"value": "Write to file cache"
},
{
"name": "Main_image_Fill",
"value": "Main image Fill Stretch Fill"
},
{
"name": "Maintain_proportion_filling",
"value": "Maintain proportion filling in the placeholder map 'Include'"
},
{
"name": "Error_graph_None",
"value": "Error graph None remains unchanged"
},
{
"name": "Test_failure_success",
"value": "Test failure/success"
},
{
"name": "Custom_download_failed",
"value": "Custom download failed"
},
{
"name": "Retrieve_media_gallery",
"value": "Retrieve the URI of the media gallery and display it using ImageKnife"
},
{
"name": "Click_load_Uri",
"value": "Click to load Uri and display"
},
{
"name": "Delete_all_caches",
"value": "Delete all caches"
},
{
"name": "Delete_all_memory_caches",
"value": "Delete all memory caches"
},
{
"name": "Delete_all_file_caches",
"value": "Delete all file caches"
},
{
"name": "Delete_all_custom_memory_caches",
"value": "Delete all custom memory caches"
},
{
"name": "Delete_all_custom_file_caches",
"value": "Delete all custom file caches"
},
{
"name": "Blur_effect",
"value": "Blur effect"
},
{
"name": "Highlighting_effect",
"value": "Highlighting effect"
},
{
"name": "Ashing_effect",
"value": "Ashing effect"
},
{
"name": "Inverse_effect",
"value": "Inverse effect"
},
{
"name": "Animation_filter_effect",
"value": "Animation filter effect"
},
{
"name": "Crop_circular_effect",
"value": "Crop circular effect"
},
{
"name": "Crop_circular_with_border_effect",
"value": "Crop circular with border effect"
},
{
"name": "Contrast_effect",
"value": "Contrast effect"
},
{
"name": "Black_ink_filtering_effect",
"value": "Black ink filtering effect"
},
{
"name": "Rotate",
"value": "Rotate"
},
{
"name": "Corners",
"value": "Corners"
},
{
"name": "Kuwahara_Filter_effect",
"value": "Kuwahara filter effect"
},
{
"name": "Pixelated_Filter_effect",
"value": "Pixelated filtering effect"
},
{
"name": "Sketch_Filter_effect",
"value": "Sketch Filter effect"
},
{
"name": "Distortion_Filter_effect",
"value": "Distortion Filter effect"
},
{
"name": "Decorative_Filter_effect",
"value": "Decorative Filter effect"
},
{
"name": "Square_cutting_effect",
"value": "Square cutting effect"
},
{
"name": "Top_cutting_effect",
"value": "Top cutting effect"
},
{
"name": "Middle_cutting_effect",
"value": "Middle cutting effect"
},
{
"name": "Bottom_cutting_effect",
"value": "Bottom cutting effect"
},
{
"name": "Mask_effect",
"value": "Mask effect"
},
{
"name": "TIPS",
"value": "Please shut down the network first and ensure that there is no cache of images from this network in the test failure scenario locally"
},
{
"name": "Network_reload",
"value": "Network recovery reload"
},
{
"name": "preloading_prefetch",
"value": "Dynamic preloading prefetch"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -40,6 +40,10 @@
"name": "Test_SingleImage", "name": "Test_SingleImage",
"value": "单个图片使用" "value": "单个图片使用"
}, },
{
"name": "Test_LocalImageShow",
"value": "本地图片显示"
},
{ {
"name": "Test_custom_download", "name": "Test_custom_download",
"value": "全局自定义下载" "value": "全局自定义下载"
@ -102,11 +106,11 @@
}, },
{ {
"name": "Display_the_first_frame", "name": "Display_the_first_frame",
"value": "动画显示第一帧" "value": "第一帧"
}, },
{ {
"name": "Display_the_last_frame", "name": "Display_the_last_frame",
"value": "动画显示最后一帧" "value": "最后一帧"
}, },
{ {
"name": "Play", "name": "Play",
@ -136,9 +140,21 @@
"name": "Local_SVG", "name": "Local_SVG",
"value": "本地资源SVG图片" "value": "本地资源SVG图片"
}, },
{
"name": "local_r_file",
"value": "本地$r文件"
},
{
"name": "local_rawfile",
"value": "本地rawfile文件"
},
{ {
"name": "Under_context_file", "name": "Under_context_file",
"value": "本地context files下文件" "value": "本地沙箱路径文件"
},
{
"name": "local_other_module",
"value": "本地其他模块文件"
}, },
{ {
"name": "Network_images", "name": "Network_images",
@ -558,7 +574,7 @@
}, },
{ {
"name": "img_frame", "name": "img_frame",
"value": "片的帧数:%d " "value": "图帧数:%d "
}, },
{ {
"name": "img_content_size", "name": "img_content_size",
@ -582,15 +598,15 @@
}, },
{ {
"name": "req_start_time", "name": "req_start_time",
"value": "图片的请求开始时间:%s " "value": "请求开始时间:%s "
}, },
{ {
"name": "req_end_time", "name": "req_end_time",
"value": "图片请求结束时间:%s " "value": "请求结束时间:%s "
}, },
{ {
"name": "req_cancel_time", "name": "req_cancel_time",
"value": "图片请求取消时间:%s " "value": "请求取消时间:%s "
}, },
{ {
"name": "memory_start_time", "name": "memory_start_time",
@ -625,8 +641,8 @@
"value": "解码结束时间点:%s " "value": "解码结束时间点:%s "
}, },
{ {
"name": "render_time", "name": "request_data_from",
"value": "渲染成功的时间:%s " "value": "请求数据来自于:%s "
}, },
{ {
"name": "Image_Downsampling_Functionality", "name": "Image_Downsampling_Functionality",
@ -643,6 +659,46 @@
{ {
"name": "After_the_sampling", "name": "After_the_sampling",
"value": "降采样后大小" "value": "降采样后大小"
},
{
"name": "adjust_size",
"value": "调整大小"
},
{
"name": "Auto_ImageFit",
"value": "ImageFit.Auto:自适用图片高度"
},
{
"name": "Single_CallBack",
"value": "单个图片回调"
},
{
"name": "Multiple_CallBack",
"value": "多张图片回调"
},
{
"name": "Error_Message",
"value": "错误信息"
},
{
"name": "base_image",
"value": "图片不携带旋转信息"
},
{
"name": "test_exif",
"value": "测试图片携带的EXIF元数据作为显示方向"
},
{
"name": "rotate_mirror",
"value": "水平翻转"
},
{
"name": "rotate_rotate90",
"value": "顺时针90°"
},
{
"name": "rotate_mirror_rotate270",
"value": "水平翻转后再顺时针270°"
} }
] ]
} }

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import { ImageKnifeOption, ImageKnifeRequest } from '@ohos/imageknife/Index'; import { ImageKnifeOption, ImageKnifeRequest } from '@ohos/imageknife';
import { DefaultJobQueue } from '@ohos/imageknife/src/main/ets/queue/DefaultJobQueue'; import { DefaultJobQueue } from '@ohos/imageknife/src/main/ets/queue/DefaultJobQueue';
import { IJobQueue } from '@ohos/imageknife/src/main/ets/queue/IJobQueue'; import { IJobQueue } from '@ohos/imageknife/src/main/ets/queue/IJobQueue';
import taskpool from '@ohos.taskpool'; import taskpool from '@ohos.taskpool';

View File

@ -44,7 +44,7 @@ export default function ImageKnifeOptionTest() {
imageWidth: 0, imageWidth: 0,
imageHeight: 0, imageHeight: 0,
} }
let ImageKnifeOption: ImageKnifeOption = { let imageKnifeOption: ImageKnifeOption = {
loadSrc: $r("app.media.rabbit"), loadSrc: $r("app.media.rabbit"),
onLoadListener: { onLoadListener: {
onLoadFailed: (err) => { onLoadFailed: (err) => {
@ -59,9 +59,9 @@ export default function ImageKnifeOptionTest() {
}, },
}, },
} }
if (ImageKnifeOption.onLoadListener && ImageKnifeOption.onLoadListener.onLoadSuccess && ImageKnifeOption.onLoadListener.onLoadFailed) { if (imageKnifeOption.onLoadListener && imageKnifeOption.onLoadListener.onLoadSuccess && imageKnifeOption.onLoadListener.onLoadFailed) {
ImageKnifeOption.onLoadListener.onLoadSuccess(a,imageData); imageKnifeOption.onLoadListener.onLoadSuccess(a,imageData);
ImageKnifeOption.onLoadListener.onLoadFailed(a); imageKnifeOption.onLoadListener.onLoadFailed(a);
} }
expect(a).assertEqual(b); expect(a).assertEqual(b);
}); });

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2024 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 '@ohos/hypium';
import { ImageKnifeOption,ImageKnifeData } from "@ohos/imageknife"
export default function ImageKnifeOptionTest() {
describe('ImageKnifeOptionTest',() => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
});
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
});
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
});
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
});
it('onLoadListener', 0, () => {
let a = 'abc';
let b: string = '';
let imageData:ImageKnifeData = {
source: "",
imageWidth: 0,
imageHeight: 0,
}
let imageKnifeOption: ImageKnifeOption = {
loadSrc: $r("app.media.rabbit"),
onLoadListener: {
onLoadFailed: (err) => {
console.error("Load Failed Reason: " + err);
},
onLoadSuccess: (data,imageknifeData) => {
if(typeof data == 'string') {
return b = data;
}
imageData = imageknifeData
return data;
},
},
}
if (imageKnifeOption.onLoadListener && imageKnifeOption.onLoadListener.onLoadSuccess && imageKnifeOption.onLoadListener.onLoadFailed) {
imageKnifeOption.onLoadListener.onLoadSuccess(a,imageData);
imageKnifeOption.onLoadListener.onLoadFailed(a);
}
expect(a).assertEqual(b);
});
});
}

View File

@ -14,7 +14,7 @@
*/ */
import DefaultJobQueueTest from './DefaultJobQueueTest.test'; import DefaultJobQueueTest from './DefaultJobQueueTest.test';
import FileLruCacheTest from './FileLruCache.test'; import FileLruCacheTest from './FileLruCache.test';
import ImageKnifeOptionTest from './ImageKnifeOption.test'; import ImageKnifeOptionTest from './ImageknifeOption.test';
import MemoryLruCacheTest from './MemoryLruCache.test'; import MemoryLruCacheTest from './MemoryLruCache.test';
import ImageKnifeTest from './ImageKnife.test'; import ImageKnifeTest from './ImageKnife.test';
import Transform from './transform.test'; import Transform from './transform.test';

View File

@ -13,8 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { image } from '@kit.ImageKit'
import { BusinessError } from '@kit.BasicServicesKit'
import { Downsampler } from '@ohos/imageknife/src/main/ets/downsampling/Downsampler' import { Downsampler } from '@ohos/imageknife/src/main/ets/downsampling/Downsampler'
import { DownsampleStrategy } from '@ohos/imageknife' import { DownsampleStrategy } from '@ohos/imageknife'
@ -63,14 +61,14 @@ export default function SamplingTest() {
it('CENTER_OUTSIDE_MEMORY', 3, () => { it('CENTER_OUTSIDE_MEMORY', 3, () => {
let reqSize: Size = let reqSize: Size =
new Downsampler().calculateScaling('jpg', 1024, 1024, 200, new Downsampler().calculateScaling('jpg', 1024, 1024, 200,
200, DownsampleStrategy.CENTER_OUTSIDE_MEMORY) 200, DownsampleStrategy.CENTER_INSIDE_MEMORY)
let req = (reqSize.width < 1024 && reqSize.height < 1024) let req = (reqSize.width < 1024 && reqSize.height < 1024)
expect(req).assertEqual(true); expect(req).assertEqual(true);
}) })
it('CENTER_OUTSIDE_QUALITY', 4, () => { it('CENTER_OUTSIDE_QUALITY', 4, () => {
let reqSize: Size = let reqSize: Size =
new Downsampler().calculateScaling('jpg', 1024, 1024, 200, new Downsampler().calculateScaling('jpg', 1024, 1024, 200,
200, DownsampleStrategy.CENTER_OUTSIDE_QUALITY) 200, DownsampleStrategy.CENTER_INSIDE_QUALITY)
let req = (reqSize.width < 1024 && reqSize.height < 1024) let req = (reqSize.width < 1024 && reqSize.height < 1024)
expect(req).assertEqual(true); expect(req).assertEqual(true);
}) })

View File

@ -17,7 +17,6 @@ import {
ImageKnifeOption, ImageKnifeOption,
ImageKnife, ImageKnife,
ImageKnifeRequest, ImageKnifeRequest,
ImageKnifeRequestSource,
CacheStrategy CacheStrategy
} from "@ohos/imageknife" } from "@ohos/imageknife"
import { common } from '@kit.AbilityKit'; import { common } from '@kit.AbilityKit';

View File

@ -17,8 +17,7 @@ import {
ImageKnifeOption, ImageKnifeOption,
ImageKnife, ImageKnife,
ImageKnifeRequest, ImageKnifeRequest,
ImageKnifeRequestSource, ImageKnifeData
CacheStrategy
} from "@ohos/imageknife" } from "@ohos/imageknife"
import { common } from '@kit.AbilityKit'; import { common } from '@kit.AbilityKit';
@ -44,8 +43,8 @@ export default function loadCallBackData() {
// This API supports only one parameter: clear action function. // This API supports only one parameter: clear action function.
}); });
it('startAndSuccess-CallBack', 0, async () => { it('startAndSuccess-CallBack', 0, async () => {
let startCallBack: ESObject = undefined; let startCallBack: ImageKnifeData | undefined = undefined;
let successCallBack: ESObject = undefined; let successCallBack: ImageKnifeData | undefined = undefined;
let url: string = let url: string =
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/63/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg" "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/63/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg"
let imageKnifeOption: ImageKnifeOption = { let imageKnifeOption: ImageKnifeOption = {
@ -54,10 +53,10 @@ export default function loadCallBackData() {
await new Promise<string>((resolve, reject) => { await new Promise<string>((resolve, reject) => {
imageKnifeOption.onLoadListener = { imageKnifeOption.onLoadListener = {
onLoadStart: (data) => { onLoadStart: (data) => {
startCallBack = data?.getImageKnifeData(); startCallBack = data?.imageKnifeData;
}, },
onLoadSuccess: (data, imageknifeData,req) => { onLoadSuccess: (data, imageknifeData,req) => {
successCallBack = req?.getImageKnifeData(); successCallBack = req?.imageKnifeData;
resolve("") resolve("")
}, },
onLoadFailed(err) { onLoadFailed(err) {
@ -81,7 +80,7 @@ export default function loadCallBackData() {
expect(successCallBack != undefined).assertTrue(); expect(successCallBack != undefined).assertTrue();
}); });
it('failed-CallBack', 0, async () => { it('failed-CallBack', 0, async () => {
let failedCallBack: ESObject = undefined; let failedCallBack: ImageKnifeData | undefined = undefined;
let url: string = let url: string =
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/163/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg" "https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/163/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg"
let imageKnifeOption: ImageKnifeOption = { let imageKnifeOption: ImageKnifeOption = {
@ -94,7 +93,7 @@ export default function loadCallBackData() {
onLoadSuccess: (data, imageknifeData) => { onLoadSuccess: (data, imageknifeData) => {
}, },
onLoadFailed(res,req) { onLoadFailed(res,req) {
failedCallBack = req?.getImageKnifeData(); failedCallBack = req?.imageKnifeData;
resolve(res) resolve(res)
} }
} }

View File

@ -5,8 +5,11 @@
"description": "$string:module_test_desc", "description": "$string:module_test_desc",
"mainElement": "TestAbility", "mainElement": "TestAbility",
"deviceTypes": [ "deviceTypes": [
"phone", "default",
"tablet", "tablet",
"tv",
"wearable",
"car",
"2in1" "2in1"
], ],
"deliveryWithInstall": true, "deliveryWithInstall": true,

View File

@ -1,7 +1,11 @@
## 1.0.3 ## 1.0.4
- 修改门禁编译问题 修改点如下 - 修改门禁编译问题 修改点如下
- 修改src/main/cpp/boundscheck/CMakeLists.txt文件中的内容
- 修改src/main/cpp/util/DebugLog.h文件中hilog的大小写 - 修改src/main/cpp/util/DebugLog.h文件中hilog的大小写
## 1.0.3
- 安全编译开启Strip和Ftrapv
## 1.0.2 ## 1.0.2
- 支持x86编译 - 支持x86编译

View File

@ -3,7 +3,7 @@
"buildOption": { "buildOption": {
"externalNativeOptions": { "externalNativeOptions": {
"path": "./src/main/cpp/CMakeLists.txt", "path": "./src/main/cpp/CMakeLists.txt",
"arguments": "", "arguments": " -DCMAKE_BUILD_TYPE=Release",
"abiFilters": [ "abiFilters": [
"armeabi-v7a", "armeabi-v7a",
"arm64-v8a", "arm64-v8a",

View File

@ -14,7 +14,7 @@
"main": "index.ets", "main": "index.ets",
"repository": "https://gitee.com/openharmony-tpc/ImageKnife", "repository": "https://gitee.com/openharmony-tpc/ImageKnife",
"type": "module", "type": "module",
"version": "1.0.3", "version": "1.0.4",
"tags": [ "tags": [
"Tool" "Tool"
], ],

View File

@ -11,8 +11,11 @@ include_directories(${NATIVERENDER_ROOT_PATH}
${NATIVERENDER_ROOT_PATH}/common ${NATIVERENDER_ROOT_PATH}/common
${NATIVERENDER_ROOT_PATH}/render ${NATIVERENDER_ROOT_PATH}/render
${NATIVERENDER_ROOT_PATH}/constant ${NATIVERENDER_ROOT_PATH}/constant
${NATIVERENDER_ROOT_PATH}/boundscheck
) )
add_subdirectory(boundscheck)
add_library(nativeGpu SHARED add_library(nativeGpu SHARED
${NATIVERENDER_ROOT_PATH}/napi/napi_init.cpp ${NATIVERENDER_ROOT_PATH}/napi/napi_init.cpp
${NATIVERENDER_ROOT_PATH}/render/EGLRender.cpp ${NATIVERENDER_ROOT_PATH}/render/EGLRender.cpp
@ -30,4 +33,4 @@ find_library (
GLES-lib GLES-lib
GLESv3 ) GLESv3 )
target_link_libraries(nativeGpu PUBLIC ${hilog-lib} ${EGL-lib} ${GLES-lib} libace_napi.z.so libc++.a) target_link_libraries(nativeGpu PUBLIC boundscheck ${hilog-lib} ${EGL-lib} ${GLES-lib} libace_napi.z.so -s -ftrapv)

View File

@ -0,0 +1,27 @@
# the minimum version of CMake.
cmake_minimum_required(VERSION 3.4.1)
set(can_use_assembler TRUE)
enable_language(ASM)
IF("${OHOS_ARCH}" STREQUAL "arm64-v8a")
SET(ASM_OPTIONS "-x assembler-with-cpp")
SET(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS} -march=armv8+crypto -D__OHOS__")
ENDIF()
project(boundscheck)
set(TAGET_BOUNDSCHECK_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/third_party_bounds_checking_function/src)
add_library(boundscheck
STATIC
${TAGET_BOUNDSCHECK_SRC_PATH}/memcpy_s.c
${TAGET_BOUNDSCHECK_SRC_PATH}/memset_s.c
${TAGET_BOUNDSCHECK_SRC_PATH}/securecutil.c)
target_precompile_headers(boundscheck PUBLIC ${CMAKE_SYSROOT}/usr/include/stdint.h)
include_directories(${TAGET_BOUNDSCHECK_SRC_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/third_party_bounds_checking_function/include
)
target_link_libraries(boundscheck)

@ -0,0 +1 @@
Subproject commit a45b3aceed2c0138babc951850445d1cd010ce48

View File

@ -535,7 +535,10 @@ void EGLRender::SetImageData(uint8_t *pData, int width, int height)
m_RenderImage.height = height; m_RenderImage.height = height;
m_RenderImage.format = IMAGE_FORMAT_RGBA; m_RenderImage.format = IMAGE_FORMAT_RGBA;
NativeImageUtil::AllocNativeImage(&m_RenderImage); NativeImageUtil::AllocNativeImage(&m_RenderImage);
memcpy(m_RenderImage.ppPlane[0], pData, width * height * DEFAULT_FOUR); if (memcpy_s(m_RenderImage.ppPlane[0],
width * height * DEFAULT_FOUR, pData, width * height * DEFAULT_FOUR) != EOK) {
return;
}
glBindTexture(GL_TEXTURE_2D, m_ImageTextureId); glBindTexture(GL_TEXTURE_2D, m_ImageTextureId);
glTexImage2D(GL_TEXTURE_2D, glTexImage2D(GL_TEXTURE_2D,

View File

@ -26,6 +26,7 @@
#include <string> #include <string>
#include <string.h> #include <string.h>
#include "DebugLog.h" #include "DebugLog.h"
#include "third_party_bounds_checking_function/include/securec.h"
const int32_t MAX_STR_LENGTH = 1024; const int32_t MAX_STR_LENGTH = 1024;
@ -41,7 +42,7 @@ void NapiUtil::JsValueToString(const napi_env &env, const napi_value &value, con
LOGI("%s nullptr js object to string malloc failed", __func__); LOGI("%s nullptr js object to string malloc failed", __func__);
return; return;
} }
(void) memset(buf.get(), 0, bufLen); (void) memset_s(buf.get(), bufLen, 0, bufLen);
size_t result = 0; size_t result = 0;
napi_get_value_string_utf8(env, value, buf.get(), bufLen, &result); napi_get_value_string_utf8(env, value, buf.get(), bufLen, &result);
target = buf.get(); target = buf.get();

View File

@ -30,6 +30,7 @@
#include <string.h> #include <string.h>
#include "DebugLog.h" #include "DebugLog.h"
#include "constant/constant_shape.h" #include "constant/constant_shape.h"
#include "third_party_bounds_checking_function/include/securec.h"
#define IMAGE_FORMAT_RGBA 0x01 #define IMAGE_FORMAT_RGBA 0x01
#define IMAGE_FORMAT_NV21 0x02 #define IMAGE_FORMAT_NV21 0x02
@ -48,7 +49,7 @@
#define IMAGE_FORMAT_GRAY_EXT "GRAY" #define IMAGE_FORMAT_GRAY_EXT "GRAY"
#define IMAGE_FORMAT_I444_EXT "I444" #define IMAGE_FORMAT_I444_EXT "I444"
#define IMAGE_FORMAT_P010_EXT "P010" // 16bit NV21 #define IMAGE_FORMAT_P010_EXT "P010" // 16bit NV21
#define EOK 0
struct NativeImage { struct NativeImage {
int width; int width;
@ -140,7 +141,9 @@ public:
if (napi_create_arraybuffer(env, srcLen, &nativePtr, res) != napi_ok || nativePtr == nullptr) { if (napi_create_arraybuffer(env, srcLen, &nativePtr, res) != napi_ok || nativePtr == nullptr) {
return false; return false;
} }
memcpy(nativePtr, src, srcLen); if (memcpy_s(nativePtr, srcLen, src, srcLen) != EOK) {
return false;
}
return true; return true;
} }
@ -149,10 +152,17 @@ public:
int totalLength = width * height * DEFAULT_FOUR; int totalLength = width * height * DEFAULT_FOUR;
int oneLineLength = width * DEFAULT_FOUR; int oneLineLength = width * DEFAULT_FOUR;
uint8_t* tmp = (uint8_t*)malloc(totalLength); uint8_t* tmp = (uint8_t*)malloc(totalLength);
memcpy(tmp, *buf, totalLength); if (memcpy_s(tmp, totalLength, *buf, totalLength) != EOK) {
memset(*buf, DEFAULT_ZERO, sizeof(uint8_t)*totalLength); return;
}
if (memset_s(*buf, sizeof(uint8_t)*totalLength, DEFAULT_ZERO, sizeof(uint8_t)*totalLength) != EOK) {
return;
}
for (int i = 0; i < height; i++) { for (int i = 0; i < height; i++) {
memcpy(*buf + oneLineLength * i, tmp + totalLength - oneLineLength * (i+1), oneLineLength); if (memcpy_s(*buf + oneLineLength * i, oneLineLength,
tmp + totalLength - oneLineLength * (i+1), oneLineLength) != EOK) {
break;
}
} }
free(tmp); free(tmp);
} }

View File

@ -1,6 +1,7 @@
{ {
"modelVersion": "5.0.0", "hvigorVersion": "4.0.2",
"dependencies": { "dependencies": {
"@ohos/hvigor-ohos-plugin": "4.0.2"
}, },
"execution": { "execution": {
// "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */
@ -18,4 +19,4 @@
"nodeOptions": { "nodeOptions": {
// "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ // "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */
} }
} }

1
hvigor/hvigor-wrapper.js Normal file

File diff suppressed because one or more lines are too long

48
hvigorw Normal file
View File

@ -0,0 +1,48 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Hvigor startup script, version 1.0.0
#
# Required ENV vars:
# ------------------
# NODE_HOME - location of a Node home dir
# or
# Add /usr/local/nodejs/bin to the PATH environment variable
# ----------------------------------------------------------------------------
HVIGOR_APP_HOME=$(dirname $(readlink -f $0))
HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
warn() {
echo ""
echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}
error() {
echo ""
echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}
fail() {
error "$@"
exit 1
}
# Determine node to start hvigor wrapper script
if [ -n "${NODE_HOME}" ];then
EXECUTABLE_NODE="${NODE_HOME}/bin/node"
if [ ! -x "$EXECUTABLE_NODE" ];then
fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
fi
else
EXECUTABLE_NODE="node"
which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path"
fi
# Check hvigor wrapper script
if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then
fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
fi
# start hvigor-wrapper script
exec "${EXECUTABLE_NODE}" \
"${HVIGOR_WRAPPER_SCRIPT}" "$@"

57
hvigorw.bat Normal file
View File

@ -0,0 +1,57 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Hvigor 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
set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
set NODE_EXE=node.exe
goto start
:start
@rem Find node.exe
if defined NODE_HOME goto findNodeFromNodeHome
%NODE_EXE% --version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
goto fail
:findNodeFromNodeHome
set NODE_HOME=%NODE_HOME:"=%
set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%
if exist "%NODE_EXE_PATH%" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
goto fail
:execute
@rem Execute hvigor
"%NODE_EXE%" %WRAPPER_MODULE_PATH% %*
:fail
exit /b 1

View File

@ -18,7 +18,10 @@ export { ImageKnifeAnimatorComponent } from './src/main/ets/components/ImageKnif
export { ImageKnife } from './src/main/ets/ImageKnife' export { ImageKnife } from './src/main/ets/ImageKnife'
export { ImageKnifeOption , AnimatorOption } from './src/main/ets/model/ImageKnifeOption' export { ImageKnifeOption,
AnimatorOption,
HttpRequestOption,
HeaderOptions } from './src/main/ets/model/ImageKnifeOption'
export { ImageKnifeRequest } from './src/main/ets/model/ImageKnifeRequest' export { ImageKnifeRequest } from './src/main/ets/model/ImageKnifeRequest'
@ -68,4 +71,4 @@ export { CropTransformation } from './src/main/ets/transform/CropTransformation'
export { MaskTransformation } from './src/main/ets/transform/MaskTransformation' export { MaskTransformation } from './src/main/ets/transform/MaskTransformation'
export { SepiaTransformation } from './src/main/ets/transform/SepiaTransformation' export { SepiaTransformation } from './src/main/ets/transform/SepiaTransformation'

View File

@ -14,7 +14,7 @@
"main": "index.ets", "main": "index.ets",
"repository": "https://gitee.com/openharmony-tpc/ImageKnife", "repository": "https://gitee.com/openharmony-tpc/ImageKnife",
"type": "module", "type": "module",
"version": "3.2.0-rc.2", "version": "3.2.2-rc.1",
"dependencies": { "dependencies": {
"@ohos/gpu_transform": "^1.0.2" "@ohos/gpu_transform": "^1.0.2"
}, },

View File

@ -25,6 +25,7 @@ import { util } from '@kit.ArkTS';
import { image } from '@kit.ImageKit'; import { image } from '@kit.ImageKit';
import { common } from '@kit.AbilityKit'; import { common } from '@kit.AbilityKit';
import { LogUtil } from './utils/LogUtil'; import { LogUtil } from './utils/LogUtil';
import { emitter } from '@kit.BasicServicesKit';
export class ImageKnife { export class ImageKnife {
@ -152,7 +153,7 @@ export class ImageKnife {
*/ */
preload(loadSrc:string | ImageKnifeOption):ImageKnifeRequest{ preload(loadSrc:string | ImageKnifeOption):ImageKnifeRequest{
let imageKnifeOption = new ImageKnifeOption() let imageKnifeOption = new ImageKnifeOption()
if (typeof loadSrc == "string") { if (typeof loadSrc == 'string') {
imageKnifeOption.loadSrc = loadSrc imageKnifeOption.loadSrc = loadSrc
} else { } else {
imageKnifeOption = loadSrc; imageKnifeOption = loadSrc;
@ -176,6 +177,9 @@ export class ImageKnife {
* @param request 图片请求request * @param request 图片请求request
*/ */
cancel(request:ImageKnifeRequest) { cancel(request:ImageKnifeRequest) {
if (typeof request?.imageKnifeOption.loadSrc === 'string' && !request?.drawMainSuccess) {
emitter.emit(request.imageKnifeOption.loadSrc + request.componentId)
}
request.requestState = ImageKnifeRequestState.DESTROY request.requestState = ImageKnifeRequestState.DESTROY
} }
/** /**
@ -186,15 +190,15 @@ export class ImageKnife {
preLoadCache(loadSrc: string | ImageKnifeOption): Promise<string> { preLoadCache(loadSrc: string | ImageKnifeOption): Promise<string> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let imageKnifeOption = new ImageKnifeOption() let imageKnifeOption = new ImageKnifeOption()
if (typeof loadSrc == "string") { if (typeof loadSrc == 'string') {
imageKnifeOption.loadSrc = loadSrc imageKnifeOption.loadSrc = loadSrc
} else { } else {
imageKnifeOption = loadSrc; imageKnifeOption = loadSrc;
} }
LogUtil.log("ImageKnife_DataTime_preLoadCache-imageKnifeOption:"+loadSrc) LogUtil.log('ImageKnife_DataTime_preLoadCache-imageKnifeOption:'+loadSrc)
let fileKey = this.getEngineKeyImpl().generateFileKey(imageKnifeOption.loadSrc, imageKnifeOption.signature) let fileKey = this.getEngineKeyImpl().generateFileKey(imageKnifeOption.loadSrc, imageKnifeOption.signature)
let cachePath = ImageKnife.getInstance().getFileCache().getFileToPath(fileKey) let cachePath = ImageKnife.getInstance().getFileCache().getFileToPath(fileKey)
if (cachePath == null || cachePath == "" || cachePath == undefined) { if (cachePath == null || cachePath == '' || cachePath == undefined) {
imageKnifeOption.onLoadListener = { imageKnifeOption.onLoadListener = {
onLoadSuccess(){ onLoadSuccess(){
resolve(ImageKnife.getInstance().getFileCache().getFileToPath(fileKey)) resolve(ImageKnife.getInstance().getFileCache().getFileToPath(fileKey))
@ -317,14 +321,14 @@ export class ImageKnife {
} }
loadFromMemoryCache(key: string): ImageKnifeData | undefined { loadFromMemoryCache(key: string): ImageKnifeData | undefined {
if (key !== "") { if (key !== '') {
return this.memoryCache.get(key) return this.memoryCache.get(key)
} }
return undefined return undefined
} }
saveMemoryCache(key: string, data: ImageKnifeData): void { saveMemoryCache(key: string, data: ImageKnifeData): void {
if (key !== "") { if (key !== '') {
this.memoryCache.put(key, data) this.memoryCache.put(key, data)
} }
} }
@ -356,7 +360,7 @@ export class ImageKnife {
if (this.isFileCacheInit()) { if (this.isFileCacheInit()) {
return this.fileCache?.maxMemory; return this.fileCache?.maxMemory;
} else { } else {
throw new Error("the disk cache not init"); throw new Error('the disk cache not init');
} }
} }
} }
@ -376,7 +380,7 @@ export class ImageKnife {
if (this.isFileCacheInit()) { if (this.isFileCacheInit()) {
return this.fileCache?.size(); return this.fileCache?.size();
} else { } else {
throw new Error("the disk cache not init"); throw new Error('the disk cache not init');
} }
} }
} }
@ -396,7 +400,7 @@ export class ImageKnife {
if (this.isFileCacheInit()) { if (this.isFileCacheInit()) {
return this.fileCache?.currentMemory; return this.fileCache?.currentMemory;
} else { } else {
throw new Error("the disk cache not init"); throw new Error('the disk cache not init');
} }
} }
} }
@ -424,7 +428,7 @@ export class ImageKnife {
if (typeValue === 'gif' || typeValue === 'webp') { if (typeValue === 'gif' || typeValue === 'webp') {
let base64Help = new util.Base64Helper() let base64Help = new util.Base64Helper()
let base64str = "data:image/" + typeValue + ";base64," + base64Help.encodeToStringSync(new Uint8Array(buffer)) let base64str = 'data:image/' + typeValue + ';base64,' + base64Help.encodeToStringSync(new Uint8Array(buffer))
onComplete({ onComplete({
source: base64str, source: base64str,
imageWidth: 0, imageWidth: 0,
@ -462,13 +466,13 @@ export class ImageKnife {
return false return false
} }
async execute(request: ImageKnifeRequest,isAnimator?: boolean): Promise<void> { async execute(request: ImageKnifeRequest): Promise<void> {
LogUtil.log("ImageKnife_DataTime_execute.start:"+request.imageKnifeOption.loadSrc) LogUtil.log('ImageKnife_DataTime_execute.start:'+request.imageKnifeOption.loadSrc)
if (this.headerMap.size > 0) { if (this.headerMap.size > 0) {
request.addHeaderMap(this.headerMap) request.addHeaderMap(this.headerMap)
} }
this.dispatcher.enqueue(request,isAnimator) this.dispatcher.enqueue(request)
LogUtil.log("ImageKnife_DataTime_execute.end:"+request.imageKnifeOption.loadSrc) LogUtil.log('ImageKnife_DataTime_execute.end:'+request.imageKnifeOption.loadSrc)
} }
setEngineKeyImpl(impl: IEngineKey): void { setEngineKeyImpl(impl: IEngineKey): void {

View File

@ -24,7 +24,6 @@ import image from '@ohos.multimedia.image';
import emitter from '@ohos.events.emitter'; import emitter from '@ohos.events.emitter';
import { Constants, LoadPhase, LoadPixelMapCode } from './utils/Constants'; import { Constants, LoadPhase, LoadPixelMapCode } from './utils/Constants';
import taskpool from '@ohos.taskpool'; import taskpool from '@ohos.taskpool';
import { FileTypeUtil } from './utils/FileTypeUtil';
import { IEngineKey } from './key/IEngineKey'; import { IEngineKey } from './key/IEngineKey';
import { DefaultEngineKey } from './key/DefaultEngineKey'; import { DefaultEngineKey } from './key/DefaultEngineKey';
import { import {
@ -49,10 +48,10 @@ export class ImageKnifeDispatcher {
private engineKey: IEngineKey = new DefaultEngineKey(); private engineKey: IEngineKey = new DefaultEngineKey();
showFromMemomry(request: ImageKnifeRequest, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,isAnimator?: boolean): boolean { showFromMemomry(request: ImageKnifeRequest, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,isAnimator?: boolean): boolean {
LogUtil.log("ImageKnife_DataTime_showFromMemomry.start:" + request.imageKnifeOption.loadSrc + "requestSource=" + requestSource + " isAnimator=" + isAnimator) LogUtil.log('showFromMemomry.start:' + request.componentId + ',srcType:' + requestSource + ',version:' + request.componentVersion + ' isAnimator=' + isAnimator)
let memoryCache: ImageKnifeData | undefined; let memoryCache: ImageKnifeData | undefined;
let memoryCheckStartTime = Date.now(); let memoryCheckStartTime = Date.now();
if ((typeof (request.imageKnifeOption.loadSrc as image.PixelMap).isEditable) == 'boolean') { if ((typeof (request.imageKnifeOption.loadSrc as image.PixelMap)?.isEditable) == 'boolean') {
memoryCache = { memoryCache = {
source: request.imageKnifeOption.loadSrc as image.PixelMap, source: request.imageKnifeOption.loadSrc as image.PixelMap,
imageWidth: 0, imageWidth: 0,
@ -60,12 +59,12 @@ export class ImageKnifeDispatcher {
} }
} else { } else {
memoryCache = ImageKnife.getInstance() memoryCache = ImageKnife.getInstance()
.loadFromMemoryCache(this.engineKey.generateMemoryKey(imageSrc, requestSource, request.imageKnifeOption,isAnimator)); .loadFromMemoryCache(this.engineKey.generateMemoryKey(imageSrc, requestSource, request.imageKnifeOption,isAnimator, request.componentWidth, request.componentHeight));
} }
//记录ImageKnifeRequestSource.SRC 开始内存检查的时间点 //记录ImageKnifeRequestSource.SRC 开始内存检查的时间点
if (requestSource == ImageKnifeRequestSource.SRC && request.getImageKnifeData()) { if (requestSource == ImageKnifeRequestSource.SRC && request.imageKnifeData) {
let timeInfo = request.getImageKnifeData()?.timeInfo let timeInfo = request.imageKnifeData?.timeInfo
if (timeInfo) { if (timeInfo) {
timeInfo.memoryCheckStartTime = memoryCheckStartTime; timeInfo.memoryCheckStartTime = memoryCheckStartTime;
timeInfo.memoryCheckEndTime = Date.now(); timeInfo.memoryCheckEndTime = Date.now();
@ -82,29 +81,26 @@ export class ImageKnifeDispatcher {
// 回调请求开始 // 回调请求开始
if (requestSource === ImageKnifeRequestSource.SRC && request.imageKnifeOption.onLoadListener?.onLoadStart !== undefined) { if (requestSource === ImageKnifeRequestSource.SRC && request.imageKnifeOption.onLoadListener?.onLoadStart !== undefined) {
request.imageKnifeOption.onLoadListener.onLoadStart(request) request.imageKnifeOption.onLoadListener.onLoadStart(request)
LogUtil.log("ImageKnife_DataTime_MemoryCache_onLoadStart:" + request.imageKnifeOption.loadSrc)
} }
LogUtil.log("ImageKnife_DataTime_MemoryCache_showPixelMap.start:" + request.imageKnifeOption.loadSrc)
request.ImageKnifeRequestCallback?.showPixelMap(request.componentVersion, memoryCache.source, request.ImageKnifeRequestCallback?.showPixelMap(request.componentVersion, memoryCache.source,
{ width: memoryCache.imageWidth, height: memoryCache.imageHeight }, requestSource, memoryCache.imageAnimator) { width: memoryCache.imageWidth, height: memoryCache.imageHeight }, requestSource, memoryCache.imageAnimator)
LogUtil.log("ImageKnife_DataTime_MemoryCache_showPixelMap.end:" + request.imageKnifeOption.loadSrc)
if (requestSource == ImageKnifeRequestSource.SRC) { if (requestSource == ImageKnifeRequestSource.SRC) {
request.requestState = ImageKnifeRequestState.COMPLETE request.requestState = ImageKnifeRequestState.COMPLETE
request.drawMainSuccess = true
// 回调请求开结束 // 回调请求开结束
if (request.imageKnifeOption.onLoadListener?.onLoadSuccess !== undefined) { if (request.imageKnifeOption.onLoadListener?.onLoadSuccess !== undefined) {
this.copyMemoryCacheInfo(memoryCache, request.getImageKnifeData()); this.copyMemoryCacheInfo(memoryCache, request.imageKnifeData);
request.imageKnifeOption.onLoadListener.onLoadSuccess(memoryCache.source, memoryCache, request) request.imageKnifeOption.onLoadListener.onLoadSuccess(memoryCache.source, memoryCache, request)
LogUtil.log("ImageKnife_DataTime_MemoryCache_onLoadSuccess:" + request.imageKnifeOption.loadSrc)
} }
} else if (requestSource == ImageKnifeRequestSource.ERROR_HOLDER) { } else if (requestSource == ImageKnifeRequestSource.ERROR_HOLDER) {
request.requestState = ImageKnifeRequestState.ERROR request.requestState = ImageKnifeRequestState.ERROR
} }
} }
LogUtil.log("ImageKnife_DataTime_showFromMemomry.end_hasmemory:" + request.imageKnifeOption.loadSrc) LogUtil.log('showFromMemomry.end_hasmemory:' + request.componentId + ',srcType:' + requestSource + ',version:' + request.componentVersion)
return true return true
} }
LogUtil.log("ImageKnife_DataTime_showFromMemomry.end_nomemory:" + request.imageKnifeOption.loadSrc) LogUtil.log('showFromMemomry.end_nomemory:' + request.componentId + ',srcType:' + requestSource + ',version:' + request.componentVersion)
return false return false
} }
@ -116,6 +112,7 @@ export class ImageKnifeDispatcher {
target.imageWidth = memoryCache.imageWidth; target.imageWidth = memoryCache.imageWidth;
target.imageHeight = memoryCache.imageHeight; target.imageHeight = memoryCache.imageHeight;
target.type = memoryCache.type; target.type = memoryCache.type;
target.bufSize = memoryCache.bufSize
target.imageAnimator = memoryCache.imageAnimator; target.imageAnimator = memoryCache.imageAnimator;
} }
@ -131,7 +128,7 @@ export class ImageKnifeDispatcher {
afterCallData.timeInfo.memoryCheckEndTime = beforeCallData.timeInfo.memoryCheckEndTime; afterCallData.timeInfo.memoryCheckEndTime = beforeCallData.timeInfo.memoryCheckEndTime;
} }
} }
req.setImageKnifeData(afterCallData); req.imageKnifeData = afterCallData;
} }
private initCallData(request: ImageKnifeRequest) { private initCallData(request: ImageKnifeRequest) {
@ -140,7 +137,7 @@ export class ImageKnifeDispatcher {
} }
//图片加载信息回调数据 //图片加载信息回调数据
let callBackData: ImageKnifeData = { let callBackData: ImageKnifeData = {
source: "", source: '',
imageWidth: 0, imageWidth: 0,
imageHeight: 0, imageHeight: 0,
}; };
@ -151,14 +148,14 @@ export class ImageKnifeDispatcher {
callBackData.timeInfo = callBackTimeInfo; callBackData.timeInfo = callBackTimeInfo;
//跟隨請求保存回調信息點 //跟隨請求保存回調信息點
request.setImageKnifeData(callBackData); request.imageKnifeData = callBackData;
} }
enqueue(request: ImageKnifeRequest,isAnimator?: boolean): void { enqueue(request: ImageKnifeRequest,): void {
//初始化加载回调信息 //初始化加载回调信息
this.initCallData(request); this.initCallData(request);
//1.内存有的话直接渲染 //1.内存有的话直接渲染
if (this.showFromMemomry(request, request.imageKnifeOption.loadSrc, ImageKnifeRequestSource.SRC,isAnimator)) { if (this.showFromMemomry(request, request.imageKnifeOption.loadSrc, ImageKnifeRequestSource.SRC,request.animator)) {
return return
} }
// 2.内存获取占位图 // 2.内存获取占位图
@ -172,32 +169,30 @@ export class ImageKnifeDispatcher {
this.jobQueue.add(request) this.jobQueue.add(request)
return return
} }
this.executeJob(request,isAnimator) this.executeJob(request)
} }
executeJob(request: ImageKnifeRequest,isAnimator?: boolean): void { executeJob(request: ImageKnifeRequest): void {
LogUtil.log("ImageKnife_DataTime_executeJob.start:" + request.imageKnifeOption.loadSrc) LogUtil.log('executeJob.start:' + request.componentId + ',version:' + request.componentVersion)
// 加载占位符 // 加载占位符
if (request.imageKnifeOption.placeholderSrc !== undefined && request.drawPlayHolderSuccess == false) { if (request.imageKnifeOption.placeholderSrc !== undefined && request.drawPlayHolderSuccess == false) {
this.getAndShowImage(request, request.imageKnifeOption.placeholderSrc, ImageKnifeRequestSource.PLACE_HOLDER) this.getAndShowImage(request, request.imageKnifeOption.placeholderSrc, ImageKnifeRequestSource.PLACE_HOLDER)
} }
if (request.imageKnifeOption.onLoadListener?.onLoadStart !== undefined) {
request.imageKnifeOption.onLoadListener?.onLoadStart(request)
}
// 加载主图 // 加载主图
this.getAndShowImage(request, request.imageKnifeOption.loadSrc, ImageKnifeRequestSource.SRC,isAnimator) this.getAndShowImage(request, request.imageKnifeOption.loadSrc, ImageKnifeRequestSource.SRC,request.animator)
LogUtil.log("ImageKnife_DataTime_executeJob.end:" + request.imageKnifeOption.loadSrc) LogUtil.log('executeJob.end:' + request.componentId + ',version:' + request.componentVersion)
} }
/** /**
* 获取和显示图片 * 获取和显示图片
*/ */
getAndShowImage(currentRequest: ImageKnifeRequest, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,isAnimator?: boolean): void { getAndShowImage(currentRequest: ImageKnifeRequest, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,isAnimator?: boolean): void {
LogUtil.log("ImageKnife_DataTime_getAndShowImage.start:" + currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage.start:' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
if (requestSource === ImageKnifeRequestSource.SRC && currentRequest.imageKnifeOption.onLoadListener?.onLoadStart !== undefined) {
currentRequest.imageKnifeOption.onLoadListener?.onLoadStart(currentRequest)
LogUtil.log("ImageKnife_DataTime_getAndShowImage_onLoadStart:" + currentRequest.imageKnifeOption.loadSrc)
}
let memoryKey: string = this.engineKey.generateMemoryKey(imageSrc, requestSource, currentRequest.imageKnifeOption,isAnimator) let memoryKey: string = this.engineKey.generateMemoryKey(imageSrc, requestSource, currentRequest.imageKnifeOption,isAnimator, currentRequest.componentWidth, currentRequest.componentHeight)
let requestList: List<ImageKnifeRequestWithSource> | undefined = this.executingJobMap.get(memoryKey) let requestList: List<ImageKnifeRequestWithSource> | undefined = this.executingJobMap.get(memoryKey)
if (requestList == undefined) { if (requestList == undefined) {
requestList = new List() requestList = new List()
@ -207,32 +202,20 @@ export class ImageKnifeDispatcher {
requestList.add({ request: currentRequest, source: requestSource }) requestList.add({ request: currentRequest, source: requestSource })
return return
} }
LogUtil.info('image load getAndShowImage start:' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
let isWatchProgress : boolean = false let isWatchProgress : boolean = false
if (currentRequest.imageKnifeOption.progressListener !== undefined && requestSource === ImageKnifeRequestSource.SRC) { if (currentRequest.imageKnifeOption.progressListener !== undefined && requestSource === ImageKnifeRequestSource.SRC) {
isWatchProgress = true isWatchProgress = true
} }
// 回调请求开始 let src: string | number = ''
requestList.forEach((requestWithSource: ImageKnifeRequestWithSource) => { let moduleName: string = ''
if (requestWithSource.source === ImageKnifeRequestSource.SRC && requestWithSource.request.imageKnifeOption.onLoadListener?.onLoadStart !== undefined) { let resName: string = ''
requestWithSource.request.imageKnifeOption.onLoadListener?.onLoadStart(requestWithSource.request)
LogUtil.log("ImageKnife_DataTime_getAndShowImage_onLoadStart:" + currentRequest.imageKnifeOption.loadSrc)
}
if (requestWithSource.request.imageKnifeOption.progressListener !== undefined && requestWithSource.source === ImageKnifeRequestSource.SRC) {
isWatchProgress = true
}
});
let src: string | number = ""
let moduleName: string = ""
let resName: string = ""
if((imageSrc as Resource).id != undefined) { if((imageSrc as Resource).id != undefined) {
moduleName = (imageSrc as Resource).moduleName moduleName = (imageSrc as Resource).moduleName
src = (imageSrc as Resource).id src = (imageSrc as Resource).id
if(src == -1) { resName = (imageSrc as Resource).params![0]
resName = (imageSrc as Resource).params![0] } else if(typeof imageSrc == 'string') {
}
} else if(typeof imageSrc == "string") {
src = imageSrc src = imageSrc
} }
let request: RequestJobRequest = { let request: RequestJobRequest = {
@ -254,12 +237,17 @@ export class ImageKnifeDispatcher {
memoryKey: memoryKey, memoryKey: memoryKey,
fileCacheFolder: ImageKnife.getInstance().getFileCache()?.getCacheFolder(), fileCacheFolder: ImageKnife.getInstance().getFileCache()?.getCacheFolder(),
isAnimator:isAnimator, isAnimator:isAnimator,
moduleName: moduleName == "" ? undefined : moduleName, moduleName: moduleName == '' ? undefined : moduleName,
resName: resName == "" ? undefined : resName, resName: resName == '' ? undefined : resName,
caPath: currentRequest.imageKnifeOption.caPath, caPath: currentRequest.imageKnifeOption.httpOption?.caPath,
targetWidth: currentRequest.componentWidth, targetWidth: currentRequest.componentWidth,
targetHeight: currentRequest.componentHeight, targetHeight: currentRequest.componentHeight,
downsampType: currentRequest.imageKnifeOption.downsampleOf == undefined ? DownsampleStrategy.NONE : currentRequest.imageKnifeOption.downsampleOf downsampType: currentRequest.imageKnifeOption.downsampleOf == undefined ? DownsampleStrategy.DEFAULT : currentRequest.imageKnifeOption.downsampleOf,
isAutoImageFit: currentRequest.imageKnifeOption.objectFit == ImageFit.Auto,
componentId: currentRequest.componentId,
componentVersion: currentRequest.componentVersion,
connectTimeout: currentRequest.imageKnifeOption.httpOption?.connectTimeout,
readTimeout: currentRequest.imageKnifeOption.httpOption?.readTimeout
} }
if(request.customGetImage == undefined) { if(request.customGetImage == undefined) {
@ -272,50 +260,68 @@ export class ImageKnifeDispatcher {
if (isWatchProgress){ if (isWatchProgress){
emitter.off(Constants.PROGRESS_EMITTER + memoryKey) emitter.off(Constants.PROGRESS_EMITTER + memoryKey)
} }
LogUtil.log("ImageKnife_DataTime_getAndShowImage_execute.end:"+currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage.end:'+ currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
LogUtil.log("ImageKnife_DataTime_getAndShowImage.end:"+currentRequest.imageKnifeOption.loadSrc)
}) })
if (ImageKnife.getInstance().isRequestInSubThread){ if (ImageKnife.getInstance().isRequestInSubThread){
// 启动线程下载和解码主图 // 启动线程下载和解码主图
LogUtil.log("ImageKnife_DataTime_getAndShowImage_Task.start:" + currentRequest.imageKnifeOption.loadSrc) LogUtil.log('etAndShowImage_Task.start:' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
let task = new taskpool.Task(requestJob, request) let task = new taskpool.Task(requestJob, request)
LogUtil.log("ImageKnife_DataTime_getAndShowImage_Task.end:" + currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage_Task.end:' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
if (isWatchProgress){ if (isWatchProgress){
emitter.on(Constants.PROGRESS_EMITTER + memoryKey, (data) => { emitter.on(Constants.PROGRESS_EMITTER + memoryKey, (data) => {
this.progressCallBack(requestList! , data?.data?.value as number) this.progressCallBack(requestList! , data?.data?.value as number)
}); });
} }
LogUtil.log("ImageKnife_DataTime_getAndShowImage_execute.start(subthread):" + currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage_execute.start(subthread):' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
taskpool.execute(task).then((res: Object) => { taskpool.execute(task).then((res: Object) => {
// this.doTaskCallback(res as RequestJobResult | undefined, requestList!, currentRequest, memoryKey, imageSrc, requestSource,isAnimator);
// if (isWatchProgress){
// emitter.off(Constants.PROGRESS_EMITTER + memoryKey)
// }
// LogUtil.log("ImageKnife_DataTime_getAndShowImage_execute.end:"+currentRequest.imageKnifeOption.loadSrc)
// LogUtil.log("ImageKnife_DataTime_getAndShowImage.end:"+currentRequest.imageKnifeOption.loadSrc)
}).catch((err: BusinessError) => { }).catch((err: BusinessError) => {
emitter.off(Constants.CALLBACK_EMITTER + memoryKey) emitter.off(Constants.CALLBACK_EMITTER + memoryKey)
LogUtil.error("Fail to requestJob in sub thread src=" + imageSrc + " err=" + err) LogUtil.error('Fail to requestJob in sub thread src=' + imageSrc + ' err=' + err)
LogUtil.log("ImageKnife_DataTime_getAndShowImage.end:" + currentRequest.imageKnifeOption.loadSrc)
if (isWatchProgress){ if (isWatchProgress){
emitter.off(Constants.PROGRESS_EMITTER + memoryKey) emitter.off(Constants.PROGRESS_EMITTER + memoryKey)
} }
this.executingJobMap.remove(memoryKey);
this.dispatchNextJob(); this.doTaskCallback({
pixelMap: undefined,
bufferSize: 0,
fileKey: '',
loadFail: 'Fail to requestJob in sub thread src=' + imageSrc + ' err=' + err,
imageKnifeData: {
source: '',
imageWidth: 0,
imageHeight: 0,
timeInfo: { requestEndTime: Date.now() },
errorInfo: {
phase: LoadPhase.PHASE_LOAD,
code: LoadPixelMapCode.IMAGE_CUSTOM_LOAD_FAILED_CODE,
}
}
}, requestList!, currentRequest, memoryKey, imageSrc, requestSource, isAnimator)
}) })
} else { //主线程请求 } else { //主线程请求
LogUtil.log("ImageKnife_DataTime_getAndShowImage_execute.start(mainthread):" + currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage_execute.start(mainthread):' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
requestJob(request, requestList).then(() => { requestJob(request, requestList).then(() => {
// this.doTaskCallback(res, requestList!, currentRequest, memoryKey, imageSrc, requestSource,isAnimator);
// LogUtil.log("ImageKnife_DataTime_getAndShowImage_execute.end:"+currentRequest.imageKnifeOption.loadSrc)
// LogUtil.log("ImageKnife_DataTime_getAndShowImage.end:"+currentRequest.imageKnifeOption.loadSrc)
}).catch((err: BusinessError) => { }).catch((err: BusinessError) => {
emitter.off(Constants.CALLBACK_EMITTER + memoryKey) emitter.off(Constants.CALLBACK_EMITTER + memoryKey)
LogUtil.error("Fail to requestJob in main thread src=" + imageSrc + " err=" + err) LogUtil.error('Fail to requestJob in main thread src=' + imageSrc + ' err=' + err)
LogUtil.log("ImageKnife_DataTime_getAndShowImage.end:" + currentRequest.imageKnifeOption.loadSrc)
this.executingJobMap.remove(memoryKey); this.doTaskCallback({
this.dispatchNextJob(); pixelMap: undefined,
bufferSize: 0,
fileKey: '',
loadFail: 'Fail to requestJob in main thread src=' + imageSrc + ' err=' + err,
imageKnifeData: {
source: '',
imageWidth: 0,
imageHeight: 0,
timeInfo: { requestEndTime: Date.now() },
errorInfo: {
phase: LoadPhase.PHASE_LOAD,
code: LoadPixelMapCode.IMAGE_CUSTOM_LOAD_FAILED_CODE,
}
}
}, requestList!, currentRequest, memoryKey, imageSrc, requestSource, isAnimator)
}) })
} }
} }
@ -336,7 +342,7 @@ export class ImageKnifeDispatcher {
private doTaskCallback(requestJobResult: RequestJobResult | undefined, requestList: List<ImageKnifeRequestWithSource> , private doTaskCallback(requestJobResult: RequestJobResult | undefined, requestList: List<ImageKnifeRequestWithSource> ,
currentRequest: ImageKnifeRequest, memoryKey: string, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,isAnimator?: boolean):void { currentRequest: ImageKnifeRequest, memoryKey: string, imageSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,isAnimator?: boolean):void {
LogUtil.log("ImageKnife_DataTime_getAndShowImage_CallBack.start:"+currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage_CallBack.start:' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
if (requestJobResult === undefined){ if (requestJobResult === undefined){
return return
} }
@ -347,20 +353,68 @@ export class ImageKnifeDispatcher {
} }
let pixelmap = requestJobResult.pixelMap; let pixelmap = requestJobResult.pixelMap;
if (pixelmap === undefined) { // 请求取消
LogUtil.log("ImageKnife_DataTime_getAndShowImage_CallBack.pixelmap undefined:"+currentRequest.imageKnifeOption.loadSrc) if (currentRequest.requestState === ImageKnifeRequestState.DESTROY) {
this.executingJobMap.remove(memoryKey);
requestList.forEach((requestWithSource: ImageKnifeRequestWithSource) => { requestList.forEach((requestWithSource: ImageKnifeRequestWithSource) => {
if (currentRequest.componentId !== requestWithSource.request.componentId && requestWithSource.request.requestState !== ImageKnifeRequestState.DESTROY) {
// 加载占位符
if (requestWithSource.source === ImageKnifeRequestSource.PLACE_HOLDER &&
requestWithSource.request.imageKnifeOption.placeholderSrc !== undefined &&
requestWithSource.request.drawPlayHolderSuccess == false) {
this.getAndShowImage(requestWithSource.request, requestWithSource.request.imageKnifeOption.placeholderSrc, ImageKnifeRequestSource.PLACE_HOLDER)
} else if (requestWithSource.source === ImageKnifeRequestSource.ERROR_HOLDER &&
requestWithSource.request.imageKnifeOption.errorholderSrc !== undefined) {
this.getAndShowImage(requestWithSource.request, requestWithSource.request.imageKnifeOption.errorholderSrc, ImageKnifeRequestSource.ERROR_HOLDER)
} else if (requestWithSource.source === ImageKnifeRequestSource.SRC) {
// 加载主图
this.getAndShowImage(requestWithSource.request, requestWithSource.request.imageKnifeOption.loadSrc, ImageKnifeRequestSource.SRC,requestWithSource.request.animator)
}
} else {
if (pixelmap !== undefined && typeof pixelmap !== 'string') {
(pixelmap as PixelMap).release()
}
if (requestWithSource.source == ImageKnifeRequestSource.SRC && requestWithSource.request.imageKnifeOption.onLoadListener?.onLoadCancel) {
// 回调请求成功
// 回调请求成功
//设置失败回调的时间点
let callBackData = requestWithSource.request.imageKnifeData;
if (requestJobResult.imageKnifeData && requestJobResult.imageKnifeData.timeInfo) {
requestJobResult.imageKnifeData.timeInfo.requestCancelTime = Date.now();
if (requestJobResult.imageKnifeData.errorInfo) {
requestJobResult.imageKnifeData.errorInfo.phase = LoadPhase.PHASE_WILL_SHOW;
requestJobResult.imageKnifeData.errorInfo.code = LoadPixelMapCode.IMAGE_LOAD_CANCEL_FAILED_CODE;
}
}
this.assembleImageKnifeData(callBackData,requestJobResult.imageKnifeData,requestWithSource.request)
LogUtil.log('getAndShowImage cancel:' + requestWithSource.request.componentId + ',srcType:' + requestSource + ',version:' + requestWithSource.request.componentVersion)
requestWithSource.request.imageKnifeOption.onLoadListener.onLoadCancel(requestJobResult.loadFail ?? 'component has destroyed from load', requestWithSource.request)
}
}
})
this.dispatchNextJob()
return
}
// 请求失败
if (pixelmap === undefined) {
this.executingJobMap.remove(memoryKey);
requestList.forEach((requestWithSource: ImageKnifeRequestWithSource) => {
requestWithSource.request.requestState = ImageKnifeRequestState.ERROR
LogUtil.error('getAndShowImage_CallBack.pixelmap failed:' + currentRequest.componentId + ',srcType:' +
requestSource + ',version:' + currentRequest.componentVersion + " error: " + requestJobResult.loadFail)
// 回调请求失败 // 回调请求失败
if (requestWithSource.source === ImageKnifeRequestSource.SRC && if (requestWithSource.source === ImageKnifeRequestSource.SRC &&
requestWithSource.request.imageKnifeOption.onLoadListener?.onLoadFailed !== undefined && requestWithSource.request.imageKnifeOption.onLoadListener?.onLoadFailed !== undefined &&
requestJobResult.loadFail) { requestJobResult.loadFail) {
this.assembleImageKnifeData(requestWithSource.request.getImageKnifeData(), requestJobResult.imageKnifeData, requestWithSource.request) this.assembleImageKnifeData(requestWithSource.request.imageKnifeData, requestJobResult.imageKnifeData,
requestWithSource.request.imageKnifeOption.onLoadListener.onLoadFailed(requestJobResult.loadFail,requestWithSource.request); requestWithSource.request)
LogUtil.log("ImageKnife_DataTime_getAndShowImage_onLoadFailed:"+currentRequest.imageKnifeOption.loadSrc) requestWithSource.request.imageKnifeOption.onLoadListener.onLoadFailed(requestJobResult.loadFail,
requestWithSource.request);
} }
if (requestWithSource.source === ImageKnifeRequestSource.SRC && if (requestWithSource.source === ImageKnifeRequestSource.SRC &&
requestWithSource.request.imageKnifeOption.errorholderSrc !== undefined) { requestWithSource.request.imageKnifeOption.errorholderSrc !== undefined) {
requestWithSource.request.requestState = ImageKnifeRequestState.PROGRESS
if (this.showFromMemomry(requestWithSource.request, requestWithSource.request.imageKnifeOption.errorholderSrc, if (this.showFromMemomry(requestWithSource.request, requestWithSource.request.imageKnifeOption.errorholderSrc,
ImageKnifeRequestSource.ERROR_HOLDER) === false) { ImageKnifeRequestSource.ERROR_HOLDER) === false) {
this.getAndShowImage(requestWithSource.request, requestWithSource.request.imageKnifeOption.errorholderSrc, this.getAndShowImage(requestWithSource.request, requestWithSource.request.imageKnifeOption.errorholderSrc,
@ -368,15 +422,14 @@ export class ImageKnifeDispatcher {
} }
} }
}); });
this.executingJobMap.remove(memoryKey);
this.dispatchNextJob(); this.dispatchNextJob();
return; return;
} }
// 保存文件缓存 // 保存文件缓存
if (requestJobResult.bufferSize > 0 && currentRequest.imageKnifeOption.writeCacheStrategy !== CacheStrategy.Memory) { if (requestJobResult.bufferSize > 0 && currentRequest.imageKnifeOption.writeCacheStrategy !== CacheStrategy.Memory) {
LogUtil.log("ImageKnife_DataTime_getAndShowImage_saveWithoutWriteFile.start:"+currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage_saveWithoutWriteFile.start:' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
ImageKnife.getInstance().saveWithoutWriteFile(requestJobResult.fileKey, requestJobResult.bufferSize); ImageKnife.getInstance().saveWithoutWriteFile(requestJobResult.fileKey, requestJobResult.bufferSize);
LogUtil.log("ImageKnife_DataTime_getAndShowImage_saveWithoutWriteFile.end:"+currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage_saveWithoutWriteFile.end:' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
} }
let imageKnifeData: ImageKnifeData; let imageKnifeData: ImageKnifeData;
@ -406,94 +459,80 @@ export class ImageKnifeDispatcher {
//构建缓存保存的ImageKnifeData //构建缓存保存的ImageKnifeData
let saveCacheImageData: ImageKnifeData = { let saveCacheImageData: ImageKnifeData = {
source: pixelmap!, source: pixelmap!,
imageWidth: requestJobResult.size == undefined ? 0 : requestJobResult.size.width, imageWidth: requestJobResult.size?.width ?? 0,
imageHeight: requestJobResult.size == undefined ? 0 : requestJobResult.size.height, imageHeight: requestJobResult.size?.height ?? 0,
type: requestJobResult.type, type: requestJobResult.type,
bufSize: requestJobResult.bufferSize,
imageAnimator: imageKnifeData.imageAnimator imageAnimator: imageKnifeData.imageAnimator
} }
// 保存内存缓存 // 保存内存缓存
if (currentRequest.imageKnifeOption.writeCacheStrategy !== CacheStrategy.File) { if (currentRequest.imageKnifeOption.writeCacheStrategy !== CacheStrategy.File) {
LogUtil.log("ImageKnife_DataTime_getAndShowImage_saveMemoryCache.start:"+currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage_saveMemoryCache.start:' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
ImageKnife.getInstance() ImageKnife.getInstance()
.saveMemoryCache(this.engineKey.generateMemoryKey(imageSrc, requestSource, currentRequest.imageKnifeOption,isAnimator), .saveMemoryCache(this.engineKey.generateMemoryKey(imageSrc, requestSource, currentRequest.imageKnifeOption,isAnimator, currentRequest.componentWidth, currentRequest.componentHeight),
saveCacheImageData); saveCacheImageData);
LogUtil.log("ImageKnife_DataTime_getAndShowImage_saveMemoryCache.end:"+currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage_saveMemoryCache.end:' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
} }
if (requestList !== undefined) { if (requestList !== undefined) {
// key相同的request一起绘制 // key相同的request一起绘制
requestList.forEach((requestWithSource: ImageKnifeRequestWithSource) => { requestList.forEach((requestWithSource: ImageKnifeRequestWithSource) => {
if (requestWithSource.request.requestState !== ImageKnifeRequestState.DESTROY) { // 画主图
// 画主图 if (requestWithSource.source === ImageKnifeRequestSource.SRC ||
if (requestWithSource.source === ImageKnifeRequestSource.SRC || requestWithSource.source === ImageKnifeRequestSource.ERROR_HOLDER
requestWithSource.source === ImageKnifeRequestSource.ERROR_HOLDER || (requestWithSource.source === ImageKnifeRequestSource.PLACE_HOLDER &&
|| (requestWithSource.source === ImageKnifeRequestSource.PLACE_HOLDER && requestWithSource.request.requestState === ImageKnifeRequestState.PROGRESS)) {
requestWithSource.request.requestState === ImageKnifeRequestState.PROGRESS)) { requestWithSource.request.ImageKnifeRequestCallback.showPixelMap(requestWithSource.request.componentVersion,
LogUtil.log("ImageKnife_DataTime_getAndShowImage_showPixelMap.start:"+currentRequest.imageKnifeOption.loadSrc) imageKnifeData.source, { width: imageKnifeData.imageWidth, height: imageKnifeData.imageHeight },
requestWithSource.request.ImageKnifeRequestCallback.showPixelMap(requestWithSource.request.componentVersion, requestWithSource.source, imageKnifeData.imageAnimator);
imageKnifeData.source, { width: imageKnifeData.imageWidth, height: imageKnifeData.imageHeight }, }
requestWithSource.source, imageKnifeData.imageAnimator);
LogUtil.log("ImageKnife_DataTime_getAndShowImage_showPixelMap.end:"+currentRequest.imageKnifeOption.loadSrc)
}
if (requestWithSource.source == ImageKnifeRequestSource.SRC) { if (requestWithSource.source == ImageKnifeRequestSource.SRC) {
requestWithSource.request.requestState = ImageKnifeRequestState.COMPLETE; requestWithSource.request.requestState = ImageKnifeRequestState.COMPLETE;
if (requestWithSource.request.imageKnifeOption.onLoadListener && requestWithSource.request.drawMainSuccess = true
requestWithSource.request.imageKnifeOption.onLoadListener.onLoadSuccess) { if (requestWithSource.request.imageKnifeOption.onLoadListener &&
// 回调请求成功 requestWithSource.request.imageKnifeOption.onLoadListener.onLoadSuccess) {
this.assembleImageKnifeData(requestWithSource.request.getImageKnifeData(), imageKnifeData,requestWithSource.request);
requestWithSource.request.imageKnifeOption.onLoadListener.onLoadSuccess(imageKnifeData.source,
saveCacheImageData, requestWithSource.request);
LogUtil.log("ImageKnife_DataTime_getAndShowImage_onLoadSuccess:"+currentRequest.imageKnifeOption.loadSrc)
}
} else if (requestWithSource.source == ImageKnifeRequestSource.ERROR_HOLDER) {
requestWithSource.request.requestState = ImageKnifeRequestState.ERROR;
}
} else {
if (requestWithSource.source == ImageKnifeRequestSource.SRC && requestWithSource.request.imageKnifeOption.onLoadListener?.onLoadCancel) {
// 回调请求成功 // 回调请求成功
// 回调请求成功 this.assembleImageKnifeData(requestWithSource.request.imageKnifeData, imageKnifeData,
//设置失败回调的时间点 requestWithSource.request);
let callBackData = requestWithSource.request.getImageKnifeData(); requestWithSource.request.imageKnifeOption.onLoadListener.onLoadSuccess(imageKnifeData.source,
saveCacheImageData, requestWithSource.request);
if (requestJobResult.imageKnifeData && requestJobResult.imageKnifeData.timeInfo) {
requestJobResult.imageKnifeData.timeInfo.requestCancelTime = Date.now();
if (requestJobResult.imageKnifeData.errorInfo) {
requestJobResult.imageKnifeData.errorInfo.phase = LoadPhase.PHASE_WILL_SHOW;
requestJobResult.imageKnifeData.errorInfo.code = LoadPixelMapCode.IMAGE_LOAD_CANCEL_FAILED_CODE;
}
}
this.assembleImageKnifeData(callBackData,requestJobResult.imageKnifeData,requestWithSource.request)
requestWithSource.request.imageKnifeOption.onLoadListener.onLoadCancel("component has destroyed", requestWithSource.request)
} }
} else if (requestWithSource.source == ImageKnifeRequestSource.ERROR_HOLDER) {
requestWithSource.request.requestState = ImageKnifeRequestState.ERROR;
} }
}); });
this.executingJobMap.remove(memoryKey); this.executingJobMap.remove(memoryKey);
this.dispatchNextJob(); this.dispatchNextJob();
} else { } else {
LogUtil.log("error: no requestlist need to draw for key = " + memoryKey); LogUtil.log('error: no requestlist need to draw for key = ' + memoryKey);
} }
LogUtil.log("ImageKnife_DataTime_getAndShowImage_CallBack.end:"+currentRequest.imageKnifeOption.loadSrc) LogUtil.log('getAndShowImage_CallBack.end:' + currentRequest.componentId + ',srcType:' + requestSource + ',version:' + currentRequest.componentVersion)
} }
dispatchNextJob() { dispatchNextJob() {
LogUtil.log("ImageKnife_DataTime_dispatchNextJob.start") LogUtil.log('dispatchNextJob.start')
// 主图和错误图并发加载时以及主图加载失败后立即加载错误图可能会导致短时间内并发数超过maxRequests故此处减少响应的并发
if (this.executingJobMap.length >= this.maxRequests) {
return
}
while (true) { while (true) {
let request = this.jobQueue.pop() let request = this.jobQueue.pop()
if (request === undefined) { if (request === undefined) {
LogUtil.log("ImageKnife_DataTime_dispatchNextJob.end:no any job") LogUtil.log('dispatchNextJob.end:no any job')
break // 队列已无任务 break // 队列已无任务
} }
else if (request.requestState === ImageKnifeRequestState.PROGRESS) { else if (request.requestState === ImageKnifeRequestState.PROGRESS) {
LogUtil.log("ImageKnife_DataTime_dispatchNextJob.start executeJob:" + request.imageKnifeOption.loadSrc) LogUtil.log('dispatchNextJob.start executeJob:' + request.componentId + ',version:' + request.componentVersion)
this.executeJob(request) this.executeJob(request)
LogUtil.log("ImageKnife_DataTime_dispatchNextJob.end executeJob:" + request.imageKnifeOption.loadSrc) LogUtil.log('dispatchNextJob.end executeJob:' + request.componentId + ',version:' + request.componentVersion)
break break
}else if (request.requestState == ImageKnifeRequestState.DESTROY && request.imageKnifeOption.onLoadListener?.onLoadCancel) { }else if (request.requestState == ImageKnifeRequestState.DESTROY && request.imageKnifeOption.onLoadListener?.onLoadCancel) {
//构建回调错误信息 //构建回调错误信息
let callBackData = request.getImageKnifeData(); let callBackData = request.imageKnifeData;
if (callBackData) { if (callBackData) {
let timeInfo: TimeInfo = ImageKnifeLoader.getTimeInfo(callBackData) let timeInfo: TimeInfo = ImageKnifeLoader.getTimeInfo(callBackData)
timeInfo.requestCancelTime = Date.now(); timeInfo.requestCancelTime = Date.now();
@ -504,7 +543,8 @@ export class ImageKnifeDispatcher {
}; };
callBackData.errorInfo = errorInfo; callBackData.errorInfo = errorInfo;
} }
request.imageKnifeOption.onLoadListener.onLoadCancel("component has destroyed", request) LogUtil.log('dispatchNextJob cancel:' + request.componentId + ',version:' + request.componentVersion)
request.imageKnifeOption.onLoadListener.onLoadCancel('component has destroyed from queue', request)
} }
} }
} }
@ -532,8 +572,8 @@ export class ImageKnifeDispatcher {
*/ */
@Concurrent @Concurrent
async function requestJob(request: RequestJobRequest, requestList?: List<ImageKnifeRequestWithSource>) { async function requestJob(request: RequestJobRequest, requestList?: List<ImageKnifeRequestWithSource>) {
LogUtil.log("ImageKnife_DataTime_requestJob.start:" + request.src + " requestSource=" + request.requestSource) LogUtil.log('requestJob.start:' + request.componentId + ',srcType:' + request.requestSource + ',' + request.componentVersion)
let src = typeof request.src == "number" ? request.resName != undefined ? request.resName : request.src + "" : request.src let src = typeof request.src == 'number' ? request.resName != undefined ? request.resName : request.src + '' : request.src
// 生成文件缓存key // 生成文件缓存key
let fileKey = request.engineKey.generateFileKey(src, request.signature, request.isAnimator) let fileKey = request.engineKey.generateFileKey(src, request.signature, request.isAnimator)

View File

@ -16,6 +16,7 @@ import {
CacheStrategy, CacheStrategy,
DecodeImageInfo, DecodeImageInfo,
ErrorInfo, ErrorInfo,
FlipRotate,
ImageKnifeData, ImageKnifeData,
ImageKnifeRequestSource, ImageKnifeRequestSource,
ImageKnifeRequestWithSource, RequestJobRequest, ImageKnifeRequestWithSource, RequestJobRequest,
@ -35,6 +36,8 @@ import util from '@ohos.util';
import { FileTypeUtil } from './utils/FileTypeUtil'; import { FileTypeUtil } from './utils/FileTypeUtil';
import { DownsampleStrategy } from './downsampling/DownsampleStartegy'; import { DownsampleStrategy } from './downsampling/DownsampleStartegy';
import { Downsampler } from './downsampling/Downsampler'; import { Downsampler } from './downsampling/Downsampler';
import { common } from '@kit.AbilityKit';
import { ImageLoaderFactory } from './loaderStrategy/ImageLoaderFactory';
class RequestData { class RequestData {
receiveSize: number = 2000 receiveSize: number = 2000
@ -48,13 +51,28 @@ export class ImageKnifeLoader {
static execute(request: RequestJobRequest, requestList: List<ImageKnifeRequestWithSource> | undefined, fileKey: string){ static execute(request: RequestJobRequest, requestList: List<ImageKnifeRequestWithSource> | undefined, fileKey: string){
ImageKnifeLoader.getImageArrayBuffer(request,requestList,fileKey) ImageKnifeLoader.getImageArrayBuffer(request,requestList,fileKey)
} }
static getUnit8Array (resBuf: ArrayBuffer) {
let unit8 = new Uint8Array(resBuf)
let unitString = ''
if (unit8.length >= 3) {
unitString = unit8[0] + ',' + unit8[1] + ',' + unit8[2]
} else if (unit8.length > 0 && unit8.length < 3) {
unitString = unit8.length + ''
}
return unitString
}
static async parseImage(resBuf: ArrayBuffer, fileKey: string, static async parseImage(resBuf: ArrayBuffer, fileKey: string,
request: RequestJobRequest, callBackData: ImageKnifeData) { request: RequestJobRequest, callBackData: ImageKnifeData) {
callBackData.bufSize = resBuf.byteLength; callBackData.bufSize = resBuf.byteLength;
let typeValue = new FileTypeUtil().getFileType(resBuf); let typeValue = new FileTypeUtil().getFileType(resBuf);
if(typeValue == null) { if(typeValue == null) {
LogUtil.log("ImageKnife_DataTime_requestJob.end: getFileType is null " + request.src) LogUtil.log('requestJob.end: getFileType is null: ' + request.componentId + ',srcType:' + request.requestSource + ',' + request.componentVersion)
ImageKnifeLoader.makeEmptyResult(request,"request is not a valid image source", ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_GET_FORMAT, LoadPixelMapCode.IMAGE_PARSE_FORMAT_FAILED_CODE)) ImageKnifeLoader.makeEmptyResult(request,
'request is not a valid image source:' + request.src + ',componentId' + request.componentId + ',srcType:' +
request.requestSource + ',' +
request.componentVersion + ',buffer:' + resBuf.byteLength + ',unit8:' + ImageKnifeLoader.getUnit8Array(resBuf),
ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_GET_FORMAT,
LoadPixelMapCode.IMAGE_PARSE_FORMAT_FAILED_CODE))
return return
} }
callBackData.type = typeValue; callBackData.type = typeValue;
@ -66,7 +84,7 @@ export class ImageKnifeLoader {
if (typeValue === 'gif' || typeValue === 'webp') { if (typeValue === 'gif' || typeValue === 'webp') {
ImageKnifeLoader.parseAnimatorImage(resBuf ,typeValue ,fileKey , request, callBackData) ImageKnifeLoader.parseAnimatorImage(resBuf ,typeValue ,fileKey , request, callBackData)
return return
} else if(typeValue == "svg") { } else if(typeValue == 'svg') {
ImageKnifeLoader.parseSvgImage(resBuf ,typeValue ,fileKey , request, callBackData) ImageKnifeLoader.parseSvgImage(resBuf ,typeValue ,fileKey , request, callBackData)
return return
} }
@ -82,20 +100,16 @@ export class ImageKnifeLoader {
loadFail: error, loadFail: error,
imageKnifeData: data imageKnifeData: data
} }
emitter.emit(Constants.CALLBACK_EMITTER + request.memoryKey, { data: { "value": res } }) emitter.emit(Constants.CALLBACK_EMITTER + request.memoryKey, { data: { 'value': res } })
} }
static assembleError(data: ImageKnifeData | undefined, phase: string, code?: number, static assembleError(data: ImageKnifeData | undefined, phase: string, code?: number): ImageKnifeData | undefined {
httpCode?: number): ImageKnifeData | undefined {
let errorCallBackData = data?.errorInfo; let errorCallBackData = data?.errorInfo;
if (!errorCallBackData) { if (!errorCallBackData) {
return data; return data;
} }
errorCallBackData.phase = phase; errorCallBackData.phase = phase;
errorCallBackData.code = code? code: 0; errorCallBackData.code = code? code: 0;
if (httpCode && httpCode != 0) {
errorCallBackData.httpCode = httpCode;
}
return data return data
} }
@ -111,6 +125,7 @@ export class ImageKnifeLoader {
} }
static async parseNormalImage(resBuf: ArrayBuffer, typeValue: string, fileKey: string, request: RequestJobRequest, callBackData: ImageKnifeData) { static async parseNormalImage(resBuf: ArrayBuffer, typeValue: string, fileKey: string, request: RequestJobRequest, callBackData: ImageKnifeData) {
LogUtil.log('image parse pixelmap start:' + request.componentId + ',srcType:' + request.requestSource + ',' + request.componentVersion)
let resPixelmap: PixelMap | undefined = undefined let resPixelmap: PixelMap | undefined = undefined
let timeInfo: TimeInfo = ImageKnifeLoader.getTimeInfo(callBackData); let timeInfo: TimeInfo = ImageKnifeLoader.getTimeInfo(callBackData);
@ -119,13 +134,24 @@ export class ImageKnifeLoader {
} }
let imageSource: image.ImageSource = image.createImageSource(resBuf) let imageSource: image.ImageSource = image.createImageSource(resBuf)
if (imageSource === undefined){ if (imageSource === undefined){
ImageKnifeLoader.makeEmptyResult(request,"image.createImageSource failed", ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CREATE_SOURCE, LoadPixelMapCode.IMAGE_SOURCE_ERROR_CODE)) ImageKnifeLoader.makeEmptyResult(request,'image.createImageSource failed', ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CREATE_SOURCE, LoadPixelMapCode.IMAGE_SOURCE_ERROR_CODE))
return return
} }
let size = (await imageSource.getImageInfo()).size let imageInfoSync = imageSource.getImageInfoSync()
if (imageInfoSync == undefined){
imageSource.release()
ImageKnifeLoader.makeEmptyResult(request, 'getImageInfoSync failed')
return
}
let size = imageInfoSync.size
callBackData.imageWidth = size.width; callBackData.imageWidth = size.width;
callBackData.imageHeight = size.height; callBackData.imageHeight = size.height;
if (request.isAutoImageFit && request.requestSource == ImageKnifeRequestSource.SRC){
request.componentHeight = request.componentWidth * size.height / size.width
}
try { try {
if ((request.downsampType !== DownsampleStrategy.NONE) && if ((request.downsampType !== DownsampleStrategy.NONE) &&
request.requestSource == ImageKnifeRequestSource.SRC) { request.requestSource == ImageKnifeRequestSource.SRC) {
@ -133,11 +159,20 @@ export class ImageKnifeLoader {
ImageKnifeLoader.getDownsamplerDecodingOptions(typeValue, request, size, ImageKnifeRequestSource.SRC) ImageKnifeLoader.getDownsamplerDecodingOptions(typeValue, request, size, ImageKnifeRequestSource.SRC)
} }
} catch (err) { } catch (err) {
ImageKnifeLoader.makeEmptyResult(request, err) imageSource.release()
ImageKnifeLoader.makeEmptyResult(request, 'getDownsamplerDecodingOptions failed:' + err)
return return
} }
timeInfo.decodeStartTime = Date.now(); timeInfo.decodeStartTime = Date.now();
// 获取旋转信息
let exif: string | undefined = undefined;
await imageSource.getImageProperty(image.PropertyKey.ORIENTATION).then((res)=>{
exif = res;
}).catch((error: BusinessError)=>{
LogUtil.info("The normal image don't have rotation information, " + error.message);
})
await imageSource.createPixelMap(decodingOptions) await imageSource.createPixelMap(decodingOptions)
.then((pixelmap: PixelMap) => { .then((pixelmap: PixelMap) => {
timeInfo.decodeEndTime = Date.now(); timeInfo.decodeEndTime = Date.now();
@ -146,23 +181,35 @@ export class ImageKnifeLoader {
}).catch((error: BusinessError) => { }).catch((error: BusinessError) => {
timeInfo.decodeEndTime = Date.now(); timeInfo.decodeEndTime = Date.now();
imageSource.release() imageSource.release()
ImageKnifeLoader.makeEmptyResult(request,JSON.stringify(error), ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CREATE_PIXEL_MAP, LoadPixelMapCode.IMAGE_DECODE_ERROR_CODE)) ImageKnifeLoader.makeEmptyResult(request, 'createPixelMap failed:' + JSON.stringify(error),
ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CREATE_PIXEL_MAP, LoadPixelMapCode.IMAGE_DECODE_ERROR_CODE))
return return
}) })
if (request.requestSource === ImageKnifeRequestSource.SRC && request.transformation !== undefined && resPixelmap !== undefined) { if (request.requestSource === ImageKnifeRequestSource.SRC && request.transformation !== undefined && resPixelmap !== undefined) {
LogUtil.log("ImageKnife_DataTime_requestJob.transform.start:" + request.src) LogUtil.log('requestJob.transform.start:' + request.componentId + ',srcType:' + request.requestSource + ',' + request.componentVersion)
resPixelmap = await request.transformation?.transform(request.context, resPixelmap, request.componentWidth, request.componentHeight); resPixelmap = await request.transformation?.transform(request.context, resPixelmap, request.componentWidth, request.componentHeight);
LogUtil.log("ImageKnife_DataTime_requestJob.transform.end:" + request.src) LogUtil.log('requestJob.transform.end:' + request.componentId + ',srcType:' + request.requestSource + ',' + request.componentVersion)
} }
try { try {
resPixelmap?.setTransferDetached(true) resPixelmap?.setTransferDetached(true)
} catch (e) { } catch (e) {
LogUtil.error("PixelMap setTransferDetached err:"+JSON.stringify(e)) LogUtil.error('PixelMap setTransferDetached failed:' + JSON.stringify(e))
}
// 设置翻转和旋转角度
if(exif && exif !== 'Top-left'){
let result = ImageKnifeLoader.getOrientation(exif);
if(result.horizontal || result.vertical) {
resPixelmap?.flipSync(result.horizontal, result.vertical);
}
if(result.rotate > 0) {
resPixelmap?.rotateSync(result.rotate);
}
LogUtil.log('The normal image set flip , horizontal=' + result.horizontal + ', vertical=' +result.vertical + ', rotate=' + result.rotate);
} }
//获取各个pixelMap的大小 //获取各个pixelMap的大小
if (resPixelmap && typeof resPixelmap !== "string") { if (resPixelmap !== undefined) {
let decodeImages: Array<DecodeImageInfo> = []; let decodeImages: DecodeImageInfo[] = [];
let size = (resPixelmap as PixelMap).getImageInfoSync().size; let size = (resPixelmap as PixelMap).getImageInfoSync().size;
let decodeImage: DecodeImageInfo = { let decodeImage: DecodeImageInfo = {
contentWidth: size.width, contentWidth: size.width,
@ -181,7 +228,8 @@ export class ImageKnifeLoader {
type:typeValue, type:typeValue,
imageKnifeData:callBackData imageKnifeData:callBackData
} }
emitter.emit(Constants.CALLBACK_EMITTER + request.memoryKey, { data: { "value": res } }) LogUtil.log('image parse pixelmap end:' + request.componentId + ',srcType:' + request.requestSource + ',' + request.componentVersion)
emitter.emit(Constants.CALLBACK_EMITTER + request.memoryKey, { data: { 'value': res } })
} }
static async parseSvgImage(resBuf: ArrayBuffer, typeValue: string, fileKey: string, static async parseSvgImage(resBuf: ArrayBuffer, typeValue: string, fileKey: string,
request: RequestJobRequest, callBackData: ImageKnifeData) { request: RequestJobRequest, callBackData: ImageKnifeData) {
@ -190,11 +238,17 @@ export class ImageKnifeLoader {
let imageSource: image.ImageSource = image.createImageSource(resBuf) let imageSource: image.ImageSource = image.createImageSource(resBuf)
if (imageSource === undefined){ if (imageSource === undefined){
ImageKnifeLoader.makeEmptyResult(request,"image.createImageSource failed", ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CREATE_SOURCE, LoadPixelMapCode.IMAGE_SOURCE_ERROR_CODE)) ImageKnifeLoader.makeEmptyResult(request,'image.createImageSource failed', ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CREATE_SOURCE, LoadPixelMapCode.IMAGE_SOURCE_ERROR_CODE))
return return
} }
let size = (await imageSource.getImageInfo()).size let imageInfoSync = imageSource.getImageInfoSync()
if (imageInfoSync == undefined){
imageSource.release()
ImageKnifeLoader.makeEmptyResult(request, 'getImageInfoSync failed')
return
}
let size = imageInfoSync.size
let scale = size.height / size.width let scale = size.height / size.width
let hValue = Math.round(request.componentHeight); let hValue = Math.round(request.componentHeight);
let wValue = Math.round(request.componentWidth); let wValue = Math.round(request.componentWidth);
@ -214,10 +268,20 @@ export class ImageKnifeLoader {
opts = ImageKnifeLoader.getDownsamplerDecodingOptions(typeValue, request, size) opts = ImageKnifeLoader.getDownsamplerDecodingOptions(typeValue, request, size)
} }
} catch (err) { } catch (err) {
ImageKnifeLoader.makeEmptyResult(request,err) imageSource.release()
ImageKnifeLoader.makeEmptyResult(request,'getDownsamplerDecodingOptions failed:' + err)
return return
} }
timeInfo.decodeStartTime = Date.now(); timeInfo.decodeStartTime = Date.now();
// 获取旋转信息
let exif: string | undefined = undefined;
await imageSource.getImageProperty(image.PropertyKey.ORIENTATION).then((res)=>{
exif = res;
}).catch((error: BusinessError)=>{
LogUtil.info("Svg image don't have rotation information, " + error.message);
})
await imageSource.createPixelMap(opts) await imageSource.createPixelMap(opts)
.then((pixelmap: PixelMap) => { .then((pixelmap: PixelMap) => {
timeInfo.decodeEndTime = Date.now(); timeInfo.decodeEndTime = Date.now();
@ -225,19 +289,30 @@ export class ImageKnifeLoader {
imageSource.release() imageSource.release()
try { try {
resPixelmap.setTransferDetached(true) resPixelmap.setTransferDetached(true)
// 设置翻转和旋转角度
if(exif && exif !== 'Top-left'){
let result = ImageKnifeLoader.getOrientation(exif);
if(result.horizontal || result.vertical) {
resPixelmap?.flipSync(result.horizontal, result.vertical);
}
if(result.rotate > 0) {
resPixelmap?.rotateSync(result.rotate);
}
LogUtil.log('Svg image set flip , horizontal=' + result.horizontal + ', vertical=' +result.vertical + ', rotate=' + result.rotate);
}
} catch (e) { } catch (e) {
LogUtil.error("PixelMap setTransferDetached err:"+JSON.stringify(e)) LogUtil.error('PixelMap setTransferDetached failed:' + JSON.stringify(e))
} }
}).catch((error: BusinessError) => { }).catch((error: BusinessError) => {
timeInfo.decodeEndTime = Date.now(); timeInfo.decodeEndTime = Date.now();
imageSource.release() imageSource.release()
ImageKnifeLoader.makeEmptyResult(request,JSON.stringify(error), ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CREATE_PIXEL_MAP, LoadPixelMapCode.IMAGE_DECODE_ERROR_CODE)) ImageKnifeLoader.makeEmptyResult(request,'getImageInfoSync failed:' + JSON.stringify(error), ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CREATE_PIXEL_MAP, LoadPixelMapCode.IMAGE_DECODE_ERROR_CODE))
return return
}) })
//获取各个pixelMap的大小 //获取各个pixelMap的大小
if (resPixelmap && typeof resPixelmap !== "string") { if (resPixelmap && typeof resPixelmap !== 'string') {
let decodeImages: Array<DecodeImageInfo> = []; let decodeImages: DecodeImageInfo[] = [];
let decodeImage: DecodeImageInfo = { let decodeImage: DecodeImageInfo = {
contentWidth: defaultSize.width, contentWidth: defaultSize.width,
contentHeight: defaultSize.height, contentHeight: defaultSize.height,
@ -253,30 +328,34 @@ export class ImageKnifeLoader {
type:typeValue, type:typeValue,
imageKnifeData:callBackData imageKnifeData:callBackData
} }
emitter.emit(Constants.CALLBACK_EMITTER + request.memoryKey, { data: { "value": res } }) emitter.emit(Constants.CALLBACK_EMITTER + request.memoryKey, { data: { 'value': res } })
} }
static async parseAnimatorImage(resBuf: ArrayBuffer, typeValue: string, static async parseAnimatorImage(resBuf: ArrayBuffer, typeValue: string,
fileKey: string,request: RequestJobRequest, callBackData: ImageKnifeData) { fileKey: string,request: RequestJobRequest, callBackData: ImageKnifeData) {
let timeInfo: TimeInfo = ImageKnifeLoader.getTimeInfo(callBackData); let timeInfo: TimeInfo = ImageKnifeLoader.getTimeInfo(callBackData);
let imageSource: image.ImageSource = image.createImageSource(resBuf) let imageSource: image.ImageSource = image.createImageSource(resBuf)
if (imageSource === undefined){ if (imageSource === undefined){
ImageKnifeLoader.makeEmptyResult(request,"image.createImageSource failed", ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_CREATE_SOURCE,LoadPixelMapCode.IMAGE_SOURCE_ERROR_CODE)) ImageKnifeLoader.makeEmptyResult(request,'image.createImageSource failed', ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_CREATE_SOURCE,LoadPixelMapCode.IMAGE_SOURCE_ERROR_CODE))
return return
} }
let frameCount = await imageSource.getFrameCount() let frameCount = await imageSource.getFrameCount()
let size = (await imageSource.getImageInfo()).size let imageInfoSync = imageSource.getImageInfoSync()
imageSource.release()
if (imageInfoSync == undefined){
ImageKnifeLoader.makeEmptyResult(request, 'getImageInfoSync failed')
return
}
let size = imageInfoSync.size
callBackData.frameCount = frameCount; callBackData.frameCount = frameCount;
callBackData.imageWidth = size.width; callBackData.imageWidth = size.width;
callBackData.imageHeight = size.height; callBackData.imageHeight = size.height;
imageSource.release()
if(frameCount == undefined || frameCount == 1) { if(frameCount == undefined || frameCount == 1) {
} else { } else {
timeInfo.decodeStartTime = Date.now() timeInfo.decodeStartTime = Date.now()
let base64str = "data:image/" + typeValue + ";base64," + new util.Base64Helper().encodeToStringSync(new Uint8Array(resBuf)) let base64str = 'data:image/' + typeValue + ';base64,' + new util.Base64Helper().encodeToStringSync(new Uint8Array(resBuf))
timeInfo.diskCheckEndTime = Date.now() timeInfo.decodeEndTime = Date.now()
let res: RequestJobResult = { let res: RequestJobResult = {
pixelMap: base64str, pixelMap: base64str,
bufferSize: resBuf.byteLength, bufferSize: resBuf.byteLength,
@ -285,7 +364,7 @@ export class ImageKnifeLoader {
type:typeValue, type:typeValue,
imageKnifeData:callBackData imageKnifeData:callBackData
} }
emitter.emit(Constants.CALLBACK_EMITTER + request.memoryKey, { data: { "value": res } }) emitter.emit(Constants.CALLBACK_EMITTER + request.memoryKey, { data: { 'value': res } })
return return
} }
ImageKnifeLoader.parseNormalImage(resBuf, typeValue, fileKey, request, callBackData) ImageKnifeLoader.parseNormalImage(resBuf, typeValue, fileKey, request, callBackData)
@ -297,14 +376,21 @@ export class ImageKnifeLoader {
if (typeValue === 'gif' || typeValue === 'webp') { if (typeValue === 'gif' || typeValue === 'webp') {
let imageSource: image.ImageSource = image.createImageSource(resBuf); let imageSource: image.ImageSource = image.createImageSource(resBuf);
if (imageSource === undefined){ if (imageSource === undefined){
ImageKnifeLoader.makeEmptyResult(request,"image.createImageSource failed", ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CREATE_SOURCE, LoadPixelMapCode.IMAGE_SOURCE_ERROR_CODE)) ImageKnifeLoader.makeEmptyResult(request,'image.createImageSource failed', ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CREATE_SOURCE, LoadPixelMapCode.IMAGE_SOURCE_ERROR_CODE))
return return
} }
let decodingOptions: image.DecodingOptions = { let decodingOptions: image.DecodingOptions = {
editable: request.requestSource === ImageKnifeRequestSource.SRC && request.transformation !== undefined ? true : false, editable: request.requestSource === ImageKnifeRequestSource.SRC && request.transformation !== undefined ? true : false,
} }
callBackData.imageWidth = imageSource.getImageInfoSync().size.width;
callBackData.imageHeight = imageSource.getImageInfoSync().size.height; let imageInfoSync = imageSource.getImageInfoSync()
if (imageInfoSync == undefined){
imageSource.release()
ImageKnifeLoader.makeEmptyResult(request, 'getImageInfoSync failed')
return
}
callBackData.imageWidth = imageInfoSync.size.width;
callBackData.imageHeight = imageInfoSync.size.height;
let pixelMapList: Array<PixelMap> = [] let pixelMapList: Array<PixelMap> = []
let delayList: Array<number> = [] let delayList: Array<number> = []
timeInfo.decodeStartTime = Date.now(); timeInfo.decodeStartTime = Date.now();
@ -336,12 +422,13 @@ export class ImageKnifeLoader {
}).catch((error: BusinessError) => { }).catch((error: BusinessError) => {
imageSource.release() imageSource.release()
timeInfo.decodeEndTime = Date.now(); timeInfo.decodeEndTime = Date.now();
ImageKnifeLoader.makeEmptyResult(request,JSON.stringify(error), ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_CREATE_PIXEL_MAP,LoadPixelMapCode.IMAGE_DECODE_ERROR_CODE)) ImageKnifeLoader.makeEmptyResult(request,'createPixelMapList failed:' + JSON.stringify(error),
ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_CREATE_PIXEL_MAP,LoadPixelMapCode.IMAGE_DECODE_ERROR_CODE))
return return
}) })
callBackData.decodeImages = decodeImages; callBackData.decodeImages = decodeImages;
let res: RequestJobResult = { let res: RequestJobResult = {
pixelMap: "", pixelMap: '',
bufferSize: resBuf.byteLength, bufferSize: resBuf.byteLength,
fileKey: fileKey, fileKey: fileKey,
type: typeValue, type: typeValue,
@ -349,9 +436,9 @@ export class ImageKnifeLoader {
pixelMapList, pixelMapList,
delayList delayList
} }
emitter.emit(Constants.CALLBACK_EMITTER + request.memoryKey, { data: { "value": res } }) emitter.emit(Constants.CALLBACK_EMITTER + request.memoryKey, { data: { 'value': res } })
} else { } else {
ImageKnifeLoader.makeEmptyResult(request,"ImageKnifeAnimatorComponent组件仅支持动态图", ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_PARSE_IAMGE,LoadPixelMapCode.IMAGE_FORMAT_ERROR_CODE)) ImageKnifeLoader.makeEmptyResult(request,'ImageKnifeAnimatorComponent not support format', ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_PARSE_IAMGE,LoadPixelMapCode.IMAGE_FORMAT_ERROR_CODE))
} }
} }
static getHeaderObj(request:RequestJobRequest){ static getHeaderObj(request:RequestJobRequest){
@ -368,207 +455,62 @@ export class ImageKnifeLoader {
return headerObj return headerObj
} }
static FileCacheParseImage(request:RequestJobRequest,resBuf:ArrayBuffer,fileKey:string, callBackData: ImageKnifeData){ static FileCacheParseImage(request:RequestJobRequest,resBuf:ArrayBuffer,fileKey:string, callBackData: ImageKnifeData){
// 保存文件缓存 try {
if (resBuf !== undefined && request.writeCacheStrategy !== CacheStrategy.Memory) { // 保存文件缓存
LogUtil.log("ImageKnife_DataTime_requestJob_saveFileCacheOnlyFile.start:"+request.src) if (resBuf !== undefined && request.writeCacheStrategy !== CacheStrategy.Memory) {
FileCache.saveFileCacheOnlyFile(request.context, fileKey, resBuf , request.fileCacheFolder) LogUtil.log('requestJob_saveFileCacheOnlyFile.start:' + request.componentId + ',srcType:' + request.requestSource + ',' + request.componentVersion)
LogUtil.log("ImageKnife_DataTime_requestJob_saveFileCacheOnlyFile.end:"+request.src) FileCache.saveFileCacheOnlyFile(request.context, fileKey, resBuf , request.fileCacheFolder)
LogUtil.log('requestJob_saveFileCacheOnlyFile.end:' + request.componentId + ',srcType:' + request.requestSource + ',' + request.componentVersion)
}
ImageKnifeLoader.parseImage(resBuf,fileKey,request, callBackData)
} catch (e) {
ImageKnifeLoader.makeEmptyResult(request,
'image load FileCacheParseImage error:' + e + ',componentId' + request.componentId + ',srcType:' +
request.requestSource + ',' + request.componentVersion)
} }
ImageKnifeLoader.parseImage(resBuf,fileKey,request, callBackData)
} }
// 获取图片资源 // 获取图片资源
static async getImageArrayBuffer(request: RequestJobRequest, requestList: List<ImageKnifeRequestWithSource> | undefined,fileKey:string) { static async getImageArrayBuffer(request: RequestJobRequest, requestList: List<ImageKnifeRequestWithSource> | undefined,fileKey:string) {
let resBuf: ArrayBuffer | undefined let resBuf: ArrayBuffer | undefined
let loadError: string = "" let loadError: string = ''
//定义图片各个阶段错误信息 //定义图片各个阶段错误信息
let error: ErrorInfo = { code: 0, phase: LoadPhase.PHASE_LOAD } let error: ErrorInfo = { code: 0, phase: LoadPhase.PHASE_LOAD }
//定义加载时间点 //定义加载时间点
let callBackTimeInfo: TimeInfo = {}; let callBackTimeInfo: TimeInfo = {};
//定义加载信息回调数据 //定义加载信息回调数据
let callBackData: ImageKnifeData = { let callBackData: ImageKnifeData = {
source: "", source: '',
imageWidth: 0, imageWidth: 0,
imageHeight: 0, imageHeight: 0,
timeInfo: callBackTimeInfo, timeInfo: callBackTimeInfo,
errorInfo: error errorInfo: error
}; };
// 判断自定义下载 const loaderStrategy = ImageLoaderFactory.getLoaderStrategy(request);
if (request.customGetImage !== undefined && request.requestSource == ImageKnifeRequestSource.SRC && typeof request.src == "string") { if (loaderStrategy) {
// 先从文件缓存获取 await loaderStrategy.loadImage(request, requestList, fileKey, callBackData, callBackTimeInfo);
ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_CUSTOM_LOAD) } else {
callBackTimeInfo.diskCheckStartTime = Date.now(); loadError = `Unsupported request type: ${request.src}`;
resBuf = FileCache.getFileCacheByFile(request.context, fileKey , request.fileCacheFolder)
callBackTimeInfo.diskCheckEndTime = Date.now();
if (resBuf === undefined) {
LogUtil.log("start customGetImage src=" + request.src)
const headerObj: Record<string, Object> = ImageKnifeLoader.getHeaderObj(request)
try {
request.customGetImage(request.context, request.src, headerObj)
.then((buffer)=>{
if(buffer != undefined) {
ImageKnifeLoader.FileCacheParseImage(request,buffer,fileKey,callBackData)
} else {
loadError = "customGetImage loadFail undefined"
ImageKnifeLoader.makeEmptyResult(request,loadError, ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CUSTOM_LOAD, LoadPixelMapCode.IMAGE_CUSTOM_LOAD_FAILED_CODE))
}
}).catch((err:string)=>{
ImageKnifeLoader.makeEmptyResult(request,err, ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CUSTOM_LOAD, LoadPixelMapCode.IMAGE_CUSTOM_LOAD_FAILED_CODE))
})
} catch (e) {
loadError = "customGetImage loadFail failed"
ImageKnifeLoader.makeEmptyResult(request,loadError + e, ImageKnifeLoader.assembleError(callBackData, LoadPhase.PHASE_CUSTOM_LOAD, LoadPixelMapCode.IMAGE_CUSTOM_LOAD_FAILED_CODE))
}
LogUtil.log("end customGetImage src=" + request.src)
return
}
}
else {
if (typeof request.src === 'string') {
if (request.src.indexOf("http://") == 0 || request.src.indexOf("https://") == 0) { //从网络下载
// 先从文件缓存获取
ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_NET)
callBackTimeInfo.diskCheckStartTime = Date.now()
resBuf = FileCache.getFileCacheByFile(request.context, fileKey , request.fileCacheFolder)
callBackTimeInfo.diskCheckEndTime = Date.now()
if (resBuf !== undefined){
LogUtil.log("success get image from filecache for key = " + fileKey + " src = " + request.src)
}
else if (request.onlyRetrieveFromCache != true) {
LogUtil.log("HttpDownloadClient.start:" + request.src)
callBackTimeInfo.netRequestStartTime = Date.now();
let httpRequest = http.createHttp();
let progress: number = 0
let arrayBuffers = new Array<ArrayBuffer>()
const headerObj: Record<string, Object> = ImageKnifeLoader.getHeaderObj(request)
httpRequest.on("dataReceive", (data: ArrayBuffer) => {
arrayBuffers.push(data)
});
if (request.isWatchProgress) {
httpRequest.on('dataReceiveProgress', (data: RequestData) => {
// 下载进度
if (data != undefined && (typeof data.receiveSize == 'number') && (typeof data.totalSize == 'number')) {
let percent = Math.round(((data.receiveSize * 1.0) / (data.totalSize * 1.0)) * 100)
if (progress !== percent) {
progress = percent
if (requestList === undefined) {
// 子线程
emitter.emit(Constants.PROGRESS_EMITTER + request.memoryKey, { data: { "value": progress } })
}else {
// 主线程请求
requestList!.forEach((requestWithSource: ImageKnifeRequestWithSource) => {
if (requestWithSource.request.imageKnifeOption.progressListener !== undefined && requestWithSource.source === ImageKnifeRequestSource.SRC) {
requestWithSource.request.imageKnifeOption.progressListener(progress)
}
})
}
}
}
})
}
let promise = httpRequest.requestInStream(request.src, {
header: headerObj,
method: http.RequestMethod.GET,
expectDataType: http.HttpDataType.ARRAY_BUFFER,
connectTimeout: 60000,
readTimeout: 0,
// usingProtocol:http.HttpProtocol.HTTP1_1
// header: new Header('application/json')
caPath: request.caPath === undefined ? undefined : request.caPath,
});
promise.then((data: number) => {
ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_NET, undefined, data)
callBackTimeInfo.netRequestEndTime = Date.now();
if (data == 200 || data == 206 || data == 204) {
resBuf = combineArrayBuffers(arrayBuffers)
ImageKnifeLoader.FileCacheParseImage(request,resBuf,fileKey, callBackData)
} else {
loadError = "HttpDownloadClient has error, http code =" + JSON.stringify(data)
ImageKnifeLoader.makeEmptyResult(request,loadError, ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_NET, LoadPixelMapCode.IMAGE_HTTPS_LOAD_FAILED_CODE, data))
}
}).catch((err: Error) => {
loadError = "HttpDownloadClient download ERROR : err = " + JSON.stringify(err)
callBackTimeInfo.netRequestEndTime = Date.now();
ImageKnifeLoader.makeEmptyResult(request,loadError, ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_NET, LoadPixelMapCode.IMAGE_HTTPS_LOAD_FAILED_CODE, undefined))
});
LogUtil.log("HttpDownloadClient.end:" + request.src)
return
}
else {
callBackTimeInfo.netRequestEndTime = Date.now();
loadError = 'onlyRetrieveFromCache,do not fetch image src = ' + request.src
}
} else if (request.src.startsWith('datashare://') || request.src.startsWith('file://')) {
ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_SHARE_FILE)
await fs.open(request.src, fs.OpenMode.READ_ONLY).then(async (file) => {
await fs.stat(file.fd).then(async (stat) =>{
let buf = new ArrayBuffer(stat.size);
await fs.read(file.fd, buf).then((readLen) => {
resBuf = buf;
fs.closeSync(file.fd);
}).catch((err:BusinessError) => {
ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_SHARE_FILE, LoadPixelMapCode.IMAGE_LOAD_SHARE_FILE_FAILED_CODE)
loadError = 'LoadDataShareFileClient fs.read err happened uri=' + request.src + " err.msg=" + err?.message + " err.code=" + err?.code
})
}).catch((err:BusinessError) => {
ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_SHARE_FILE, LoadPixelMapCode.IMAGE_LOAD_SHARE_FILE_FAILED_CODE)
loadError = 'LoadDataShareFileClient fs.stat err happened uri=' + request.src + " err.msg=" + err?.message + " err.code=" + err?.code
})
}).catch((err:BusinessError) => {
ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_SHARE_FILE, LoadPixelMapCode.IMAGE_LOAD_SHARE_FILE_FAILED_CODE)
loadError = 'LoadDataShareFileClient fs.open err happened uri=' + request.src + " err.msg=" + err?.message + " err.code=" + err?.code
})
} else { //从本地文件获取
ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_LOCAL_FILE)
try {
let stat = fs.statSync(request.src);
if (stat.size > 0) {
let file = fs.openSync(request.src, fs.OpenMode.READ_ONLY);
resBuf = new ArrayBuffer(stat.size);
fs.readSync(file.fd, resBuf);
fs.closeSync(file);
}
} catch (err) {
ImageKnifeLoader.assembleError(callBackData,LoadPhase.PHASE_LOCAL_FILE, LoadPixelMapCode.IMAGE_LOAD_LOCAL_FILE_FAILED_CODE)
loadError = err
}
}
} else if (typeof request.src == "number") { //从资源文件获取
let manager = request.context.createModuleContext(request.moduleName).resourceManager
if (resBuf == undefined && request.onlyRetrieveFromCache != true && request.requestSource == ImageKnifeRequestSource.SRC) {
if(request.src == -1) {
let resName = request.resName as string
resBuf = (await manager.getMediaByName(resName.substring(10))).buffer as ArrayBuffer
} else {
resBuf = manager.getMediaContentSync(request.src).buffer as ArrayBuffer
}
} else if (resBuf == undefined && request.requestSource != ImageKnifeRequestSource.SRC) {
if(request.src == -1) {
let resName = request.resName as string
resBuf = (await manager.getMediaByName(resName.substring(10))).buffer as ArrayBuffer
} else {
resBuf = manager.getMediaContentSync(request.src).buffer as ArrayBuffer
}
}
}
}
if (resBuf === undefined){
callBackTimeInfo.requestEndTime = Date.now(); callBackTimeInfo.requestEndTime = Date.now();
ImageKnifeLoader.makeEmptyResult(request,loadError ,callBackData) ImageKnifeLoader.makeEmptyResult(request, loadError, callBackData);
return
} }
ImageKnifeLoader.parseImage(resBuf,fileKey,request, callBackData)
} }
static isLocalLoadSrc(context: Object | undefined, loadSrc: string): boolean {
if (context != undefined) {
let fileDir: string = (context as common.UIAbilityContext).filesDir as string;
let cacheDir: string = (context as common.UIAbilityContext).cacheDir as string
if (loadSrc.startsWith(fileDir) || loadSrc.startsWith(cacheDir)) {
return true;
}
}
return false;
}
static getDownsamplerDecodingOptions(typeValue: string, request: RequestJobRequest, size: Size, static getDownsamplerDecodingOptions(typeValue: string, request: RequestJobRequest, size: Size,
SRC?: ImageKnifeRequestSource):image.DecodingOptions { SRC?: ImageKnifeRequestSource):image.DecodingOptions {
let reqSize = let reqSize =
new Downsampler().calculateScaling(typeValue, size.width, size.height, request.targetWidth, request.targetHeight, new Downsampler().calculateScaling(typeValue, size.width, size.height,
request.downsampType) vp2px(request.targetWidth), vp2px(request.targetHeight), request.downsampType)
if (typeValue == "svg") { if (typeValue == 'svg') {
return { return {
editable: true, editable: true,
desiredSize: { desiredSize: {
@ -587,4 +529,39 @@ export class ImageKnifeLoader {
} }
} }
} }
static getOrientation(orientation: string | undefined){
let horizontal: boolean = false;
let vertical: boolean = false;
let rotate: number= 0;
switch (orientation){
case 'Top-left': break
case 'Top-right':
horizontal = true;
break;
case 'Bottom-left':
vertical = true;
break
case 'Bottom-right':
rotate = 180;
break;
case 'Left-top':
horizontal = true;
rotate = 270;
break
case 'Right-top':
rotate = 90;
break;
case 'Left-bottom':
rotate = 270;
break
case 'Right-bottom':
horizontal = true;
rotate = 90;
break;
}
let data: FlipRotate = { horizontal: horizontal, vertical: vertical, rotate:rotate };
return data
}
} }

Some files were not shown because too many files have changed in this diff Show More