Compare commits
No commits in common. "master" and "3.0.0-rc.8" have entirely different histories.
master
...
3.0.0-rc.8
|
@ -1,13 +0,0 @@
|
||||||
### 该问题是怎么引起的?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 重现步骤
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 报错信息
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
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
|
|
|
@ -1 +0,0 @@
|
||||||
blank_issues_enabled: false
|
|
|
@ -1,21 +0,0 @@
|
||||||
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
|
|
|
@ -1,15 +0,0 @@
|
||||||
name: 问题咨询|Question
|
|
||||||
description: 如果您对OpenHarmony社区有疑问,欢迎反馈咨询。
|
|
||||||
title: "[问题咨询]: "
|
|
||||||
labels: ["question"]
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
感谢提出问题,我们将安排人答复!
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: 问题描述
|
|
||||||
description: 请描述下您的问题
|
|
||||||
validations:
|
|
||||||
required: true
|
|
|
@ -1,72 +0,0 @@
|
||||||
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
|
|
|
@ -1,8 +0,0 @@
|
||||||
### 一、修改说明
|
|
||||||
|
|
||||||
|
|
||||||
### 二、变更内容
|
|
||||||
|
|
||||||
|
|
||||||
### 三、测试建议
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[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
|
|
157
CHANGELOG.md
|
@ -1,160 +1,3 @@
|
||||||
## 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
|
|
||||||
- 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
|
|
||||||
- HTTPS custom certificate verification
|
|
||||||
- Add downsampling function to reduces memory cache consumption
|
|
||||||
|
|
||||||
## 3.2.0-rc.1
|
|
||||||
- Change the queue from Stack to Queue
|
|
||||||
- ShowPixelMap callback PixelMap assigns value to Image component to synchronize
|
|
||||||
|
|
||||||
## 3.2.0-rc.0
|
|
||||||
- Rollback the old version V1 decorator. V2 decorator will be provided in version 4.x
|
|
||||||
- The sub-thread network request is changed to asynchronous, thereby increasing the number of concurrent sub-thread network requests
|
|
||||||
- Set the concurrency through the setMaxRequests interface under the ImageKnife class
|
|
||||||
- aboutToRecycle life cycle clear image content
|
|
||||||
- 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
|
|
||||||
|
|
||||||
## 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
|
|
||||||
- Released version 3.0.3
|
|
||||||
|
|
||||||
## 3.0.3-rc.0
|
|
||||||
- Custom network method to add request header parameters
|
|
||||||
|
|
||||||
## 3.0.2
|
|
||||||
- Added new image reloading interface reload
|
|
||||||
- Added return request preload interface preload
|
|
||||||
- Added cancel request interface cancel
|
|
||||||
|
|
||||||
## 3.0.2-rc.2
|
|
||||||
- ImageKnifeAnimatorComponent新增开始、结束、暂停的回调事件
|
|
||||||
- 文件缓存数量负数和超过INT最大值时默认为INT最大值
|
|
||||||
- 修复宽高不等svg图片显示有毛边
|
|
||||||
- 部分静态webp图片有delay属性导致识别成动图,改用getFrameCount识别
|
|
||||||
- 修复加载错误图后未去请求排队队列中的请求
|
|
||||||
- 子线程本地Resource参数类型转换成number
|
|
||||||
- 修改使用hilog记录日志,默认打开debug级别的日志
|
|
||||||
- 解码pixelMap默认不可编辑,图形变化可编辑
|
|
||||||
- 修改网络请求超时设置
|
|
||||||
- 重构代码:抽取ImageKnifeDispatcher子线程requestJob相关代码到ImageKnifeLoader中,降低函数复杂度
|
|
||||||
|
|
||||||
## 3.0.2-rc.1
|
|
||||||
- release打包关闭混淆
|
|
||||||
|
|
||||||
## 3.0.2-rc.0
|
|
||||||
- FileUtil.readFile接口和file格式图片同步关闭fd
|
|
||||||
|
|
||||||
## 3.0.1
|
|
||||||
- 修复animatorOption属性设置初始化值失效
|
|
||||||
- 网络请求code为206、204时返回arraybuffer
|
|
||||||
- ImageKnifeComponent显示非必要文件缓存初始化
|
|
||||||
- 修复webp静态图无法设置图形变换
|
|
||||||
|
|
||||||
## 3.0.1-rc.2
|
|
||||||
- 修复自定义下载失败无失败回调
|
|
||||||
- 增加全局配置自定义下载接口
|
|
||||||
- 修复主图相同,错误图不同导致只显示一个错误图
|
|
||||||
- heic格式图片文件魔数从第五位开始匹配
|
|
||||||
|
|
||||||
## 3.0.1-rc.1
|
|
||||||
- 新增ImageKnifeAnimatorComponent控制动图组件
|
|
||||||
- 修复部分heif图无法解码
|
|
||||||
|
|
||||||
## 3.0.1-rc.0
|
|
||||||
- 文件缓存设置最大缓存数量改为无限制
|
|
||||||
|
|
||||||
## 3.0.0
|
|
||||||
- 修复图形变换的闪退问题
|
|
||||||
- 自定义下载customGetImage改为仅主图支持
|
|
||||||
- 修改网络请求requestInStream配置优先返回arraybuffer
|
|
||||||
- 新增ColorFilter属性
|
|
||||||
|
|
||||||
## 3.0.0-rc.9
|
|
||||||
- 修复Resource类型$r(变量无法)加载
|
|
||||||
- 成功回调增加图片格式
|
|
||||||
- Image组件增加onComplete回调
|
|
||||||
- 修复404链接无返回错误信息
|
|
||||||
- onLoadListener增加请求取消回调
|
|
||||||
|
|
||||||
## 3.0.0-rc.8
|
## 3.0.0-rc.8
|
||||||
- svg解码单位改为px
|
- svg解码单位改为px
|
||||||
- 修复预加载接口preLoadCache传ImageKnifeOption失效
|
- 修复预加载接口preLoadCache传ImageKnifeOption失效
|
||||||
|
|
20
OAT.xml
|
@ -1,21 +1,4 @@
|
||||||
<?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>
|
||||||
|
@ -27,7 +10,6 @@
|
||||||
<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 compatibility,license header policies">
|
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||||
|
@ -38,7 +20,6 @@
|
||||||
<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">
|
||||||
|
@ -50,7 +31,6 @@
|
||||||
<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">
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
{
|
{
|
||||||
"Name": "glide",
|
"Name": "glide",
|
||||||
"License": "Apache License 2.0",
|
"License": "Apache License 2.0",
|
||||||
"License File": "LICENSE",
|
"License File": "https://github.com/bumptech/glide/blob/master/LICENSE",
|
||||||
"Version Number": "4.13.1",
|
"Version Number": "4.13.1",
|
||||||
"Owner" : "xiafeng@huawei.com",
|
"Owner" : "bumptech",
|
||||||
"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": "LICENSE",
|
"License File": "https://github.com/wasabeef/glide-transformations/blob/main/LICENSE",
|
||||||
"Version Number": "4.3.0",
|
"Version Number": "4.3.0",
|
||||||
"Owner" : "xiafeng@huawei.com",
|
"Owner" : "wasabeef",
|
||||||
"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": "LICENSE",
|
"License File": "https://github.com/facebook/fresco/blob/main/LICENSE",
|
||||||
"Version Number": "2.6.0",
|
"Version Number": "2.6.0",
|
||||||
"Owner" : "xiafeng@huawei.com",
|
"Owner" : "facebook",
|
||||||
"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": "LICENSE",
|
"License File": "https://github.com/photopea/UPNG.js/blob/master/LICENSE",
|
||||||
"Version Number": "1.0.0",
|
"Version Number": "1.0.0",
|
||||||
"Owner" : "xiafeng@huawei.com",
|
"Owner" : "photopea",
|
||||||
"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": "LICENSE",
|
"License File": "https://github.com/Curzibn/Luban/blob/master/LICENSE",
|
||||||
"Version Number": "1.1.8",
|
"Version Number": "1.1.8",
|
||||||
"Owner" : " xiafeng@huawei.com",
|
"Owner" : " Curzibn",
|
||||||
"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" : " xiafeng@huawei.com",
|
"Owner" : " Yalantis",
|
||||||
"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": "LICENSE",
|
"License File": "https://github.com/satazor/js-spark-md5/blob/master/LICENSE",
|
||||||
"Version Number": "v3.0.2",
|
"Version Number": "v3.0.2",
|
||||||
"Owner" : "xiafeng@huawei.com",
|
"Owner" : "satazor",
|
||||||
"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"
|
||||||
}
|
}
|
||||||
|
|
305
README.md
|
@ -1,68 +1,63 @@
|
||||||
## 🚨 **重要提示 | 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.
|
**专门为OpenHarmony打造的一款图像加载缓存库,致力于更高效、更轻便、更简单。**
|
||||||
|
|
||||||
## Introduction
|
## 简介
|
||||||
|
|
||||||
This project is a self-developed version for OpenHarmony, inspired by the open-source [Glide](https://github.com/bumptech/glide) library. It sports the following features:
|
本项目参考开源库 [Glide](https://github.com/bumptech/glide) 进行OpenHarmony的自研版本:
|
||||||
|
|
||||||
- Customizable memory cache strategy with adjustable cache size (default LRU)
|
- 支持自定义内存缓存策略,支持设置内存缓存的大小(默认LRU策略)。
|
||||||
- Disk L2 cache for downloaded images
|
- 支持磁盘二级缓存,对于下载图片会保存一份至磁盘当中。
|
||||||
- Custom implementation for image acquisition and network downloading
|
- 支持自定义实现图片获取/网络下载
|
||||||
- Listening for progress of network downloads through callbacks
|
- 支持监听网络下载回调进度
|
||||||
- Image options for borders and rounded corners
|
- 继承Image的能力,支持option传入border,设置边框,圆角
|
||||||
- Image scaling with **objectFit**, including auto-adapting height
|
- 继承Image的能力,支持option传入objectFit设置图片缩放,包括objectFit为auto时根据图片自适应高度
|
||||||
- Image scaling through transformation
|
- 支持通过设置transform缩放图片
|
||||||
- Concurrent request management with priority queuing
|
- 并发请求数量,支持请求排队队列的优先级
|
||||||
- No requests made for images whose lifecycle has been destroyed
|
- 支持生命周期已销毁的图片,不再发起请求
|
||||||
- Custom cache keys
|
- 自定义缓存key
|
||||||
- Custom HTTP request headers
|
- 自定义http网络请求头
|
||||||
- **writeCacheStrategy** for controlling cache storage (memory or file)
|
- 支持writeCacheStrategy控制缓存的存入策略(只存入内存或文件缓存)
|
||||||
- Preloading images with **preLoadCache**
|
- 支持preLoadCache预加载图片
|
||||||
- Loading images exclusively from cache with **onlyRetrieveFromCache**
|
- 支持onlyRetrieveFromCache仅用缓存加载
|
||||||
- Support for image transformations such as blurring and highlighting
|
- 支持使用一个或多个图片变换,如模糊,高亮等
|
||||||
|
|
||||||
Planned features:
|
待实现特性
|
||||||
|
|
||||||
- Memory downsampling optimization to save memory usage
|
- gif/webp动图显示与控制
|
||||||
- Support for custom image decoding
|
- 内存降采样优化,节约内存的占用
|
||||||
|
- 支持自定义图片解码
|
||||||
|
|
||||||
Note: The 3.x version has been significantly restructured from the 2.x version, mainly in the following aspects:
|
注意:3.x版本相对2.x版本做了重大的重构,主要体现在:
|
||||||
|
|
||||||
- Use of the **Image** component instead of the **Canvas** component for rendering
|
- 使用Image组件代替Canvas组件渲染
|
||||||
- Refactored dispatch logic to control the number of concurrent requests and support priority in request queuing
|
- 重构Dispatch分发逻辑,支持控制并发请求数,支持请求排队队列的优先级
|
||||||
- Support for custom memory cache strategies and sizes through **initMemoryCache**
|
- 支持通过initMemoryCache自定义策略内存缓存策略和大小
|
||||||
- Support for custom implementation of image acquisition/network downloading through options
|
- 支持option自定义实现图片获取/网络下载
|
||||||
|
|
||||||
Therefore, there are some differences in APIs and capabilities, which mainly include the following:
|
因此API及能力上,目前有部分差异,主要体现在:
|
||||||
|
|
||||||
- The **drawLifeCycle** API is not supported; images are drawn manually through the canvas.
|
- 不支持drawLifeCycle接口,通过canvas自会图片
|
||||||
- In the new version, parameters such as **mainScaleType** and **border** are consistent with the system **Image** component.
|
- mainScaleType,border等参数,新版本与系统Image保持一致
|
||||||
- GIF/WebP animation playback and control (implemented by **ImageAnimator**).
|
- gif/webp动图播放与控制
|
||||||
- Anti-aliasing related parameters.
|
- 抗锯齿相关参数
|
||||||
|
|
||||||
## How to Install
|
## 下载安装
|
||||||
|
|
||||||
```
|
```
|
||||||
ohpm install @ohos/imageknife
|
ohpm install @ohos/imageknife
|
||||||
|
|
||||||
// If file caching is required, initialize the file cache in advance.
|
// 如果需要用文件缓存,需要提前初始化文件缓存
|
||||||
await ImageKnife.getInstance().initFileCache(context, 256, 256 * 1024 * 1024)
|
await ImageKnife.getInstance().initFileCache(context, 256, 256 * 1024 * 1024)
|
||||||
```
|
```
|
||||||
|
|
||||||
## How to Use
|
## 使用说明
|
||||||
|
|
||||||
#### 1. Displaying a Local Resource Image
|
#### 1.显示本地资源图片
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
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"),
|
||||||
|
@ -71,7 +66,7 @@ ImageKnifeComponent({
|
||||||
}).width(100).height(100)
|
}).width(100).height(100)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 2. Displaying a File from Local Context Files
|
#### 2.显示本地context files下文件
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
|
@ -84,7 +79,7 @@ ImageKnifeComponent({
|
||||||
}).width(100).height(100)
|
}).width(100).height(100)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 3. Displaying a Network Image
|
#### 3.显示网络图片
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
|
@ -97,7 +92,7 @@ ImageKnifeComponent({
|
||||||
}).width(100).height(100)
|
}).width(100).height(100)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 4. Downloading an Image with Custom Options
|
#### 4.自定义下载图片
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
|
@ -110,16 +105,16 @@ ImageKnifeComponent({
|
||||||
}
|
}
|
||||||
}).width(100).height(100)
|
}).width(100).height(100)
|
||||||
|
|
||||||
// Custom implementation of the image acquisition method, such as custom network download。
|
// 自定义实现图片获取方法,如自定义网络下载
|
||||||
@Concurrent
|
@Concurrent
|
||||||
async function custom(context: Context, src: string | PixelMap | Resource): Promise<ArrayBuffer | undefined> {
|
async function custom(context: Context, src: string | PixelMap | Resource): Promise<ArrayBuffer | undefined> {
|
||||||
console.info("ImageKnife:: custom download: " + src)
|
console.info("ImageKnife:: custom download:" + src)
|
||||||
// Example of hardcoding to read from a local file. You can also request a network image.
|
// 举例写死从本地文件读取,也可以自己请求网络图片
|
||||||
return context.resourceManager.getMediaContentSync($r("app.media.bb").id).buffer as ArrayBuffer
|
return context.resourceManager.getMediaContentSync($r("app.media.bb").id).buffer as ArrayBuffer
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 5. Listening for Network Download Progress
|
#### 5.监听网络下载进度
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
|
@ -130,7 +125,7 @@ ImageKnifeComponent({
|
||||||
}).width(100).height(100)
|
}).width(100).height(100)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 6. Setting Border Options
|
#### 6.支持option传入border,设置边框,圆角
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({ ImageKnifeOption:
|
ImageKnifeComponent({ ImageKnifeOption:
|
||||||
|
@ -141,7 +136,7 @@ ImageKnifeComponent({ ImageKnifeOption:
|
||||||
}).width(100).height(100)
|
}).width(100).height(100)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 7. Setting Image Transformation Options
|
#### 7.支持option图片变换
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({ ImageKnifeOption:
|
ImageKnifeComponent({ ImageKnifeOption:
|
||||||
|
@ -152,29 +147,29 @@ ImageKnifeComponent({ ImageKnifeOption:
|
||||||
}
|
}
|
||||||
}).width(100).height(100)
|
}).width(100).height(100)
|
||||||
```
|
```
|
||||||
Multiple combined transformation usages:
|
多种组合变换用法
|
||||||
|
|
||||||
```
|
```
|
||||||
let transformations: collections.Array<PixelMapTransformation> = new collections.Array<PixelMapTransformation>();
|
let transformations: collections.Array<PixelMapTransformation> = new collections.Array<PixelMapTransformation>();
|
||||||
transformations.push(new BlurTransformation(5));
|
transformations.push(new BlurTransformation(5));
|
||||||
transformations.push(new BrightnessTransformation(0.2));
|
transformations.push(new BrightnessTransformation(0.2));
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
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: { topLeft: 50, bottomRight: 50 } }, // Rounded corner settings
|
border: { radius: { topLeft: 50, bottomRight: 50 } }, // 圆角设置
|
||||||
transformation: transformations.length > 0 ? new MultiTransTransformation(transformations) : undefined // Graphic transformation group
|
transformation: transformations.length > 0 ? new MultiTransTransformation(transformations) : undefined // 图形变换组
|
||||||
}
|
}
|
||||||
}).width(300)
|
}).width(300)
|
||||||
.height(300)
|
.height(300)
|
||||||
.rotate ({angle: 90}) // Rotate by 90 degrees.
|
.rotate({ angle: 90 }) // 旋转90度
|
||||||
.contrast(12) // Contrast filter
|
.contrast(12) // 对比度滤波器
|
||||||
```
|
```
|
||||||
Other transformation-related properties can be stacked to achieve combined transformation effects.
|
其他变换相关属性,可叠加实现组合变换效果
|
||||||
|
|
||||||
Example of circular cropping transformation:
|
圆形裁剪变换示例
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({ ImageKnifeOption:
|
ImageKnifeComponent({ ImageKnifeOption:
|
||||||
|
@ -187,7 +182,7 @@ ImageKnifeComponent({ ImageKnifeOption:
|
||||||
.height(300)
|
.height(300)
|
||||||
```
|
```
|
||||||
|
|
||||||
Example of Circular cropping with border transformation:
|
圆形裁剪带边框变换示例
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({ ImageKnifeOption:
|
ImageKnifeComponent({ ImageKnifeOption:
|
||||||
|
@ -200,7 +195,7 @@ ImageKnifeComponent({ ImageKnifeOption:
|
||||||
.height(300)
|
.height(300)
|
||||||
```
|
```
|
||||||
|
|
||||||
Example of contrast filtering transformation:
|
对比度滤波变换示例
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
|
@ -212,11 +207,11 @@ ImageKnifeComponent({
|
||||||
.contrast(12)
|
.contrast(12)
|
||||||
```
|
```
|
||||||
|
|
||||||
Example of rotation transformation:
|
旋转变换示例
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
imageKnifeOption:({
|
imageKnifeOption: {
|
||||||
loadSrc: $r('app.media.pngSample')
|
loadSrc: $r('app.media.pngSample')
|
||||||
}
|
}
|
||||||
}).width(300)
|
}).width(300)
|
||||||
|
@ -225,10 +220,10 @@ ImageKnifeComponent({
|
||||||
.backgroundColor(Color.Pink)
|
.backgroundColor(Color.Pink)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 8. Listening for Image Loading Success and Failure
|
#### 8.监听图片加载成功与失败
|
||||||
|
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({ ImageKnifeOption:
|
ImageKnifeComponent({ ImageKnifeOption:
|
||||||
{
|
{
|
||||||
loadSrc: $r("app.media.rabbit"),
|
loadSrc: $r("app.media.rabbit"),
|
||||||
onLoadListener:{
|
onLoadListener:{
|
||||||
|
@ -239,19 +234,16 @@ ImageKnifeComponent({ ImageKnifeOption:
|
||||||
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) => {
|
||||||
console.info("Load Successful: cost " + (new Date().getTime() - this.starTime) + " milliseconds");
|
console.info("Load Successful: cost " + (new Date().getTime() - this.starTime) + " milliseconds");
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
onLoadCancel(err){
|
|
||||||
console.info(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).width(100).height(100)
|
}).width(100).height(100)
|
||||||
```
|
```
|
||||||
#### 9. Use of syncLoad
|
#### 9.ImageKnifeComponent - syncLoad
|
||||||
**syncLoad** sets whether to load the image synchronously. By default, the image is loaded asynchronously. When loading a small image, you are advised to set **syncLoad** to **true** so that the image loading can be quickly completed on the main thread.
|
设置是否同步加载图片,默认是异步加载。建议加载尺寸较小的本地图片时将syncLoad设为true,因为耗时较短,在主线程上执行即可
|
||||||
```
|
```
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
imageKnifeOption:{
|
imageKnifeOption:{
|
||||||
|
@ -260,130 +252,89 @@ ImageKnifeComponent({
|
||||||
},syncLoad:true
|
},syncLoad:true
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
#### 10. Use of ImageKnifeAnimatorComponent
|
## 接口说明
|
||||||
```
|
|
||||||
ImageKnifeAnimatorComponent({
|
|
||||||
imageKnifeOption:{
|
|
||||||
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
|
|
||||||
placeholderSrc:$r('app.media.loading'),
|
|
||||||
errorholderSrc:$r('app.media.failed')
|
|
||||||
},animatorOption:this.animatorOption
|
|
||||||
}).width(300).height(300).backgroundColor(Color.Orange).margin({top:30})
|
|
||||||
```
|
|
||||||
#### Reuse Scenario
|
|
||||||
Clear the component content in the **aboutToRecycle** lifecycle and trigger image loading through watch observeration.
|
|
||||||
## Available APIs
|
|
||||||
### ImageKnife
|
|
||||||
| Component | Parameter | Description |
|
|
||||||
| --------------------------- | -------------------------------- | ------------ |
|
|
||||||
| ImageKnifeComponent | ImageKnifeOption | Image display component.|
|
|
||||||
| ImageKnifeAnimatorComponent | ImageKnifeOption, AnimatorOption| Animated image control component.|
|
|
||||||
|
|
||||||
### AnimatorOption
|
### ImageKnifeOption参数列表
|
||||||
| Parameter | Type | Description |
|
|
||||||
| ---------- | --------------- | ---------------------------------------- |
|
|
||||||
| state | AnimationStatus | Playback status. Optional. |
|
|
||||||
| iterations | number | Number of playback times. Optional. |
|
|
||||||
| reverse | boolean | Playback order. Optional. |
|
|
||||||
| onStart | ()=>void | Triggered when the animation starts. Optional. |
|
|
||||||
| onFinish | ()=>void | Triggered when the animation finishes or stops. Optional.|
|
|
||||||
| onPause | ()=>void | Triggered when the animation pauses. Optional. |
|
|
||||||
| onCancel | ()=>void | Triggered when the animation is canceled, that is, when it is reset to its initial state. Optional. |
|
|
||||||
| onRepeat | ()=>void | Triggered when the animation repeats. Optional. |
|
|
||||||
|
|
||||||
### ImageKnifeOption
|
| 参数名称 | 入参内容 | 功能简介 |
|
||||||
|
|-----------------------|-------------------------------------------------------|-----------------|
|
||||||
|
| loadSrc | string、PixelMap、Resource | 主图展示 |
|
||||||
|
| placeholderSrc | PixelMap、Resource | 占位图图展示(可选) |
|
||||||
|
| errorholderSrc | PixelMap、Resource | 错误图展示(可选) |
|
||||||
|
| objectFit | ImageFit | 主图填充效果(可选) |
|
||||||
|
| placeholderObjectFit | ImageFit | 占位图填充效果(可选) |
|
||||||
|
| errorholderObjectFit | ImageFit | 错误图填充效果(可选) |
|
||||||
|
| writeCacheStrategy | CacheStrategyType | 写入缓存策略(可选) |
|
||||||
|
| onlyRetrieveFromCache | boolean | 是否跳过网络和本地请求(可选) |
|
||||||
|
| customGetImage | (context: Context, src: string | 自定义下载图片(可选) | | Resource | 错误占位图数据源 |
|
||||||
|
| border | BorderOptions | 边框圆角(可选) |
|
||||||
|
| priority | taskpool.Priority | 加载优先级(可选) |
|
||||||
|
| context | common.UIAbilityContext | 上下文(可选) |
|
||||||
|
| progressListener | (progress: number)=>void | 进度(可选) |
|
||||||
|
| signature | String | 自定义缓存关键字(可选) |
|
||||||
|
| headerOption | Array<HeaderOptions> | 设置请求头(可选) |
|
||||||
|
| transformation | PixelMapTransformation | 图片变换(可选) |
|
||||||
|
| onLoadListener | onLoadStart: () => void、onLoadSuccess: (data: string | PixelMap | undefined) => void、onLoadFailed: (err: string) => void| 监听图片加载成功与失败 |
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
### ImageKnife接口
|
||||||
| --------------------- | ----------------------------------------------------- | ------------------------------ |
|
|
||||||
| loadSrc | string, PixelMap, Resource | Main image. |
|
|
||||||
| placeholderSrc | PixelMap, Resource | Placeholder image. Optional. |
|
|
||||||
| errorholderSrc | PixelMap, Resource | Error image. Optional. |
|
|
||||||
| objectFit | ImageFit | How the main image is resized to fit its container. Optional. |
|
|
||||||
| placeholderObjectFit | ImageFit | How the placeholder image is resized to fit its container. Optional. |
|
|
||||||
| errorholderObjectFit | ImageFit | How the error image is resized to fit its container. Optional. |
|
|
||||||
| writeCacheStrategy | CacheStrategyType | Cache writing strategy. Optional. |
|
|
||||||
| onlyRetrieveFromCache | boolean | Whether to skip network and local requests. Optional.|
|
|
||||||
| customGetImage | (context: Context, src: string | Custom image download. Optional. |
|
|
||||||
| border | BorderOptions | Border corner. Optional. |
|
|
||||||
| priority | taskpool.Priority | Load priority. Optional. |
|
|
||||||
| context | common.UIAbilityContext | Context. Optional. |
|
|
||||||
| progressListener | (progress: number)=>void | Progress. Optional. |
|
|
||||||
| signature | String | Custom cache signature. Optional. |
|
|
||||||
| headerOption | Array\<HeaderOptions> | Request headers. Optional. |
|
|
||||||
| transformation | PixelMapTransformation | Image transformation. Optional. |
|
|
||||||
| drawingColorFilter | ColorFilter | Drawing color filter. Optional. |
|
|
||||||
| onComplete | (event:EventImage \| undefined)=>void | Callback for image loading completion. Optional. |
|
|
||||||
| onLoadListener | onLoadStart:()=>void,onLoadSuccess:(data:string\|Pixelmap)=>void | Callback for image loading events. Optional. |
|
|
||||||
|
|
||||||
### ImageKnife
|
| 参数名称 | 入参内容 | 功能简介 |
|
||||||
|
|------------------|-------------------------------------------------------------------------------------------------------|---------------|
|
||||||
|
| initMemoryCache | newMemoryCache: IMemoryCache | 自定义内存缓存策略 |
|
||||||
|
| initFileCache | context: Context, size: number, memory: number | 初始化文件缓存数量和大小 |
|
||||||
|
| preLoadCache | loadSrc: string I ImageKnifeOption | 预加载并返回文件缓存路径 |
|
||||||
|
| getCacheImage | loadSrc: string, cacheType: CacheStrategy = CacheStrategy.Default, signature?: string) | 从内存或文件缓存中获取资源 |
|
||||||
|
| addHeader | key: string, value: Object | 全局添加http请求头 |
|
||||||
|
| setHeaderOptions | Array<HeaderOptions> | 全局设置http请求头 |
|
||||||
|
| deleteHeader | key: string | 全局删除http请求头 |
|
||||||
|
| setEngineKeyImpl | IEngineKey | 全局配置缓存key生成策略 |
|
||||||
|
| putCacheImage | url: string, pixelMap: PixelMap, cacheType: CacheStrategy = CacheStrategy.Default, signature?: string | 写入内存磁盘缓存 |
|
||||||
|
| removeMemoryCache| url: string | ImageKnifeOption | 清理指定内存缓存 |
|
||||||
|
| removeFileCache | url: string | ImageKnifeOption | 清理指定磁盘缓存 |
|
||||||
|
### 图形变换类型(需要为GPUImage添加依赖项)
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
| 类型 | 相关描述 |
|
||||||
| ----------------- | ------------------------------------------------------------ | -------------------------- |
|
| ---------------------------------- | ----------------------------- |
|
||||||
| initMemoryCache | newMemoryCache: IMemoryCache | Initializes a custom memory cache strategy. |
|
| BlurTransformation | 模糊处理 |
|
||||||
| initFileCache | context: Context, size: number, memory: number | Initializes the file cache size and quantity |
|
| BrightnessTransformation | 亮度滤波器 |
|
||||||
| preLoadCache | loadSrc: string I ImageKnifeOption | Preloads and returns the file cache path. |
|
| CropSquareTransformation | 正方形剪裁 |
|
||||||
| getCacheImage | loadSrc: string, cacheType: CacheStrategy = CacheStrategy.Default, signature?: string) | Obtains resources from memory or file cache.|
|
| CropTransformation | 自定义矩形剪裁 |
|
||||||
| addHeader | key: string, value: Object | Adds a global HTTP request header. |
|
| GrayScaleTransformation | 灰度级滤波器 |
|
||||||
| setHeaderOptions | Array<HeaderOptions> | Sets global HTTP request headers. |
|
| InvertTransformation | 反转滤波器 |
|
||||||
| deleteHeader | key: string | Deletes a global HTTP request header. |
|
| KuwaharaTransformation | 桑原滤波器(使用GPUIImage) |
|
||||||
| setCustomGetImage | customGetImage?: (context: Context, src: string | PixelMap |
|
| MaskTransformation | 遮罩 |
|
||||||
| setEngineKeyImpl | IEngineKey | Sets a global cache key generation strategy. |
|
| PixelationTransformation | 像素化滤波器(使用GPUIImage) |
|
||||||
| putCacheImage | url: string, pixelMap: PixelMap, cacheType: CacheStrategy = CacheStrategy.Default, signature?: string | Writes to the memory disk cache. |
|
| SepiaTransformation | 乌墨色滤波器(使用GPUIImage) |
|
||||||
| removeMemoryCache | url: string | Removes an entry from the memory cache. |
|
| SketchTransformation | 素描滤波器(使用GPUIImage) |
|
||||||
| removeFileCache | url: string | Removes an entry from the file cache. |
|
| SwirlTransformation | 扭曲滤波器(使用GPUIImage) |
|
||||||
### Graphics tRansformation Types (GPUImage Dependency Required)
|
| ToonTransformation | 动画滤波器(使用GPUIImage) |
|
||||||
|
| VignetterTransformation | 装饰滤波器(使用GPUIImage) |
|
||||||
|
|
||||||
| Type | Description |
|
## 下载安装GPUImage依赖
|
||||||
| ------------------------ | ----------------------------- |
|
方法一:在Terminal窗口中,执行如下命令安装三方包,DevEco Studio会自动在工程的oh-package.json5中自动添加三方包依赖。
|
||||||
| BlurTransformation | Blurs the image. |
|
|
||||||
| BrightnessTransformation | Applies a brightness filter. |
|
|
||||||
| CropSquareTransformation | Crops the image to a square. |
|
|
||||||
| CropTransformation | Crops the image to a custom rectangle. |
|
|
||||||
| GrayScaleTransformation | Applies a grayscale filter. |
|
|
||||||
| InvertTransformation | Applies an inversion filter. |
|
|
||||||
| KuwaharaTransformation | Applies a Kuwahara filter (requires **GPUImage**). |
|
|
||||||
| MaskTransformation | Applies a mask. |
|
|
||||||
| PixelationTransformation | Applies a pixelation filter (requires **GPUImage**).|
|
|
||||||
| SepiaTransformation | Applies a sepia filter (requires **GPUImage**).|
|
|
||||||
| SketchTransformation | Applies a sketch filter (requires **GPUIImage**). |
|
|
||||||
| SwirlTransformation | Applies a swirl filter (requires **GPUImage**). |
|
|
||||||
| ToonTransformation | Applies a cartoon filter (requires **GPUImage**). |
|
|
||||||
| VignetterTransformation | Applies a vignette filter (requires **GPUImage**). |
|
|
||||||
|
|
||||||
## Downloading and Installing the GPUImage Dependency
|
|
||||||
Method 1: In the **Terminal** window, run the following command to install the third-party HAR. DevEco Studio will automatically add the HAR as a dependency to the **oh-package.json5** file of the project.
|
|
||||||
```
|
```
|
||||||
ohpm install @ohos/gpu_transform
|
ohpm install @ohos/gpu_transform
|
||||||
```
|
```
|
||||||
Method 2: Set the third-party HAR as a dependency in the **oh-package.json5** file of the project. The following is a configuration example:
|
方法二: 在工程的oh-package.json5中设置三方包依赖,配置示例如下:
|
||||||
```
|
```
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ohos/gpu_transform": "^1.0.2"
|
"@ohos/gpu_transform": "^1.0.2"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Constraints
|
## 约束与限制
|
||||||
|
|
||||||
This project has been verified in the following version:
|
在下述版本验证通过:
|
||||||
|
DevEco Studio 5.0 Canary3(5.0.3.221)--SDK:API12
|
||||||
|
|
||||||
DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release(5.0.0.66)
|
## 贡献代码
|
||||||
|
|
||||||
## About obfuscation
|
使用过程中发现任何问题都可以提 [issue](https://gitee.com/openharmony-tpc/ImageKnife/issues)
|
||||||
- Code obfuscation, please see[Code Obfuscation](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/source-obfuscation.md)
|
给我们,当然,我们也非常欢迎你给我们发 [PR](https://gitee.com/openharmony-tpc/ImageKnife/issues) 。
|
||||||
- If you want the imageknife library not to be obfuscated during code obfuscation, you need to add corresponding exclusion rules in the obfuscation rule configuration file obfuscation-rules.txt:
|
|
||||||
```
|
|
||||||
-keep
|
|
||||||
./oh_modules/@ohos/imageknife
|
|
||||||
```
|
|
||||||
|
|
||||||
## How to Contribute
|
## 开源协议
|
||||||
|
|
||||||
If you find any problem during the use, submit an [Issue](https://gitee.com/openharmony-tpc/ImageKnife/issues) or a [PR](https://gitee.com/openharmony-tpc/ImageKnife/issues) to us.
|
本项目基于 [Apache License 2.0](https://gitee.com/openharmony-tpc/ImageKnife/blob/master/LICENSE) ,请自由的享受和参与开源。
|
||||||
|
|
||||||
## License
|
## 遗留问题
|
||||||
|
|
||||||
This project is licensed under [Apache License 2.0](https://gitee.com/openharmony-tpc/ImageKnife/blob/master/LICENSE).
|
- 添加组件闪动问题
|
||||||
|
|
||||||
## Known Issues
|
|
||||||
|
|
||||||
- The **ImageFit** attribute cannot be set for the **ImageKnifeAnimator** component.
|
|
||||||
- The **border** attribute of the **ImageKnifeAnimator** component cannot make the image rounded corners.
|
|
485
README_zh.md
|
@ -1,485 +0,0 @@
|
||||||
## 🚨 **重要提示 | 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
|
|
||||||
|
|
||||||
**专门为OpenHarmony打造的一款图像加载缓存库,致力于更高效、更轻便、更简单。**
|
|
||||||
|
|
||||||
## 简介
|
|
||||||
|
|
||||||
本项目参考开源库 [Glide](https://github.com/bumptech/glide) 进行OpenHarmony的自研版本:
|
|
||||||
|
|
||||||
- 支持自定义内存缓存策略,支持设置内存缓存的大小(默认LRU策略)。
|
|
||||||
- 支持磁盘二级缓存,对于下载图片会保存一份至磁盘当中。
|
|
||||||
- 支持自定义实现图片获取/网络下载
|
|
||||||
- 支持监听网络下载回调进度
|
|
||||||
- 继承Image的能力,支持option传入border,设置边框,圆角
|
|
||||||
- 继承Image的能力,支持option传入objectFit设置图片缩放,包括objectFit为auto时根据图片自适应高度
|
|
||||||
- 支持通过设置transform缩放图片
|
|
||||||
- 并发请求数量,支持请求排队队列的优先级
|
|
||||||
- 支持生命周期已销毁的图片,不再发起请求
|
|
||||||
- 自定义缓存key
|
|
||||||
- 自定义http网络请求头
|
|
||||||
- 支持writeCacheStrategy控制缓存的存入策略(只存入内存或文件缓存)
|
|
||||||
- 支持preLoadCache预加载图片
|
|
||||||
- 支持onlyRetrieveFromCache仅用缓存加载
|
|
||||||
- 支持使用一个或多个图片变换,如模糊,高亮等
|
|
||||||
|
|
||||||
待实现特性
|
|
||||||
|
|
||||||
- 内存降采样优化,节约内存的占用
|
|
||||||
- 支持自定义图片解码
|
|
||||||
|
|
||||||
注意:3.x版本相对2.x版本做了重大的重构,主要体现在:
|
|
||||||
|
|
||||||
- 使用Image组件代替Canvas组件渲染
|
|
||||||
- 重构Dispatch分发逻辑,支持控制并发请求数,支持请求排队队列的优先级
|
|
||||||
- 支持通过initMemoryCache自定义策略内存缓存策略和大小
|
|
||||||
- 支持option自定义实现图片获取/网络下载
|
|
||||||
|
|
||||||
因此API及能力上,目前有部分差异,主要体现在:
|
|
||||||
|
|
||||||
- 不支持drawLifeCycle接口,通过canvas自会图片
|
|
||||||
- mainScaleType,border等参数,新版本与系统Image保持一致
|
|
||||||
- gif/webp动图播放与控制(ImageAnimator实现)
|
|
||||||
- 抗锯齿相关参数
|
|
||||||
|
|
||||||
## 下载安装
|
|
||||||
|
|
||||||
```
|
|
||||||
ohpm install @ohos/imageknife
|
|
||||||
|
|
||||||
// 如果需要用文件缓存,需要提前初始化文件缓存
|
|
||||||
await ImageKnife.getInstance().initFileCache(context, 256, 256 * 1024 * 1024)
|
|
||||||
```
|
|
||||||
|
|
||||||
## 使用说明
|
|
||||||
|
|
||||||
#### 1.显示本地资源图片
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({
|
|
||||||
ImageKnifeOption: {
|
|
||||||
loadSrc: $r("app.media.app_icon"),
|
|
||||||
placeholderSrc: $r("app.media.loading"),
|
|
||||||
errorholderSrc: $r("app.media.app_icon"),
|
|
||||||
objectFit: ImageFit.Auto
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 2.显示本地context files下文件
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({
|
|
||||||
ImageKnifeOption: {
|
|
||||||
loadSrc: this.localFile,
|
|
||||||
placeholderSrc: $r("app.media.loading"),
|
|
||||||
errorholderSrc: $r("app.media.app_icon"),
|
|
||||||
objectFit: ImageFit.Auto
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 3.显示网络图片
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({
|
|
||||||
ImageKnifeOption: {
|
|
||||||
loadSrc:"https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png",
|
|
||||||
placeholderSrc: $r("app.media.loading"),
|
|
||||||
errorholderSrc: $r("app.media.app_icon"),
|
|
||||||
objectFit: ImageFit.Auto
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 4.自定义下载图片
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({
|
|
||||||
ImageKnifeOption: {
|
|
||||||
loadSrc: "https://file.atomgit.com/uploads/user/1704857786989_8994.jpeg",
|
|
||||||
placeholderSrc: $r("app.media.loading"),
|
|
||||||
errorholderSrc: $r("app.media.app_icon"),
|
|
||||||
objectFit: ImageFit.Auto,
|
|
||||||
customGetImage: custom
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
|
|
||||||
// 自定义实现图片获取方法,如自定义网络下载
|
|
||||||
@Concurrent
|
|
||||||
async function custom(context: Context, src: string | PixelMap | Resource): Promise<ArrayBuffer | undefined> {
|
|
||||||
console.info("ImageKnife:: custom download:" + src)
|
|
||||||
// 举例写死从本地文件读取,也可以自己请求网络图片
|
|
||||||
return context.resourceManager.getMediaContentSync($r("app.media.bb").id).buffer as ArrayBuffer
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 5.监听网络下载进度
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({
|
|
||||||
ImageKnifeOption: {
|
|
||||||
loadSrc:"https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png",
|
|
||||||
progressListener:(progress:number)=>{console.info("ImageKinfe:: call back progress = " + progress)}
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 6.支持option传入border,设置边框,圆角
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({ ImageKnifeOption:
|
|
||||||
{
|
|
||||||
loadSrc: $r("app.media.rabbit"),
|
|
||||||
border: {radius:50}
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 7.支持option图片变换
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({ ImageKnifeOption:
|
|
||||||
{
|
|
||||||
loadSrc: $r("app.media.rabbit"),
|
|
||||||
border: {radius:50},
|
|
||||||
transformation: new BlurTransformation(3)
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
```
|
|
||||||
多种组合变换用法
|
|
||||||
|
|
||||||
```
|
|
||||||
let transformations: collections.Array<PixelMapTransformation> = new collections.Array<PixelMapTransformation>();
|
|
||||||
transformations.push(new BlurTransformation(5));
|
|
||||||
transformations.push(new BrightnessTransformation(0.2));
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
placeholderSrc: $r("app.media.loading"),
|
|
||||||
errorholderSrc: $r("app.media.app_icon"),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
border: { radius: { topLeft: 50, bottomRight: 50 } }, // 圆角设置
|
|
||||||
transformation: transformations.length > 0 ? new MultiTransTransformation(transformations) : undefined // 图形变换组
|
|
||||||
}
|
|
||||||
}).width(300)
|
|
||||||
.height(300)
|
|
||||||
.rotate({ angle: 90 }) // 旋转90度
|
|
||||||
.contrast(12) // 对比度滤波器
|
|
||||||
```
|
|
||||||
其它变换相关属性,可叠加实现组合变换效果
|
|
||||||
|
|
||||||
圆形裁剪变换示例
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({ ImageKnifeOption:
|
|
||||||
{
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
objectFit: ImageFit.Cover,
|
|
||||||
border: { radius: 150 }
|
|
||||||
}
|
|
||||||
}).width(300)
|
|
||||||
.height(300)
|
|
||||||
```
|
|
||||||
|
|
||||||
圆形裁剪带边框变换示例
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({ ImageKnifeOption:
|
|
||||||
{
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
objectFit: ImageFit.Cover,
|
|
||||||
border: { radius: 150, color: Color.Red, width: 5 }
|
|
||||||
}
|
|
||||||
}).width(300)
|
|
||||||
.height(300)
|
|
||||||
```
|
|
||||||
|
|
||||||
对比度滤波变换示例
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: $r('app.media.pngSample')
|
|
||||||
}
|
|
||||||
}).width(300)
|
|
||||||
.height(300)
|
|
||||||
.contrast(12)
|
|
||||||
```
|
|
||||||
|
|
||||||
旋转变换示例
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: $r('app.media.pngSample')
|
|
||||||
}
|
|
||||||
}).width(300)
|
|
||||||
.height(300)
|
|
||||||
.rotate({angle:90})
|
|
||||||
.backgroundColor(Color.Pink)
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 8.监听图片加载成功与失败
|
|
||||||
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({ ImageKnifeOption:
|
|
||||||
{
|
|
||||||
loadSrc: $r("app.media.rabbit"),
|
|
||||||
onLoadListener:{
|
|
||||||
onLoadStart:()=>{
|
|
||||||
this.starTime = new Date().getTime()
|
|
||||||
console.info("Load start: ");
|
|
||||||
},
|
|
||||||
onLoadFailed: (err) => {
|
|
||||||
console.error("Load Failed Reason: " + err + " cost " + (new Date().getTime() - this.starTime) + " milliseconds");
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageData) => {
|
|
||||||
console.info("Load Successful: cost " + (new Date().getTime() - this.starTime) + " milliseconds");
|
|
||||||
return data;
|
|
||||||
},
|
|
||||||
onLoadCancel(err){
|
|
||||||
console.info(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
```
|
|
||||||
#### 9.ImageKnifeComponent - syncLoad
|
|
||||||
设置是否同步加载图片,默认是异步加载。建议加载尺寸较小的Resource图片时将syncLoad设为true,因为耗时较短,在主线程上执行即可
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption:{
|
|
||||||
loadSrc:$r("app.media.pngSample"),
|
|
||||||
placeholderSrc:$r("app.media.loading")
|
|
||||||
},syncLoad:true
|
|
||||||
})
|
|
||||||
```
|
|
||||||
#### 10.ImageKnifeAnimatorComponent 示例
|
|
||||||
```
|
|
||||||
ImageKnifeAnimatorComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc:"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
|
|
||||||
placeholderSrc:$r('app.media.loading'),
|
|
||||||
errorholderSrc:$r('app.media.failed')
|
|
||||||
},animatorOption:this.animatorOption
|
|
||||||
}).width(300).height(300).backgroundColor(Color.Orange).margin({top:30})
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 11.加载图片回调信息数据 示例
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({ ImageKnifeOption: = {
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: (req) => {
|
|
||||||
let startCallBackData = JSON.stringify(req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadFailed: (res, req) => {
|
|
||||||
let failedBackData = res + ";" + JSON.stringify(req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageData, req) => {
|
|
||||||
let successBackData = JSON.stringify(req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadCancel: (res, req) => {
|
|
||||||
let cancelBackData = res + ";" + JSON.stringify(req?.imageKnifeData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 },
|
|
||||||
onComplete: (event) => {
|
|
||||||
if (event && event.loadingStatus == 0) {
|
|
||||||
let render_success = JSON.stringify(Date.now())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
```
|
|
||||||
#### 12.图片降采样 示例
|
|
||||||
```
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption:{
|
|
||||||
loadSrc:$r("app.media.pngSample"),
|
|
||||||
placeholderSrc:$r('app.media.loading'),
|
|
||||||
errorholderSrc:$r('app.media.failed'),
|
|
||||||
downsampleOf: DownsampleStrategy.NONE
|
|
||||||
}
|
|
||||||
}).width(300).height(300)
|
|
||||||
```
|
|
||||||
#### 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监听触发图片的加载。
|
|
||||||
## 接口说明
|
|
||||||
### ImageKnife组件
|
|
||||||
| 组件名称 | 入参内容 | 功能简介 |
|
|
||||||
|-----------------------------|---------------------------------|--------|
|
|
||||||
| ImageKnifeComponent | ImageKnifeOption | 图片显示组件 |
|
|
||||||
| ImageKnifeAnimatorComponent | ImageKnifeOption、AnimatorOption | 动图控制组件 |
|
|
||||||
|
|
||||||
### AnimatorOption参数列表
|
|
||||||
| 参数名称 | 入参内容 | 功能简介 |
|
|
||||||
|------------|-----------------|----------|
|
|
||||||
| state | AnimationStatus | 播放状态(可选) |
|
|
||||||
| iterations | number | 播放次数(可选) |
|
|
||||||
| reverse | boolean | 播放顺序(可选) |
|
|
||||||
| onStart | ()=>void | 动画开始播放时触发(可选) |
|
|
||||||
| onFinish | ()=>void | 动画播放完成时或者停止播放时触发(可选) |
|
|
||||||
| onPause | ()=>void | 动画暂停播放时触发(可选) |
|
|
||||||
| onCancel | ()=>void | 动画返回最初状态时触发(可选) |
|
|
||||||
| onRepeat | ()=>void | 动画重复播放时触发(可选) |
|
|
||||||
|
|
||||||
### ImageKnifeOption参数列表
|
|
||||||
|
|
||||||
| 参数名称 | 入参内容 | 功能简介 |
|
|
||||||
|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|
|
|
||||||
| loadSrc | string、PixelMap、Resource | 主图展示 |
|
|
||||||
| placeholderSrc | PixelMap、Resource | 占位图图展示(可选) |
|
|
||||||
| errorholderSrc | PixelMap、Resource | 错误图展示(可选) |
|
|
||||||
| objectFit | ImageFit | 主图填充效果(可选) |
|
|
||||||
| placeholderObjectFit | ImageFit | 占位图填充效果(可选) |
|
|
||||||
| errorholderObjectFit | ImageFit | 错误图填充效果(可选) |
|
|
||||||
| writeCacheStrategy | CacheStrategyType | 写入缓存策略(可选) |
|
|
||||||
| onlyRetrieveFromCache | boolean | 是否跳过网络和本地请求(可选) |
|
|
||||||
| customGetImage | customGetImage?:(context: Context, src: string、PixelMap、Resource ,headers?: Record<string, Object>) => Promise<ArrayBuffer、undefined> | 自定义下载图片(可选) | | Resource | 错误占位图数据源 |
|
|
||||||
| border | BorderOptions | 边框圆角(可选) |
|
|
||||||
| priority | taskpool.Priority | 加载优先级(可选) |
|
|
||||||
| context | common.UIAbilityContext | 上下文(可选) |
|
|
||||||
| progressListener | (progress: number)=>void | 进度(可选) |
|
|
||||||
| signature | String | 自定义缓存关键字(可选) |
|
|
||||||
| headerOption | Array<HeaderOptions> | 设置请求头(可选) |
|
|
||||||
| transformation | PixelMapTransformation | 图片变换(可选) |
|
|
||||||
| drawingColorFilter | ColorFilter、drawing.ColorFilter | 颜色滤镜效果(可选) |
|
|
||||||
| 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 | 监听图片加载成功与失败 |
|
|
||||||
| downsampleOf | DownsampleStrategy | 降采样(可选) |
|
|
||||||
| httpOption | HttpRequestOption | 网络请求配置(可选) |
|
|
||||||
|
|
||||||
### 降采样类型
|
|
||||||
| 类型 | 相关描述 |
|
|
||||||
|------------------------|-------------------|
|
|
||||||
| NONE | 不进行降采样 |
|
|
||||||
| AT_MOST | 请求尺寸大于实际尺寸不进行放大 |
|
|
||||||
| FIT_CENTER_MEMORY | 两边自适应内存优先 |
|
|
||||||
| FIT_CENTER_QUALITY | 两边自适应质量优先 |
|
|
||||||
| CENTER_INSIDE_MEMORY | 宽高缩放比最大的比例,进行缩放适配内存优先 |
|
|
||||||
| CENTER_INSIDE_QUALITY | 宽高缩放比最大的比例,进行缩放适配质量优先 |
|
|
||||||
| AT_LEAST | 根据宽高的最小的比例,进行适配 |
|
|
||||||
|
|
||||||
### ImageKnife接口
|
|
||||||
|
|
||||||
| 参数名称 | 入参内容 | 功能简介 |
|
|
||||||
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------|------------------|
|
|
||||||
| initMemoryCache | newMemoryCache: IMemoryCache | 自定义内存缓存策略 |
|
|
||||||
| initFileCache | context: Context, size: number, memory: number | 初始化文件缓存数量和大小 |
|
|
||||||
| reload | request: ImageKnifeRequest | 图片重新加载 |
|
|
||||||
| preLoad | loadSrc: string I ImageKnifeOption | 预加载返回图片请求request |
|
|
||||||
| cancel | request: ImageKnifeRequest | 取消图片请求 |
|
|
||||||
| preLoadCache | loadSrc: string I ImageKnifeOption | 预加载并返回文件缓存路径 |
|
|
||||||
| getCacheImage | loadSrc: string, cacheType: CacheStrategy = CacheStrategy.Default, signature?: string) | 从内存或文件缓存中获取资源 |
|
|
||||||
| addHeader | key: string, value: Object | 全局添加http请求头 |
|
|
||||||
| setHeaderOptions | Array<HeaderOptions> | 全局设置http请求头 |
|
|
||||||
| deleteHeader | key: string | 全局删除http请求头 |
|
|
||||||
| setCustomGetImage | customGetImage?: (context: Context, src: string、PixelMap、Resource ,headers?: Record<string, Object>) => Promise<ArrayBuffer、undefined>| 全局设置自定义下载 |
|
|
||||||
| setEngineKeyImpl | IEngineKey | 全局配置缓存key生成策略 |
|
|
||||||
| putCacheImage | url: string, pixelMap: PixelMap, cacheType: CacheStrategy = CacheStrategy.Default, signature?: string | 写入内存磁盘缓存 |
|
|
||||||
| removeMemoryCache | url: string、ImageKnifeOption | 清理指定内存缓存 |
|
|
||||||
| removeFileCache | url: string、ImageKnifeOption | 清理指定磁盘缓存 |
|
|
||||||
| getCacheLimitSize | cacheType?: CacheStrategy | 获取指定缓存的上限大小 |
|
|
||||||
| getCurrentCacheNum | cacheType?: CacheStrategy | 获取指定缓存的当前缓存图片个数 |
|
|
||||||
| getCurrentCacheSize | cacheType?: CacheStrategy | 获取指定缓存的当前大小 |
|
|
||||||
| getCurrentCacheSize | cacheType?: CacheStrategy | 获取指定缓存的当前大小 |
|
|
||||||
|
|
||||||
### 回调接口说明
|
|
||||||
| 回调接口 | 回调字段 | 回调描述 |
|
|
||||||
|----------------|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| onLoadStart | req: ImageKnifeRequest | req返回字段中包含了图片请求的信息,如图片的url及其组件的宽高,同时ImageKnifeRequest包含了ImageKnifeData,其中包含此次请求的开始及其检查内存缓存的时间点 |
|
|
||||||
| onLoadSuccess | data: string、PixelMap、undefined, imageData: ImageKnifeData, req?: ImageKnifeRequest | data:加载成功的结果数据;imageData:图片的存入缓存中的信息 ,req:图片请求的信息,同时其中的ImageKnifeData,包含此次请求中图片的原始大小、图片的解码大小、格式、图片帧、请求结束时间、磁盘检查时间、网络请求开始结束、图片解码开始结束等时间点 |
|
|
||||||
| onLoadFailed | err: string, req?: ImageKnifeRequest | err:错误信息描述;req:图片请求的信息,同时其中的ImageKnifeData,包含此次请求错误信息(ErrorInfo,TimeInfo),ErrorInfo其中包含了,错误阶段、错误码及其网络请求的错误码;TimeInfo中包含请求结束时间、磁盘检查时间、网络请求开始结束、图片解码开始结束等时间点 |
|
|
||||||
| onLoadCancel | reason: string, req?: ImageKnifeRequest | reason:取消回调原因;req:图片请求的信息,同时其中的ImageKnifeData,包含此次请求错误信息(ErrorInfo,TimeInfo),ErrorInfo其中包含了,错误阶段、错误码及其网络请求的错误码;TimeInfo中包含请求结束时间、磁盘检查时间、网络请求开始结束、图片解码开始结束及其请求取消等时间点 |
|
|
||||||
|
|
||||||
### 图形变换类型(需要为GPUImage添加依赖项)
|
|
||||||
|
|
||||||
| 类型 | 相关描述 |
|
|
||||||
| ---------------------------------- | ----------------------------- |
|
|
||||||
| BlurTransformation | 模糊处理 |
|
|
||||||
| BrightnessTransformation | 亮度滤波器 |
|
|
||||||
| CropSquareTransformation | 正方形剪裁 |
|
|
||||||
| CropTransformation | 自定义矩形剪裁 |
|
|
||||||
| GrayScaleTransformation | 灰度级滤波器 |
|
|
||||||
| InvertTransformation | 反转滤波器 |
|
|
||||||
| KuwaharaTransformation | 桑原滤波器(使用GPUIImage) |
|
|
||||||
| MaskTransformation | 遮罩 |
|
|
||||||
| PixelationTransformation | 像素化滤波器(使用GPUIImage) |
|
|
||||||
| SepiaTransformation | 乌墨色滤波器(使用GPUIImage) |
|
|
||||||
| SketchTransformation | 素描滤波器(使用GPUIImage) |
|
|
||||||
| SwirlTransformation | 扭曲滤波器(使用GPUIImage) |
|
|
||||||
| ToonTransformation | 动画滤波器(使用GPUIImage) |
|
|
||||||
| VignetterTransformation | 装饰滤波器(使用GPUIImage) |
|
|
||||||
|
|
||||||
## 下载安装GPUImage依赖
|
|
||||||
方法一:在Terminal窗口中,执行如下命令安装三方包,DevEco Studio会自动在工程的oh-package.json5中自动添加三方包依赖。
|
|
||||||
```
|
|
||||||
ohpm install @ohos/gpu_transform
|
|
||||||
```
|
|
||||||
方法二: 在工程的oh-package.json5中设置三方包依赖,配置示例如下:
|
|
||||||
```
|
|
||||||
"dependencies": {
|
|
||||||
"@ohos/gpu_transform": "^1.0.2"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## 约束与限制
|
|
||||||
|
|
||||||
在下述版本验证通过:
|
|
||||||
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)
|
|
||||||
,当然,也非常欢迎发 [PR](https://gitee.com/openharmony-tpc/ImageKnife/pulls) 共建。
|
|
||||||
|
|
||||||
## 开源协议
|
|
||||||
|
|
||||||
本项目基于 [Apache License 2.0](https://gitee.com/openharmony-tpc/ImageKnife/blob/master/LICENSE) ,请自由的享受和参与开源。
|
|
||||||
|
|
||||||
## 遗留问题
|
|
||||||
|
|
||||||
- ImageKnifeAnimator组件无法设置ImageFit属性
|
|
|
@ -7,9 +7,9 @@
|
||||||
{
|
{
|
||||||
"name": "default",
|
"name": "default",
|
||||||
"signingConfig": "default",
|
"signingConfig": "default",
|
||||||
"compileSdkVersion": 12,
|
"compileSdkVersion": "5.0.0(12)",
|
||||||
"compatibleSdkVersion": 12,
|
"compatibleSdkVersion": "5.0.0(12)",
|
||||||
"runtimeOS": "OpenHarmony"
|
"runtimeOS": "HarmonyOS",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"buildModeSet": [
|
"buildModeSet": [
|
||||||
|
@ -38,10 +38,6 @@
|
||||||
"name": "library",
|
"name": "library",
|
||||||
"srcPath": "./library"
|
"srcPath": "./library"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "gpu_transform",
|
|
||||||
"srcPath": "./gpu_transform"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "sharedlibrary",
|
"name": "sharedlibrary",
|
||||||
"srcPath": "./sharedlibrary",
|
"srcPath": "./sharedlibrary",
|
||||||
|
|
|
@ -15,7 +15,4 @@
|
||||||
|
|
||||||
# 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
|
|
|
@ -12,23 +12,15 @@
|
||||||
* 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 { IEngineKey, ImageKnifeOption, PixelMapTransformation,SparkMD5 ,ImageKnifeRequestSource,
|
import { IEngineKey, ImageKnifeOption, PixelMapTransformation,SparkMD5 ,ImageKnifeRequestSource} from '@ohos/libraryimageknife';
|
||||||
DownsampleStrategy} from '@ohos/libraryimageknife';
|
|
||||||
|
|
||||||
//全局自定义key demo
|
//全局自定义key demo
|
||||||
@Sendable
|
@Sendable
|
||||||
export class CustomEngineKeyImpl implements IEngineKey {
|
export class CustomEngineKeyImpl implements IEngineKey {
|
||||||
// 生成内存缓存key
|
// 生成内存缓存key
|
||||||
generateMemoryKey(loadSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,
|
generateMemoryKey(loadSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource,
|
||||||
imageKnifeOption: ImageKnifeOption,isAnimator?: boolean, width?: number, height?: number): string {
|
imageKnifeOption: ImageKnifeOption, width?: number, height?: number): string {
|
||||||
let key = ""
|
let key = "loadSrc=" + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
||||||
if(imageKnifeOption.signature == "aaa" && typeof loadSrc == "string") {
|
|
||||||
let num = loadSrc.indexOf("?")
|
|
||||||
let src = loadSrc.substring(0,num)
|
|
||||||
key = "loadSrc=" + src
|
|
||||||
} else {
|
|
||||||
key = (isAnimator == true ? "Animator=" : "loadSrc==") + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
|
||||||
}
|
|
||||||
if (requestSource === ImageKnifeRequestSource.SRC) {
|
if (requestSource === ImageKnifeRequestSource.SRC) {
|
||||||
if (imageKnifeOption.signature !== undefined && imageKnifeOption.signature !== "") {
|
if (imageKnifeOption.signature !== undefined && imageKnifeOption.signature !== "") {
|
||||||
key += "signature=" + imageKnifeOption.signature + ";"
|
key += "signature=" + imageKnifeOption.signature + ";"
|
||||||
|
@ -36,23 +28,13 @@ export class CustomEngineKeyImpl implements IEngineKey {
|
||||||
if (imageKnifeOption.transformation) {
|
if (imageKnifeOption.transformation) {
|
||||||
key += "transformation=" + this.getTransformation(imageKnifeOption.transformation) + ";"
|
key += "transformation=" + this.getTransformation(imageKnifeOption.transformation) + ";"
|
||||||
}
|
}
|
||||||
if ((imageKnifeOption.downsampleOf !== DownsampleStrategy.NONE && imageKnifeOption.downsampleOf !== undefined)) {
|
|
||||||
key += "downsampleOf" + imageKnifeOption.downsampleOf + "width=" + width + "height=" + height
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return key
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成文件缓存key
|
// 生成文件缓存key
|
||||||
generateFileKey(loadSrc: string | PixelMap | Resource, signature?: string,isAnimator?: boolean): string {
|
generateFileKey(loadSrc: string | PixelMap | Resource, signature?: string): string {
|
||||||
let src = ""
|
let src = "loadSrc=" + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
||||||
if(signature == "aaa" && typeof loadSrc == "string") {
|
|
||||||
let num = loadSrc.indexOf("?")
|
|
||||||
let key = loadSrc.substring(0,num)
|
|
||||||
src = "loadSrc=" + key
|
|
||||||
} else {
|
|
||||||
src = (isAnimator == true ? "Animator=" : "loadSrc==") + (typeof loadSrc == "string" ? loadSrc : JSON.stringify(loadSrc)) + ";"
|
|
||||||
}
|
|
||||||
if (signature !== undefined && signature !== "") {
|
if (signature !== undefined && signature !== "") {
|
||||||
src += "signature=" + signature + ";"
|
src += "signature=" + signature + ";"
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import hilog from '@ohos.hilog';
|
||||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||||
import Want from '@ohos.app.ability.Want';
|
import Want from '@ohos.app.ability.Want';
|
||||||
import window from '@ohos.window';
|
import window from '@ohos.window';
|
||||||
import { ImageKnife, InitImageKnife } from '@ohos/libraryimageknife';
|
import { ImageKnife, InitImageKnife, LogUtil } from '@ohos/libraryimageknife';
|
||||||
import { CustomEngineKeyImpl } from '../common/CustomEngineKeyImpl';
|
import { CustomEngineKeyImpl } from '../common/CustomEngineKeyImpl';
|
||||||
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
||||||
import { BusinessError } from '@ohos.base'
|
import { BusinessError } from '@ohos.base'
|
||||||
|
@ -33,20 +33,21 @@ export default class EntryAbility extends UIAbility {
|
||||||
|
|
||||||
async onWindowStageCreate(windowStage: window.WindowStage): Promise<void> {
|
async onWindowStageCreate(windowStage: window.WindowStage): Promise<void> {
|
||||||
// Main window is created, set main page for this ability
|
// Main window is created, set main page for this ability
|
||||||
// let list: Array<Permissions> = ['ohos.permission.READ_IMAGEVIDEO', 'ohos.permission.WRITE_IMAGEVIDEO'];
|
let list: Array<Permissions> = ['ohos.permission.MEDIA_LOCATION', 'ohos.permission.READ_MEDIA'];
|
||||||
// let permissionRequestResult: Object;
|
let permissionRequestResult: Object;
|
||||||
// let atManager = abilityAccessCtrl.createAtManager();
|
let atManager = abilityAccessCtrl.createAtManager();
|
||||||
// atManager.requestPermissionsFromUser(this.context, list, (err: BusinessError, result: Object) => {
|
atManager.requestPermissionsFromUser(this.context, list, (err: BusinessError, result: Object) => {
|
||||||
// if (err) {
|
if (err) {
|
||||||
//
|
|
||||||
// } else {
|
} else {
|
||||||
// permissionRequestResult = result;
|
permissionRequestResult = result;
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
|
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||||
|
|
||||||
|
LogUtil.mLogLevel = LogUtil.ALL
|
||||||
// 初始化ImageKnife的文件缓存
|
// 初始化ImageKnife的文件缓存
|
||||||
await InitImageKnife.init(this.context)
|
await InitImageKnife.init(this.context)
|
||||||
ImageKnife.getInstance().setEngineKeyImpl(new CustomEngineKeyImpl())
|
ImageKnife.getInstance().setEngineKeyImpl(new CustomEngineKeyImpl())
|
||||||
|
|
|
@ -1,58 +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 { 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;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,220 +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 { DownsampleStrategy, ImageKnifeOption, } from '@ohos/imageknife';
|
|
||||||
import { ImageKnifeComponent } from '@ohos/libraryimageknife';
|
|
||||||
import { image } from '@kit.ImageKit';
|
|
||||||
import { BusinessError } from '@kit.BasicServicesKit';
|
|
||||||
import { Downsampler } from '@ohos/imageknife/src/main/ets/downsampling/Downsampler';
|
|
||||||
import { FileTypeUtil } from '@ohos/imageknife/src/main/ets/utils/FileTypeUtil';
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct DownSamplePage {
|
|
||||||
@State imageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.startIcon'),
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.app_icon'),
|
|
||||||
objectFit: ImageFit.Contain
|
|
||||||
}
|
|
||||||
isBrightness: boolean = false
|
|
||||||
@State beforeSampling: number = 0
|
|
||||||
@State afterSampling: number = 0
|
|
||||||
@State SamplingList: SamplingType[] = [
|
|
||||||
|
|
||||||
new SamplingType(7, 'AT_LEAST'),
|
|
||||||
new SamplingType(1, 'AT_MOST'),
|
|
||||||
|
|
||||||
new SamplingType(2, 'FIT_CENTER_MEMORY'),
|
|
||||||
new SamplingType(4, 'FIT_CENTER_QUALITY'),
|
|
||||||
new SamplingType(5, 'CENTER_INSIDE_MEMORY'),
|
|
||||||
new SamplingType(6, 'CENTER_INSIDE_QUALITY'),
|
|
||||||
new SamplingType(0, 'NONE'),
|
|
||||||
|
|
||||||
]
|
|
||||||
@State checked: boolean = false
|
|
||||||
|
|
||||||
updateImageKnifeOption(value: string) {
|
|
||||||
if (value === 'NONE') {
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.app_icon'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
downsampleOf: DownsampleStrategy.NONE
|
|
||||||
}
|
|
||||||
this.originalPixMap($r('app.media.pngSample'))
|
|
||||||
this.afterSamplingFunc($r('app.media.pngSample'))
|
|
||||||
} else if (value === 'AT_MOST') {
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.app_icon'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
downsampleOf: DownsampleStrategy.AT_MOST
|
|
||||||
}
|
|
||||||
this.originalPixMap($r('app.media.pngSample'))
|
|
||||||
this.afterSamplingFunc($r('app.media.pngSample'))
|
|
||||||
} else if (value === 'FIT_CENTER_MEMORY') {
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.app_icon'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
downsampleOf: DownsampleStrategy.FIT_CENTER_MEMORY
|
|
||||||
}
|
|
||||||
this.originalPixMap($r('app.media.pngSample'))
|
|
||||||
this.afterSamplingFunc($r('app.media.pngSample'))
|
|
||||||
} else if (value === 'FIT_CENTER_QUALITY') {
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.app_icon'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
downsampleOf: DownsampleStrategy.FIT_CENTER_QUALITY
|
|
||||||
}
|
|
||||||
this.originalPixMap($r('app.media.pngSample'))
|
|
||||||
this.afterSamplingFunc($r('app.media.pngSample'))
|
|
||||||
} else if (value === 'CENTER_INSIDE_MEMORY') {
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.app_icon'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
downsampleOf: DownsampleStrategy.CENTER_INSIDE_MEMORY
|
|
||||||
}
|
|
||||||
this.originalPixMap($r('app.media.pngSample'))
|
|
||||||
this.afterSamplingFunc($r('app.media.pngSample'))
|
|
||||||
} else if (value === 'CENTER_INSIDE_QUALITY') {
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.app_icon'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
downsampleOf: DownsampleStrategy.CENTER_INSIDE_QUALITY
|
|
||||||
}
|
|
||||||
this.originalPixMap($r('app.media.pngSample'))
|
|
||||||
this.afterSamplingFunc($r('app.media.pngSample'))
|
|
||||||
} else {
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.app_icon'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
downsampleOf: DownsampleStrategy.AT_LEAST
|
|
||||||
}
|
|
||||||
this.originalPixMap($r('app.media.pngSample'))
|
|
||||||
this.afterSamplingFunc($r('app.media.pngSample'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterSamplingFunc(imgs: Resource) {
|
|
||||||
let img: Uint8Array = await getContext(this).resourceManager.getMediaContent(imgs);
|
|
||||||
let imageSource: image.ImageSource = image.createImageSource(img.buffer.slice(0));
|
|
||||||
let fileTypeUtil = new FileTypeUtil();
|
|
||||||
let typeValue = fileTypeUtil.getFileType(img.buffer.slice(0)) as string;
|
|
||||||
let decodingOptions: image.DecodingOptions = {
|
|
||||||
editable: true,
|
|
||||||
desiredPixelFormat: 3,
|
|
||||||
}
|
|
||||||
let imageInfo = await imageSource.getImageInfo()
|
|
||||||
|
|
||||||
if (this.imageKnifeOption.downsampleOf !== DownsampleStrategy.NONE && this.imageKnifeOption.downsampleOf != undefined ) {
|
|
||||||
let reqSize =
|
|
||||||
new Downsampler().calculateScaling(typeValue, imageInfo.size.width, imageInfo.size.height, 300,
|
|
||||||
300, this.imageKnifeOption.downsampleOf)
|
|
||||||
decodingOptions = {
|
|
||||||
editable: true,
|
|
||||||
desiredSize: {
|
|
||||||
width: reqSize.width,
|
|
||||||
height: reqSize.height
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建pixelMap
|
|
||||||
imageSource.createPixelMap(decodingOptions).then((pixelMap: image.PixelMap) => {
|
|
||||||
imageSource.release()
|
|
||||||
this.afterSampling = pixelMap.getPixelBytesNumber()
|
|
||||||
pixelMap.release()
|
|
||||||
}).catch((err: BusinessError) => {
|
|
||||||
imageSource.release()
|
|
||||||
console.error('Failed to create PixelMap')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async originalPixMap(imgs: Resource,) {
|
|
||||||
let img: Uint8Array = await getContext(this).resourceManager.getMediaContent(imgs);
|
|
||||||
let imageSource: image.ImageSource = image.createImageSource(img.buffer.slice(0));
|
|
||||||
let decodingOptions: image.DecodingOptions = {
|
|
||||||
editable: true,
|
|
||||||
desiredPixelFormat: 3,
|
|
||||||
}
|
|
||||||
// 创建pixelMap
|
|
||||||
imageSource.createPixelMap(decodingOptions).then((pixelMap: image.PixelMap) => {
|
|
||||||
imageSource.release()
|
|
||||||
this.beforeSampling = pixelMap.getPixelBytesNumber()
|
|
||||||
pixelMap.release()
|
|
||||||
}).catch((err: BusinessError) => {
|
|
||||||
imageSource.release()
|
|
||||||
console.error('Failed to create PixelMap')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getResourceString(res:Resource){
|
|
||||||
return getContext().resourceManager.getStringSync(res.id)
|
|
||||||
}
|
|
||||||
build() {
|
|
||||||
Scroll() {
|
|
||||||
Column() {
|
|
||||||
ForEach(this.SamplingList, (item: SamplingType, index) => {
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
|
||||||
Radio({ value: item.value + 'radio', group: 'radioGroup' })
|
|
||||||
.height(50)
|
|
||||||
.width(50)
|
|
||||||
.checked(this.checked)
|
|
||||||
.onClick(() => {
|
|
||||||
this.updateImageKnifeOption(item.value)
|
|
||||||
})
|
|
||||||
Text(this.getResourceString($r('app.string.Sampling_pecification'))+ item.value).fontSize(20)
|
|
||||||
}
|
|
||||||
}, (item: SamplingType) => JSON.stringify(item))
|
|
||||||
Column() {
|
|
||||||
Text(`${this.getResourceString($r('app.string.Unreal_samples'))}:${this.beforeSampling}`).fontSize(20)
|
|
||||||
Text(`${ this.getResourceString($r('app.string.After_the_sampling'))}:${this.afterSampling}`).fontSize(20)
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: this.imageKnifeOption
|
|
||||||
})
|
|
||||||
.height(px2vp(300))
|
|
||||||
.width(px2vp(300))
|
|
||||||
.borderWidth(1)
|
|
||||||
.borderColor(Color.Pink)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
.height('100%')
|
|
||||||
.width('100%')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SamplingType {
|
|
||||||
key: number
|
|
||||||
value: string
|
|
||||||
|
|
||||||
constructor(key: number, value: string) {
|
|
||||||
this.key = key
|
|
||||||
this.value = value
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,93 +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 { 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})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,102 +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 { AnimatorOption, ImageKnifeAnimatorComponent, ImageKnifeOption } from '@ohos/libraryimageknife'
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct ImageAnimatorPage {
|
|
||||||
@State animatorOption: AnimatorOption = {
|
|
||||||
state: AnimationStatus.Running,
|
|
||||||
iterations: -1,
|
|
||||||
onFinish: () => {
|
|
||||||
console.log('ImageKnifeAnimatorComponent animatorOption onFinish')
|
|
||||||
},
|
|
||||||
onStart: () => {
|
|
||||||
console.log('ImageKnifeAnimatorComponent animatorOption onStart')
|
|
||||||
},
|
|
||||||
onPause: () => {
|
|
||||||
console.log('ImageKnifeAnimatorComponent animatorOption onPause')
|
|
||||||
},
|
|
||||||
onCancel: () => {
|
|
||||||
console.log('ImageKnifeAnimatorComponent animatorOption onCancel')
|
|
||||||
},
|
|
||||||
onRepeat: () => {
|
|
||||||
console.log('ImageKnifeAnimatorComponent animatorOption onRepeat')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@State animatorOptionFirstFrame: AnimatorOption = {
|
|
||||||
state: AnimationStatus.Initial
|
|
||||||
}
|
|
||||||
@State animatorOptionLastFrame: AnimatorOption = {
|
|
||||||
state: AnimationStatus.Initial,
|
|
||||||
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() {
|
|
||||||
Column() {
|
|
||||||
Row() {
|
|
||||||
Button($r('app.string.Play')).onClick(() => {
|
|
||||||
this.animatorOption.state = AnimationStatus.Running
|
|
||||||
})
|
|
||||||
Button($r('app.string.Pause')).onClick(() => {
|
|
||||||
this.animatorOption.state = AnimationStatus.Paused
|
|
||||||
})
|
|
||||||
Button($r('app.string.Stop')).onClick(() => {
|
|
||||||
this.animatorOption.state = AnimationStatus.Stopped
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
Button($r('app.string.Infinite_loop')).onClick(() => {
|
|
||||||
this.animatorOption.iterations = -1
|
|
||||||
})
|
|
||||||
Button($r('app.string.Play_once')).onClick(() => {
|
|
||||||
this.animatorOption.iterations = 1
|
|
||||||
})
|
|
||||||
Button($r('app.string.Play_twice')).onClick(() => {
|
|
||||||
this.animatorOption.iterations = 2
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageKnifeAnimatorComponent({
|
|
||||||
imageKnifeOption: this.imageKnifeOption,
|
|
||||||
animatorOption: this.animatorOption
|
|
||||||
}).width(300).height(300).backgroundColor(Color.Orange).margin({ top: 30 })
|
|
||||||
|
|
||||||
Row({ space: 10 }) {
|
|
||||||
Column() {
|
|
||||||
Text($r('app.string.Display_the_first_frame')).fontSize(20)
|
|
||||||
ImageKnifeAnimatorComponent({
|
|
||||||
imageKnifeOption: this.imageKnifeOption,
|
|
||||||
animatorOption: this.animatorOptionFirstFrame
|
|
||||||
}).width(120).height(120).backgroundColor(Color.Orange)
|
|
||||||
}
|
|
||||||
|
|
||||||
Column() {
|
|
||||||
Text($r('app.string.Display_the_last_frame')).fontSize(20)
|
|
||||||
ImageKnifeAnimatorComponent({
|
|
||||||
imageKnifeOption: this.imageKnifeOption,
|
|
||||||
animatorOption: this.animatorOptionLastFrame
|
|
||||||
}).width(120).height(120).backgroundColor(Color.Orange)
|
|
||||||
}
|
|
||||||
}.margin({ top: 50 }).padding(10)
|
|
||||||
}.width('100%').height('100%')
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,99 +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 { connection } from '@kit.NetworkKit'
|
|
||||||
import { List } from '@kit.ArkTS'
|
|
||||||
import { ImageKnifeRequest,ImageKnife,ImageKnifeComponent } from '@ohos/libraryimageknife'
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct ImageKnifeReload {
|
|
||||||
@State index: number = 0
|
|
||||||
aboutToAppear(): void {
|
|
||||||
NetWatchState.init()
|
|
||||||
}
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption:{
|
|
||||||
loadSrc:'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
|
||||||
placeholderSrc:$r('app.media.loading'),
|
|
||||||
errorholderSrc:$r('app.media.failed'),
|
|
||||||
onLoadListener:{
|
|
||||||
onLoadFailed(err,request){
|
|
||||||
NetWatchState.requestList.add(request)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).width(200).height(200)
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption:{
|
|
||||||
loadSrc:'https://img-blog.csdn.net/20140514114029140',
|
|
||||||
placeholderSrc:$r('app.media.loading'),
|
|
||||||
errorholderSrc:$r('app.media.failed'),
|
|
||||||
onLoadListener:{
|
|
||||||
onLoadFailed(err,request){
|
|
||||||
NetWatchState.requestList.add(request)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).width(200).height(200).margin({top:10})
|
|
||||||
Text("重试5次:" + this.index)
|
|
||||||
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%')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class NetWatchState {
|
|
||||||
public static netConnection: connection.NetConnection | undefined = undefined
|
|
||||||
public static requestList: List<ImageKnifeRequest> = new List()
|
|
||||||
|
|
||||||
static init() {
|
|
||||||
NetWatchState.netConnection = connection.createNetConnection()
|
|
||||||
// 注册订阅事件
|
|
||||||
NetWatchState.netConnection.register(()=>{
|
|
||||||
})
|
|
||||||
// 订阅网络能力变化事件。调用register后,才能接收到此事件通知
|
|
||||||
NetWatchState.netConnection.on('netCapabilitiesChange',(data:connection.NetCapabilityInfo)=>{
|
|
||||||
if(NetWatchState.requestList.length > 0 && data.netHandle.netId >= 100) {
|
|
||||||
NetWatchState.requestList.forEach((request)=>{
|
|
||||||
ImageKnife.getInstance().reload(request)
|
|
||||||
NetWatchState.requestList.remove(request)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
static cancel(){
|
|
||||||
if(NetWatchState.netConnection != undefined) {
|
|
||||||
// 取消订阅
|
|
||||||
NetWatchState.netConnection.unregister(()=>{})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
||||||
|
@ -78,7 +78,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Blur_effect')).fontSize(20)
|
Text('模糊效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -91,7 +91,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Highlighting_effect')).fontSize(20)
|
Text('高亮效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -104,7 +104,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Ashing_effect')).fontSize(20)
|
Text('灰化效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -117,7 +117,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Inverse_effect')).fontSize(20)
|
Text('反转效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -130,7 +130,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Animation_filter_effect')).fontSize(20)
|
Text('动画滤镜效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -143,7 +143,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Crop_circular_effect')).fontSize(20)
|
Text('裁剪圆形效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -156,7 +156,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Crop_circular_with_border_effect')).fontSize(20)
|
Text('裁剪圆形带边框效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -168,7 +168,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Contrast_effect')).fontSize(20)
|
Text('对比度效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -181,7 +181,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Black_ink_filtering_effect')).fontSize(20)
|
Text('乌墨色滤波效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -193,7 +193,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Rotate')).fontSize(20)
|
Text('旋转效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -206,7 +206,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Corners')).fontSize(20)
|
Text('圆角效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -219,7 +219,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Kuwahara_Filter_effect')).fontSize(20)
|
Text('桑原滤波效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -232,7 +232,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Pixelated_Filter_effect')).fontSize(20)
|
Text('像素化滤波效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -245,7 +245,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Sketch_Filter_effect')).fontSize(20)
|
Text('素描滤波效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -258,7 +258,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Distortion_Filter_effect')).fontSize(20)
|
Text('扭曲滤波效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -271,7 +271,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Decorative_Filter_effect')).fontSize(20)
|
Text('装饰滤波效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -284,7 +284,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Square_cutting_effect')).fontSize(20)
|
Text('正方形裁剪效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -297,7 +297,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Top_cutting_effect')).fontSize(20)
|
Text('上方裁剪效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -310,7 +310,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Middle_cutting_effect')).fontSize(20)
|
Text('中间裁剪效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -323,7 +323,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Bottom_cutting_effect')).fontSize(20)
|
Text('底下裁剪效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
|
||||||
|
@ -336,7 +336,7 @@ struct ImageTransformation {
|
||||||
})
|
})
|
||||||
.width(30)
|
.width(30)
|
||||||
.height(30)
|
.height(30)
|
||||||
Text($r('app.string.Mask_effect')).fontSize(20)
|
Text('遮罩效果').fontSize(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isContrast) {
|
if (this.isContrast) {
|
||||||
|
@ -398,13 +398,13 @@ struct ImageTransformation {
|
||||||
transformations.push(new CropSquareTransformation());
|
transformations.push(new CropSquareTransformation());
|
||||||
}
|
}
|
||||||
if (this.isCropTop) {
|
if (this.isCropTop) {
|
||||||
transformations.push(new CropTransformation(100, 100, 0));
|
transformations.push(new CropTransformation(25, 25, 0));
|
||||||
}
|
}
|
||||||
if (this.isCropCenter) {
|
if (this.isCropCenter) {
|
||||||
transformations.push(new CropTransformation(100, 100, 1));
|
transformations.push(new CropTransformation(25, 25, 1));
|
||||||
}
|
}
|
||||||
if (this.isCropBottom) {
|
if (this.isCropBottom) {
|
||||||
transformations.push(new CropTransformation(100, 100, 2));
|
transformations.push(new CropTransformation(25, 25, 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
|
||||||
|
|
|
@ -18,10 +18,6 @@ import router from '@system.router';
|
||||||
@Component
|
@Component
|
||||||
struct Index {
|
struct Index {
|
||||||
|
|
||||||
getResourceString(res:Resource){
|
|
||||||
return getContext().resourceManager.getStringSync(res.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
aboutToAppear(): void {
|
aboutToAppear(): void {
|
||||||
|
|
||||||
|
@ -30,141 +26,79 @@ struct Index {
|
||||||
build() {
|
build() {
|
||||||
Scroll(){
|
Scroll(){
|
||||||
Column() {
|
Column() {
|
||||||
Button($r('app.string.Test_ImageAnimator')).onClick(()=>{
|
Button("测试HSP场景预加载").onClick(()=>{
|
||||||
router.push({
|
|
||||||
uri: 'pages/ImageAnimatorPage',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.Network_reload')).margin({top:10}).onClick(()=>{
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/ImageKnifeReload',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.preloading_prefetch')).margin({top:10}).onClick(()=>{
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/PrefetchAndCacheCount',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.request_concurrency')).margin({top:10}).onClick(()=>{
|
|
||||||
router.push({
|
|
||||||
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(()=>{
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/TestCommonImage',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.Test_Task_error')).margin({top:10}).onClick(()=>{
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/TestTaskResourcePage',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.Test_HSP')).margin({top:10}).onClick(()=>{
|
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/TestHspPreLoadImage',
|
uri: 'pages/TestHspPreLoadImage',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Test_SingleImage')).margin({top:10}).onClick(()=>{
|
Button("单个图片使用").onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/SingleImage',
|
uri: 'pages/SingleImage',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Test_LocalImageShow')).margin({top:10}).onClick(()=>{
|
Button("多图 + LazyForEach").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/LocalImage',
|
uri: 'pages/ManyPhotoShowPage',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Error_Message')).margin({top:10}).onClick(()=>{
|
Button("多图 + reuse + LazyForeach").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
|
||||||
uri: 'pages/ErrorMessageDownload',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.Test_custom_download')).margin({top:10}).onClick(()=>{
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/TestSetCustomImagePage',
|
|
||||||
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button(this.getResourceString($r('app.string.Multiple_images')) + ' + reuse + LazyForeach').margin({top:10}).onClick(()=>{
|
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/UserPage',
|
uri: 'pages/UserPage',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Image_Downsampling_Functionality')).margin({top:10}).onClick(()=>{
|
Button("长图显示").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
|
||||||
uri: 'pages/DownSamplePage',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.Display_long_image')).margin({top:10}).onClick(()=>{
|
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/LongImagePage',
|
uri: 'pages/LongImagePage',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Auto_ImageFit')).margin({top:10}).onClick(()=>{
|
Button("缩放图片").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
|
||||||
uri: 'pages/AutoImageFit',
|
|
||||||
|
|
||||||
});
|
|
||||||
})
|
|
||||||
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("消息+List").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/TestImageFlash',
|
uri: 'pages/TestImageFlash',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Custom_cache_key')).margin({top:10}).onClick(()=>{
|
Button("自定义缓存key").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/SignatureTestPage',
|
uri: 'pages/SignatureTestPage',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Preloading_images_to_cache')).margin({top:10}).onClick(()=>{
|
Button("预加载图片到文件缓存").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/TestPrefetchToFileCache',
|
uri: 'pages/TestPrefetchToFileCache',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Retrieve_image_display_from_cache')).margin({top:10}).onClick(()=>{
|
Button("从缓存获取图片显示").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/TestIsUrlExist',
|
uri: 'pages/TestIsUrlExist',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Test_single_request_header')).margin({top:10}).onClick(()=>{
|
Button("测试单个请求头").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/TestHeader',
|
uri: 'pages/TestHeader',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Test_write_cache_strategy')).margin({top:10}).onClick(()=>{
|
Button("测试写入缓存策略").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/TestWriteCacheStage',
|
uri: 'pages/TestWriteCacheStage',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Image_Transformation')).margin({top:10}).onClick(()=>{
|
Button("图片变换").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/ImageTransformation',
|
uri: 'pages/ImageTransformation',
|
||||||
|
|
||||||
|
@ -172,7 +106,7 @@ struct Index {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Button($r('app.string.Different_ObjectFit')).margin({top:10}).onClick(()=>{
|
Button("不同的ObjectFit").margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/ObjectFitPage',
|
uri: 'pages/ObjectFitPage',
|
||||||
|
|
||||||
|
@ -180,55 +114,25 @@ struct Index {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Button($r('app.string.Test_image_loading_success_or_failure_events')).margin({top:10}).onClick(()=>{
|
Button('测试图片加载成功/失败事件').margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/LoadStatePage',
|
uri: 'pages/LoadStatePage',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Button($r('app.string.Test_removing_image_cache_interface')).margin({top:10}).onClick(()=>{
|
Button('测试移除图片缓存接口').margin({top:10}).onClick(()=>{
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/TestRemoveCache',
|
uri: 'pages/TestRemoveCache',
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.Test_error_image_display')).margin({top:10}).onClick(()=>{
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/TestErrorHolderPage',
|
|
||||||
|
|
||||||
});
|
Button("测试媒体url").margin({top:10}).onClick(()=>{
|
||||||
})
|
|
||||||
Button($r('app.string.Test_media_URL')).margin({top:10}).onClick(()=>{
|
|
||||||
router.push({
|
router.push({
|
||||||
uri: 'pages/dataShareUriLoadPage',
|
uri: 'pages/dataShareUriLoadPage',
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
Button($r('app.string.test_cache_btn')).margin({ top: 10 }).onClick(() => {
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/TestCacheDataPage',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.test_change_color_btn')).margin({ top: 10 }).onClick(() => {
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/TestChangeColorPage',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.test_cancel_callback_btn')).margin({ top: 10 }).onClick(() => {
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/TestLoadCancelListenerPage',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.test_callback')).margin({ top: 10 }).onClick(() => {
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/TestImageKnifeCallbackPage',
|
|
||||||
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Button($r('app.string.test_exif')).margin({ top: 10 }).onClick(() => {
|
|
||||||
router.push({
|
|
||||||
uri: 'pages/TestImageExif',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} .width('100%')
|
} .width('100%')
|
||||||
.height('100%')
|
.height('100%')
|
||||||
|
|
|
@ -1,51 +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, ImageKnifeOption } from '@ohos/libraryimageknife';
|
|
||||||
import { CommonDataSource } from './model/CommonDataSource';
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
export struct LazyForEachCache {
|
|
||||||
@State hotCommendList:CommonDataSource<InfoItem> = new CommonDataSource<InfoItem>([])
|
|
||||||
aboutToAppear(): void {
|
|
||||||
this.hotCommendList.addData(this.hotCommendList.totalCount(),PageViewModel.getItems())
|
|
||||||
}
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
List({ space: 16 }) {
|
|
||||||
LazyForEach(this.hotCommendList, (item: InfoItem,index) => {
|
|
||||||
ListItem() {
|
|
||||||
Column({ space: 12 }) {
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption:{
|
|
||||||
loadSrc: item.albumUrl,
|
|
||||||
placeholderSrc:$r('app.media.loading')
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
Text(`${index}`)
|
|
||||||
}.border({ width: 5 , color: '#000000'})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.cachedCount(5)
|
|
||||||
.width('100%')
|
|
||||||
.height('100%')
|
|
||||||
.margin({ left: 10, right: 10 })
|
|
||||||
.layoutWeight(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +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, ImageKnifeOption } from '@ohos/libraryimageknife';
|
|
||||||
import { CommonDataSource } from './model/CommonDataSource';
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
export struct LazyForEachCount {
|
|
||||||
@State hotCommendList:CommonDataSource<InfoItem> = new CommonDataSource<InfoItem>([])
|
|
||||||
aboutToAppear(): void {
|
|
||||||
this.hotCommendList.addData(this.hotCommendList.totalCount(),PageViewModel.getItems())
|
|
||||||
}
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
List({ space: 16 }) {
|
|
||||||
LazyForEach(this.hotCommendList, (item: InfoItem,index) => {
|
|
||||||
ListItem() {
|
|
||||||
Column({ space: 12 }) {
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption:{
|
|
||||||
loadSrc: item.albumUrl,
|
|
||||||
placeholderSrc:$r('app.media.loading')
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
Text(`${index}`)
|
|
||||||
}.border({ width: 5 , color: '#000000'})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.cachedCount(30)
|
|
||||||
.width('100%')
|
|
||||||
.height('100%')
|
|
||||||
.margin({ left: 10, right: 10 })
|
|
||||||
.layoutWeight(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
||||||
|
@ -36,81 +36,48 @@ struct LoadStatePage {
|
||||||
},
|
},
|
||||||
border: { radius: 50 }
|
border: { radius: 50 }
|
||||||
}
|
}
|
||||||
@State imageKnifeOption1: ImageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.startIcon')
|
|
||||||
}
|
|
||||||
@State message: string = ''
|
|
||||||
@State currentWidth: number = 200
|
@State currentWidth: number = 200
|
||||||
@State currentHeight: number = 200
|
@State currentHeight: number = 200
|
||||||
@State typeValue: string = ''
|
|
||||||
build() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
Text($r('app.string.TIPS'))
|
Text('测试失败场景请先关闭网络,并保证本地没有此网络图片的缓存')
|
||||||
.margin({ top: 20 })
|
.margin({ top: 20 })
|
||||||
Row() {
|
Row() {
|
||||||
Button($r('app.string.Test_failure_success'))
|
Button('测试失败/成功场景')
|
||||||
.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,width,height) => {
|
||||||
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 = width!
|
||||||
this.currentHeight = imageData.imageHeight!
|
this.currentHeight = height!
|
||||||
this.typeValue = imageData.type!
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
border: { radius: 50 },
|
border: { radius: 50 }
|
||||||
onComplete:(event)=>{
|
|
||||||
console.error('Load onComplete width:'+event?.width , ' height:'+event?.height , ' componentWidth:'+event?.componentWidth,' componentHeight:' + event?.componentHeight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
.margin({ top: 20 })
|
.margin({ top: 20 })
|
||||||
Text($r('app.string.image_format',this.typeValue))
|
|
||||||
Text($r('app.string.image_width',this.currentWidth))
|
|
||||||
Text($r('app.string.image_height',this.currentHeight))
|
|
||||||
ImageKnifeComponent({ imageKnifeOption: this.ImageKnifeOption }).height(this.currentHeight).width(this.currentWidth)
|
ImageKnifeComponent({ imageKnifeOption: this.ImageKnifeOption }).height(this.currentHeight).width(this.currentWidth)
|
||||||
.margin({ top: 20 })
|
.margin({ top: 20 })
|
||||||
Button($r('app.string.Custom_download_failed')).onClick(()=>{
|
|
||||||
this.imageKnifeOption1 = {
|
|
||||||
loadSrc: 'abc',
|
|
||||||
placeholderSrc:$r('app.media.loading'),
|
|
||||||
errorholderSrc:$r('app.media.failed'),
|
|
||||||
customGetImage:custom,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadFailed:(err)=>{
|
|
||||||
this.message = 'err:' + err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).margin({ top: 20 })
|
|
||||||
Text(this.message).fontSize(20).margin({ top: 20 })
|
|
||||||
ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }).height(this.currentHeight).width(this.currentWidth)
|
|
||||||
.margin({ top: 20 })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.width('100%')
|
.width('100%')
|
||||||
.height('100%')
|
.height('100%')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
// 自定义下载方法
|
|
||||||
@Concurrent
|
|
||||||
async function custom(context: Context, src: string | PixelMap | Resource,headers?: Record<string,Object>): Promise<ArrayBuffer | undefined> {
|
|
||||||
console.info('ImageKnife:: custom download:' + src)
|
|
||||||
// 举例写死从本地文件读取,也可以自己请求网络图片
|
|
||||||
return undefined
|
|
||||||
}
|
}
|
|
@ -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 { 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%')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -21,19 +21,15 @@ 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
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,55 +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 { ImageKnifeComponent,ImageKnife } from '@ohos/libraryimageknife';
|
|
||||||
import { CommonDataSource } from './model/CommonDataSource';
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct MaxRequest1 {
|
|
||||||
@State hotCommendList:CommonDataSource<string> = new CommonDataSource<string>([])
|
|
||||||
private data: Array<string> = []
|
|
||||||
aboutToAppear(): void {
|
|
||||||
ImageKnife.getInstance().setMaxRequests(8)
|
|
||||||
for (let index = 0; index < 200; index++) {
|
|
||||||
this.data.push(`https://img-blog.csdn.net/20140514114029140?${index}`)
|
|
||||||
}
|
|
||||||
this.hotCommendList.addData(this.hotCommendList.totalCount(),this.data)
|
|
||||||
}
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
WaterFlow() {
|
|
||||||
LazyForEach(this.hotCommendList,(item: string)=>{
|
|
||||||
FlowItem() {
|
|
||||||
Column(){
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: item,
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.failed'),
|
|
||||||
}
|
|
||||||
}).width('50%').height(160)
|
|
||||||
}
|
|
||||||
}.height(200)
|
|
||||||
.backgroundColor('#95efd2')
|
|
||||||
},(item: string) => item)
|
|
||||||
}.columnsTemplate('1fr 1fr')
|
|
||||||
.cachedCount(8)
|
|
||||||
.columnsGap(10)
|
|
||||||
.rowsGap(5)
|
|
||||||
.backgroundColor(0xFAEEE0)
|
|
||||||
.width('100%').height('100%')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +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 { ImageKnifeComponent,ImageKnife } from '@ohos/libraryimageknife';
|
|
||||||
import { CommonDataSource } from './model/CommonDataSource';
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct MaxRequest2 {
|
|
||||||
@State hotCommendList:CommonDataSource<string> = new CommonDataSource<string>([])
|
|
||||||
private data: Array<string> = []
|
|
||||||
aboutToAppear(): void {
|
|
||||||
ImageKnife.getInstance().setMaxRequests(20)
|
|
||||||
for (let index = 200; index < 400; index++) {
|
|
||||||
this.data.push(`https://img-blog.csdn.net/20140514114029140?${index}`)
|
|
||||||
}
|
|
||||||
this.hotCommendList.addData(this.hotCommendList.totalCount(),this.data)
|
|
||||||
}
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
WaterFlow() {
|
|
||||||
LazyForEach(this.hotCommendList,(item: string)=>{
|
|
||||||
FlowItem() {
|
|
||||||
Column(){
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: item,
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.failed'),
|
|
||||||
}
|
|
||||||
}).width('50%').height(160)
|
|
||||||
}
|
|
||||||
}.height(200)
|
|
||||||
.backgroundColor('#95efd2')
|
|
||||||
},(item: string) => item)
|
|
||||||
}.columnsTemplate('1fr 1fr')
|
|
||||||
.cachedCount(20)
|
|
||||||
.columnsGap(10)
|
|
||||||
.rowsGap(5)
|
|
||||||
.backgroundColor(0xFAEEE0)
|
|
||||||
.width('100%').height('100%')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +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 { ImageKnifeComponent,ImageKnife } from '@ohos/libraryimageknife';
|
|
||||||
import { CommonDataSource } from './model/CommonDataSource';
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct MaxRequest3 {
|
|
||||||
@State hotCommendList:CommonDataSource<string> = new CommonDataSource<string>([])
|
|
||||||
private data: Array<string> = []
|
|
||||||
aboutToAppear(): void {
|
|
||||||
ImageKnife.getInstance().setMaxRequests(32)
|
|
||||||
for (let index = 400; index < 600; index++) {
|
|
||||||
this.data.push(`https://img-blog.csdn.net/20140514114029140?${index}`)
|
|
||||||
}
|
|
||||||
this.hotCommendList.addData(this.hotCommendList.totalCount(),this.data)
|
|
||||||
}
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
WaterFlow() {
|
|
||||||
LazyForEach(this.hotCommendList,(item: string)=>{
|
|
||||||
FlowItem() {
|
|
||||||
Column(){
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: item,
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.failed'),
|
|
||||||
}
|
|
||||||
}).width('50%').height(160)
|
|
||||||
}
|
|
||||||
}.height(200)
|
|
||||||
.backgroundColor('#95efd2')
|
|
||||||
},(item: string) => item)
|
|
||||||
}.columnsTemplate('1fr 1fr')
|
|
||||||
.cachedCount(40)
|
|
||||||
.columnsGap(10)
|
|
||||||
.rowsGap(5)
|
|
||||||
.backgroundColor(0xFAEEE0)
|
|
||||||
.width('100%').height('100%')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,151 +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 { 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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,43 +18,43 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
|
|
||||||
Button($r('app.string.Main_image_Fill')).onClick(()=>{
|
Button("主图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
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
Button($r('app.string.Maintain_proportion_filling')).margin({top:10}).onClick(async () => {
|
Button("占位图Contain保持比例填充").margin({top:10}).onClick(async () => {
|
||||||
ImageKnife.getInstance().removeAllMemoryCache()
|
ImageKnife.getInstance().removeAllMemoryCache()
|
||||||
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
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
Button($r('app.string.Error_graph_None')).margin({top:10}).onClick(() => {
|
Button("错误图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
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +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 { router } from '@kit.ArkUI'
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct PrefetchAndCacheCount {
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
Button('cacheCount == 5')
|
|
||||||
.onClick(()=>{
|
|
||||||
router.pushUrl({url:'pages/LazyForEachCache'})
|
|
||||||
})
|
|
||||||
Button('cacheCount == 30')
|
|
||||||
.margin({top:10})
|
|
||||||
.onClick(()=>{
|
|
||||||
router.pushUrl({url:'pages/LazyForEachCount'})
|
|
||||||
})
|
|
||||||
Button('prefetch + preload')
|
|
||||||
.margin({top:10})
|
|
||||||
.onClick(()=>{
|
|
||||||
router.pushUrl({url:'pages/PrefetchAndPreload'})
|
|
||||||
})
|
|
||||||
}.width('100%')
|
|
||||||
.height('100%')
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +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 { BasicPrefetcher } from '@kit.ArkUI';
|
|
||||||
import DataSourcePrefetchingImageKnife, { InfoItem } from './model/DataSourcePrefetching';
|
|
||||||
import { PageViewModel } from './model/PageViewModel';
|
|
||||||
import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife';
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
export struct PrefetchAndPreload {
|
|
||||||
// 创建DataSourcePrefetchingImageKnife对象,具备任务预取、取消能力的数据源
|
|
||||||
private readonly dataSource = new DataSourcePrefetchingImageKnife(PageViewModel.getItems());
|
|
||||||
// 创建BasicPrefetcher对象,默认的动态预取算法实现
|
|
||||||
private readonly prefetcher = new BasicPrefetcher(this.dataSource);
|
|
||||||
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
List({ space: 16 }) {
|
|
||||||
LazyForEach(this.dataSource, (item: InfoItem,index:number) => {
|
|
||||||
ListItem() {
|
|
||||||
Column({ space: 12 }) {
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption:{
|
|
||||||
loadSrc: item.albumUrl,
|
|
||||||
placeholderSrc:$r('app.media.loading')
|
|
||||||
}
|
|
||||||
}).width(100).height(100)
|
|
||||||
Text(`${index}`)
|
|
||||||
}.border({ width: 5 , color: '#000000'})
|
|
||||||
}
|
|
||||||
.reuseId('imageKnife')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.cachedCount(5)
|
|
||||||
.onScrollIndex((start: number, end: number) => {
|
|
||||||
// 列表滚动触发visibleAreaChanged,实时更新预取范围,触发调用prefetch、cancel接口
|
|
||||||
this.prefetcher.visibleAreaChanged(start, end)
|
|
||||||
})
|
|
||||||
.width('100%')
|
|
||||||
.height('100%')
|
|
||||||
.margin({ left: 10, right: 10 })
|
|
||||||
.layoutWeight(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +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 { router } from '@kit.ArkUI'
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct SetMaxRequestPage {
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
Button('maxRequest = 8')
|
|
||||||
.onClick(()=>{
|
|
||||||
router.pushUrl({url:'pages/MaxRequest1'})
|
|
||||||
})
|
|
||||||
Button('maxRequest = 20')
|
|
||||||
.onClick(()=>{
|
|
||||||
router.pushUrl({url:'pages/MaxRequest2'})
|
|
||||||
}).margin({top:20})
|
|
||||||
Button('maxRequest = 32')
|
|
||||||
.onClick(()=>{
|
|
||||||
router.pushUrl({url:'pages/MaxRequest2'})
|
|
||||||
}).margin({top:20})
|
|
||||||
}.width('100%')
|
|
||||||
.height('100%')
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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,38 +21,38 @@ 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() {
|
||||||
Scroll() {
|
Scroll() {
|
||||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
|
|
||||||
Text($r('app.string.The_key_fixed_1')).fontSize(15)
|
Text("key固定为 1").fontSize(15)
|
||||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
Button($r('app.string.Load'))
|
Button("加载")
|
||||||
.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)
|
||||||
}.width('100%').backgroundColor(Color.Pink)
|
}.width('100%').backgroundColor(Color.Pink)
|
||||||
|
|
||||||
Text($r('app.string.The_key_changes_timestamp')).fontSize(15)
|
Text("key每次变化:时间戳").fontSize(15)
|
||||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
Button($r('app.string.Load'))
|
Button("加载")
|
||||||
.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())
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,25 +15,21 @@
|
||||||
import { ImageKnifeComponent,BlurTransformation } from '@ohos/libraryimageknife';
|
import { ImageKnifeComponent,BlurTransformation } from '@ohos/libraryimageknife';
|
||||||
import fs from '@ohos.file.fs';
|
import fs from '@ohos.file.fs';
|
||||||
import image from '@ohos.multimedia.image';
|
import image from '@ohos.multimedia.image';
|
||||||
import { common2D, drawing } from '@kit.ArkGraphics2D';
|
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct SingleImage {
|
struct SingleImage {
|
||||||
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
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,78 +38,61 @@ struct SingleImage {
|
||||||
build() {
|
build() {
|
||||||
Scroll(this.scroller) {
|
Scroll(this.scroller) {
|
||||||
Column() {
|
Column() {
|
||||||
Text($r('app.string.Local_SVG'))
|
Text("本地资源svg图片")
|
||||||
.fontSize(30)
|
.fontSize(30)
|
||||||
.fontWeight(FontWeight.Bold)
|
.fontWeight(FontWeight.Bold)
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
imageKnifeOption: {
|
imageKnifeOption: {
|
||||||
loadSrc: $r(this.resource),
|
loadSrc: $r("app.media.svgSample"),
|
||||||
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(()=>{
|
Text("本地context files下文件")
|
||||||
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'))
|
|
||||||
.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)
|
||||||
Text($r('app.string.Network_images'))
|
Text("网络图片")
|
||||||
.fontSize(30)
|
.fontSize(30)
|
||||||
.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中指定该证书所在的应用沙箱路径
|
|
||||||
// caPath: '/data/storage/el1/bundle/ca.pem',
|
|
||||||
}
|
}
|
||||||
}).width(100).height(100)
|
}).width(100).height(100)
|
||||||
Text($r('app.string.Custom_network_download'))
|
Text("自定义下载")
|
||||||
.fontSize(30)
|
.fontSize(30)
|
||||||
.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:[{
|
|
||||||
key:'refer',
|
|
||||||
value:'xx.xx.xx.xx'
|
|
||||||
}],
|
|
||||||
customGetImage: custom,
|
customGetImage: custom,
|
||||||
transformation: new BlurTransformation(10)
|
transformation: new BlurTransformation(10)
|
||||||
}
|
}
|
||||||
}).width(100).height(100)
|
}).width(100).height(100)
|
||||||
Text($r('app.string.PixelMap_loads_images'))
|
Text("pixelMap加载图片")
|
||||||
.fontSize(30)
|
.fontSize(30)
|
||||||
.fontWeight(FontWeight.Bold)
|
.fontWeight(FontWeight.Bold)
|
||||||
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)
|
||||||
|
@ -130,7 +109,6 @@ struct SingleImage {
|
||||||
editable: true,
|
editable: true,
|
||||||
}
|
}
|
||||||
imageSource.createPixelMap(decodingOptions,(err,pixelMap)=>{
|
imageSource.createPixelMap(decodingOptions,(err,pixelMap)=>{
|
||||||
imageSource.release()
|
|
||||||
this.pixelMap = pixelMap;
|
this.pixelMap = pixelMap;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -139,11 +117,9 @@ 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): Promise<ArrayBuffer | undefined> {
|
||||||
let refer = headers!['refer'] as string
|
console.info("ImageKnife:: custom download:" + src)
|
||||||
console.info('ImageKnife:: custom download:' + src,'refer:'+refer)
|
|
||||||
// 举例写死从本地文件读取,也可以自己请求网络图片
|
// 举例写死从本地文件读取,也可以自己请求网络图片
|
||||||
let buffer = context.resourceManager.getMediaContentSync($r('app.media.startIcon').id).buffer as ArrayBuffer
|
return context.resourceManager.getMediaContentSync($r("app.media.startIcon").id).buffer as ArrayBuffer
|
||||||
return buffer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,126 +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 { 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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,140 +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 { ImageKnife, CacheStrategy, ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife';
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct TestCacheDataPage {
|
|
||||||
@State cacheUpLimit: number = 0;
|
|
||||||
@State currentNum: number = 0;
|
|
||||||
@State currentSize: number = 0;
|
|
||||||
@State currentWidth: number = 200
|
|
||||||
@State currentHeight: number = 200
|
|
||||||
@State markersLimitText: 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 ImageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc: '',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadFailed: (err) => {
|
|
||||||
console.error('Load Failed Reason: ' + err);
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data) => {
|
|
||||||
return data;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
border: { radius: 50 }
|
|
||||||
}
|
|
||||||
|
|
||||||
aboutToAppear(): void {
|
|
||||||
ImageKnife.getInstance().initFileCache(getContext(this), 256, 256 * 1024 * 1024, 'ImageKnifeCache1')
|
|
||||||
}
|
|
||||||
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
|
|
||||||
ImageKnifeComponent(
|
|
||||||
{ imageKnifeOption: this.ImageKnifeOption })
|
|
||||||
.height(this.currentHeight)
|
|
||||||
.width(this.currentWidth)
|
|
||||||
.margin({ top: 10 })
|
|
||||||
|
|
||||||
Button($r('app.string.load_memory'))
|
|
||||||
.onClick(() => {
|
|
||||||
this.ImageKnifeOption = {
|
|
||||||
loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
writeCacheStrategy: CacheStrategy.Memory,
|
|
||||||
border: { radius: 50 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Button($r('app.string.load_disk'))
|
|
||||||
.onClick(() => {
|
|
||||||
this.ImageKnifeOption = {
|
|
||||||
loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/56/v3/8MdhfSsCSMKj4sA6okUWrg/5uBx56tLTUO3RYQl-E5JiQ.jpg',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
writeCacheStrategy: CacheStrategy.File,
|
|
||||||
border: { radius: 50 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Text($r('app.string.cur_cache_limit', this.markersLimitText, this.cacheUpLimit))
|
|
||||||
.fontSize(20)
|
|
||||||
.margin({ bottom: 8 });
|
|
||||||
Text($r('app.string.cur_cache_image_num', this.markersNumText, this.currentNum))
|
|
||||||
.fontSize(20)
|
|
||||||
.margin({ bottom: 8 });
|
|
||||||
Text($r('app.string.cur_cache_size', this.markersSizeText, this.currentSize)).fontSize(20).margin({ bottom: 20 });
|
|
||||||
|
|
||||||
Button($r('app.string.get_cur_memory_limit')).onClick(() => {
|
|
||||||
let result = ImageKnife.getInstance().getCacheLimitSize(CacheStrategy.Memory);
|
|
||||||
this.markersLimitText = getContext(this).resourceManager.getStringSync($r('app.string.memory'))
|
|
||||||
if (result) {
|
|
||||||
this.cacheUpLimit = result / (1024 * 1024);
|
|
||||||
} else {
|
|
||||||
this.cacheUpLimit = 0;
|
|
||||||
}
|
|
||||||
}).margin({ bottom: 8 });
|
|
||||||
Button($r('app.string.get_img_number_of_cache')).onClick(() => {
|
|
||||||
let result = ImageKnife.getInstance().getCurrentCacheNum(CacheStrategy.Memory);
|
|
||||||
this.markersNumText = getContext(this).resourceManager.getStringSync($r('app.string.memory'))
|
|
||||||
if (result) {
|
|
||||||
this.currentNum = result;
|
|
||||||
} else {
|
|
||||||
this.currentNum = 0;
|
|
||||||
}
|
|
||||||
}).margin({ bottom: 8 });
|
|
||||||
Button($r('app.string.get_cur_memory_size')).onClick(() => {
|
|
||||||
let result = ImageKnife.getInstance().getCurrentCacheSize(CacheStrategy.Memory);
|
|
||||||
this.markersSizeText = getContext(this).resourceManager.getStringSync($r('app.string.memory'))
|
|
||||||
if (result) {
|
|
||||||
this.currentSize = result / (1024 * 1024);
|
|
||||||
} else {
|
|
||||||
this.currentSize = 0;
|
|
||||||
}
|
|
||||||
}).margin({ bottom: 8 });
|
|
||||||
|
|
||||||
Button($r('app.string.get_cur_disk_limit')).onClick(() => {
|
|
||||||
let result = ImageKnife.getInstance().getCacheLimitSize(CacheStrategy.File);
|
|
||||||
this.markersLimitText = getContext(this).resourceManager.getStringSync($r('app.string.disk'))
|
|
||||||
if (result) {
|
|
||||||
this.cacheUpLimit = result / (1024 * 1024);
|
|
||||||
} else {
|
|
||||||
this.cacheUpLimit = 0;
|
|
||||||
}
|
|
||||||
}).margin({ bottom: 8 });
|
|
||||||
Button($r('app.string.get_img_number_of_disk')).onClick(() => {
|
|
||||||
let result = ImageKnife.getInstance().getCurrentCacheNum(CacheStrategy.File);
|
|
||||||
this.markersNumText = getContext(this).resourceManager.getStringSync($r('app.string.disk'))
|
|
||||||
if (result) {
|
|
||||||
this.currentNum = result;
|
|
||||||
} else {
|
|
||||||
this.currentNum = 0;
|
|
||||||
}
|
|
||||||
}).margin({ bottom: 8 });
|
|
||||||
Button($r('app.string.get_cur_disk_size')).onClick(() => {
|
|
||||||
let result = ImageKnife.getInstance().getCurrentCacheSize(CacheStrategy.File);
|
|
||||||
this.markersSizeText = getContext(this).resourceManager.getStringSync($r('app.string.disk'))
|
|
||||||
if (result) {
|
|
||||||
this.currentSize = result / (1024 * 1024);
|
|
||||||
} else {
|
|
||||||
this.currentSize = 0;
|
|
||||||
}
|
|
||||||
}).margin({ bottom: 8 });
|
|
||||||
}
|
|
||||||
.height('100%').width('100%').margin({ top: 50 })
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,112 +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 { drawing, common2D } from '@kit.ArkGraphics2D';
|
|
||||||
import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife';
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct TestChangeColorPage {
|
|
||||||
private imageOne: Resource = $r('app.media.ic_test_change_color_png');
|
|
||||||
private imageTwo: Resource = $r('app.media.ic_test_change_color_png');
|
|
||||||
@State src: Resource = this.imageOne
|
|
||||||
@State src2: Resource = this.imageTwo
|
|
||||||
@State color: common2D.Color = {
|
|
||||||
alpha: 255,
|
|
||||||
red: 255,
|
|
||||||
green: 1,
|
|
||||||
blue: 1
|
|
||||||
};
|
|
||||||
@State DrawingColorFilterFirst: ColorFilter | undefined = undefined
|
|
||||||
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
Text($r('app.string.select_color_btn')).margin({ top: 20 })
|
|
||||||
Row() {
|
|
||||||
Button($r('app.string.red')).backgroundColor(Color.Red).margin(5).onClick(() => {
|
|
||||||
this.color = {
|
|
||||||
alpha: 255,
|
|
||||||
red: 255,
|
|
||||||
green: 1,
|
|
||||||
blue: 1
|
|
||||||
};
|
|
||||||
})
|
|
||||||
Button($r('app.string.yellow')).backgroundColor(Color.Yellow).margin(5).onClick(() => {
|
|
||||||
this.color = {
|
|
||||||
alpha: 255,
|
|
||||||
red: 255,
|
|
||||||
green: 255,
|
|
||||||
blue: 1
|
|
||||||
};
|
|
||||||
})
|
|
||||||
Button($r('app.string.green')).backgroundColor(Color.Green).margin(5).onClick(() => {
|
|
||||||
this.color = {
|
|
||||||
alpha: 255,
|
|
||||||
red: 1,
|
|
||||||
green: 255,
|
|
||||||
blue: 1
|
|
||||||
};
|
|
||||||
})
|
|
||||||
Button($r('app.string.blue')).backgroundColor(Color.Blue).margin(5).onClick(() => {
|
|
||||||
this.color = {
|
|
||||||
alpha: 255,
|
|
||||||
red: 1,
|
|
||||||
green: 1,
|
|
||||||
blue: 255
|
|
||||||
};
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.width('100%')
|
|
||||||
.height(50)
|
|
||||||
.justifyContent(FlexAlign.Center)
|
|
||||||
|
|
||||||
Text($r('app.string.master_image')).margin({ top: 20 })
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: this.src
|
|
||||||
}
|
|
||||||
}).width(110).height(110)
|
|
||||||
|
|
||||||
Text($r('app.string.click_img_to_change_color')).margin({ top: 30 })
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: this.src,
|
|
||||||
drawingColorFilter: this.DrawingColorFilterFirst
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.onClick(() => {
|
|
||||||
this.DrawingColorFilterFirst =
|
|
||||||
drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN);
|
|
||||||
}).width(110).height(110)
|
|
||||||
|
|
||||||
Text($r('app.string.test_non_svg_color')).margin({ top: 30 })
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: $r('app.media.ic_test_change_color_png'),
|
|
||||||
drawingColorFilter: drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN)
|
|
||||||
}
|
|
||||||
}).width(110).height(110)
|
|
||||||
|
|
||||||
Text($r('app.string.test_svg_color')).margin({ top: 30 })
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: $r('app.media.ic_test_change_color_svg'),
|
|
||||||
drawingColorFilter: drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN)
|
|
||||||
}
|
|
||||||
}).width(110).height(110)
|
|
||||||
|
|
||||||
}.width('100%').height('100%')
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +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 { ImageKnifeComponent } from '@ohos/libraryimageknife';
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct TestCommonImage {
|
|
||||||
private data: Array<string> = []
|
|
||||||
aboutToAppear(): void {
|
|
||||||
for (let index = 0; index < 30; index++) {
|
|
||||||
this.data.push(`https://img-blog.csdn.net/20140514114029140?${index}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
WaterFlow() {
|
|
||||||
ForEach(this.data,(item: string)=>{
|
|
||||||
FlowItem() {
|
|
||||||
Column(){
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: item,
|
|
||||||
placeholderSrc: $r('app.media.loading'),
|
|
||||||
errorholderSrc: $r('app.media.failed'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
signature: 'aaa'
|
|
||||||
}
|
|
||||||
}).width('50%').height(200)
|
|
||||||
}
|
|
||||||
}.height(200)
|
|
||||||
.backgroundColor('#95efd2')
|
|
||||||
},(item: string) => item)
|
|
||||||
}.columnsTemplate('1fr 1fr')
|
|
||||||
.columnsGap(10)
|
|
||||||
.rowsGap(5)
|
|
||||||
.backgroundColor(0xFAEEE0)
|
|
||||||
.width('100%').height('100%')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +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 { ImageKnifeComponent } from '@ohos/libraryimageknife'
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct TestErrorHolderPage {
|
|
||||||
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
Text('ImageKnifeComponent1').fontSize(20)
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: 'abc',
|
|
||||||
errorholderSrc:$r('app.media.failed')
|
|
||||||
}
|
|
||||||
}).width(200).height(200)
|
|
||||||
Text('ImageKnifeComponent2').fontSize(20)
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: 'abc',
|
|
||||||
errorholderSrc:$r('app.media.startIcon')
|
|
||||||
}
|
|
||||||
}).width(200).height(200)
|
|
||||||
Text('ImageKnifeComponent2').fontSize(20)
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: 'abc',
|
|
||||||
errorholderSrc:$r('app.media.mask_starfish')
|
|
||||||
}
|
|
||||||
}).width(200).height(200)
|
|
||||||
}
|
|
||||||
.height('100%') .width('100%')
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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:"单个"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -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%')
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,92 +0,0 @@
|
||||||
/*
|
|
||||||
* 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%')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -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,20 +103,20 @@ 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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Row(){
|
Row(){
|
||||||
Text($r('app.string.Click_on_add'))
|
Text("点击尺寸加50")
|
||||||
.onClick(()=> {
|
.onClick(()=> {
|
||||||
this.imageSize = this.imageSize + 50
|
this.imageSize = this.imageSize + 50
|
||||||
})
|
})
|
||||||
.width('50%').backgroundColor(0x88ff0000).textAlign(TextAlign.Center).height(50)
|
.width('50%').backgroundColor(0x88ff0000).textAlign(TextAlign.Center).height(50)
|
||||||
Text($r('app.string.Click_on_reduce'))
|
Text("点击尺寸减50")
|
||||||
.onClick(()=> {
|
.onClick(()=> {
|
||||||
this.imageSize = Math.max(this.imageSize - 50, 0)
|
this.imageSize = Math.max(this.imageSize - 50, 0)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,387 +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 { ImageKnifeComponent, ImageKnifeData, ImageKnifeOption, ImageKnifeRequest } from '@ohos/libraryimageknife';
|
|
||||||
import { router } from '@kit.ArkUI';
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct TestImageKnifeCallbackPage {
|
|
||||||
@State imageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc: '',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
border: { radius: 50 }
|
|
||||||
};
|
|
||||||
@State currentWidth: number = 200
|
|
||||||
@State currentHeight: number = 200
|
|
||||||
@State url: string | undefined = ''
|
|
||||||
@State imageType: string | undefined = ''
|
|
||||||
@State imageWidth: number | undefined = 0
|
|
||||||
@State imageHeight: number | undefined = 0
|
|
||||||
@State imageSize: number | undefined = 0
|
|
||||||
@State componentWidth: number | undefined = 0
|
|
||||||
@State componentHeight: number | undefined = 0
|
|
||||||
@State frameNum: number | undefined = 0
|
|
||||||
@State decodeSize: string | undefined = ''
|
|
||||||
@State errMsg: string | undefined = ''
|
|
||||||
@State errPhase: string | undefined = ''
|
|
||||||
@State errCode: number | undefined = 0
|
|
||||||
@State httpCode: number | undefined = 0
|
|
||||||
@State reqStartTime: string | undefined = ''
|
|
||||||
@State reqEndTime: string | undefined = ''
|
|
||||||
@State reqCancelTime: string | undefined = ''
|
|
||||||
@State memoryStartTime: string | undefined = ''
|
|
||||||
@State memoryEndTime: string | undefined = ''
|
|
||||||
@State diskStartTime: string | undefined = ''
|
|
||||||
@State diskEndTime: string | undefined = ''
|
|
||||||
@State netStartTime: string | undefined = ''
|
|
||||||
@State netEndTime: string | undefined = ''
|
|
||||||
@State decodeStartTime: string | undefined = ''
|
|
||||||
@State decodeEndTime: string | undefined = ''
|
|
||||||
@State showChild: boolean = true;
|
|
||||||
@State requestFrom: string = '';
|
|
||||||
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
Text($r('app.string.img_url', this.url)).fontSize(14)
|
|
||||||
Text($r('app.string.img_format', this.imageType)).fontSize(14)
|
|
||||||
Text($r('app.string.img_master_size', this.imageWidth, this.imageHeight, this.imageSize)).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_content_size', this.decodeSize)).fontSize(14)
|
|
||||||
Text($r('app.string.err_msg', this.errMsg)).fontSize(14)
|
|
||||||
Text($r('app.string.err_phase', this.errPhase)).fontSize(14)
|
|
||||||
Text($r('app.string.err_code', this.errCode)).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_end_time', this.reqEndTime)).fontSize(14)
|
|
||||||
Text($r('app.string.req_cancel_time', this.reqCancelTime)).fontSize(14)
|
|
||||||
Text($r('app.string.memory_start_time', this.memoryStartTime)).fontSize(14)
|
|
||||||
Text($r('app.string.memory_end_time', this.memoryEndTime)).fontSize(14)
|
|
||||||
Text($r('app.string.disk_start_time', this.diskStartTime)).fontSize(14)
|
|
||||||
Text($r('app.string.disk_end_time', this.diskEndTime)).fontSize(14)
|
|
||||||
Text($r('app.string.net_start_time', this.netStartTime)).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_end_time', this.decodeEndTime)).fontSize(14)
|
|
||||||
Text($r('app.string.request_data_from', this.requestFrom)).fontSize(14)
|
|
||||||
|
|
||||||
Scroll() {
|
|
||||||
Column() {
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
Button($r('app.string.Network_images'))
|
|
||||||
.fontSize(13)
|
|
||||||
.onClick(() => {
|
|
||||||
this.destroy();
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/10/v3/qaEzwkU0QeKb1yehnP2Xig/q7fxAlgMQKup-HUBayRLGQ.jpg',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: (data) => {
|
|
||||||
this.analyzeStartCallBackData(data);
|
|
||||||
},
|
|
||||||
onLoadFailed: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageData, req) => {
|
|
||||||
this.analyzeSuccessCallBackData(req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadCancel: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Button($r('app.string.gif'))
|
|
||||||
.fontSize(13)
|
|
||||||
.onClick(() => {
|
|
||||||
this.destroy();
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: (data) => {
|
|
||||||
this.analyzeStartCallBackData(data);
|
|
||||||
},
|
|
||||||
onLoadFailed: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageData, req) => {
|
|
||||||
this.analyzeSuccessCallBackData(req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadCancel: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Button($r('app.string.local_pic'))
|
|
||||||
.fontSize(13)
|
|
||||||
.onClick(() => {
|
|
||||||
this.destroy();
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.pngSample'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: (data) => {
|
|
||||||
this.analyzeStartCallBackData(data);
|
|
||||||
},
|
|
||||||
onLoadFailed: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageData, req) => {
|
|
||||||
this.analyzeSuccessCallBackData(req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadCancel: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
Button($r('app.string.net_load_failed'))
|
|
||||||
.fontSize(13)
|
|
||||||
.onClick(() => {
|
|
||||||
this.destroy();
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: 'https://img-blog.csdn.net/20140514114039140',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: (data) => {
|
|
||||||
this.analyzeStartCallBackData(data);
|
|
||||||
},
|
|
||||||
onLoadFailed: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageData, req) => {
|
|
||||||
this.analyzeSuccessCallBackData(req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadCancel: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Button($r('app.string.local_load_failed'))
|
|
||||||
.fontSize(13)
|
|
||||||
.onClick(() => {
|
|
||||||
this.destroy();
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: 'app.media.xxx',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: (data) => {
|
|
||||||
this.analyzeStartCallBackData(data);
|
|
||||||
},
|
|
||||||
onLoadFailed: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageData, req) => {
|
|
||||||
this.analyzeSuccessCallBackData(req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadCancel: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Button($r('app.string.share_load_failed'))
|
|
||||||
.fontSize(13)
|
|
||||||
.onClick(() => {
|
|
||||||
this.destroy();
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: 'datashare://ssas',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: (data) => {
|
|
||||||
this.analyzeStartCallBackData(data);
|
|
||||||
},
|
|
||||||
onLoadFailed: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageData, req) => {
|
|
||||||
this.analyzeSuccessCallBackData(req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadCancel: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Button($r('app.string.test_cancel_callback_btn'))
|
|
||||||
.fontSize(13)
|
|
||||||
.onClick(() => {
|
|
||||||
this.destroy();
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/bf/v3/lSjrRwFcS-ez6jp1ALSQFg/0n7R7XinSPyrYLqDu_1dfw.jpg',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: (data) => {
|
|
||||||
this.showChild = false;
|
|
||||||
this.analyzeStartCallBackData(data);
|
|
||||||
},
|
|
||||||
onLoadFailed: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageData, req) => {
|
|
||||||
this.analyzeSuccessCallBackData(req?.imageKnifeData);
|
|
||||||
},
|
|
||||||
onLoadCancel: (res, req) => {
|
|
||||||
this.analyzeFailedBackData(res, req?.imageKnifeData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Button($r('app.string.list_pic'))
|
|
||||||
.fontSize(13)
|
|
||||||
.onClick(() => {
|
|
||||||
router.push({
|
|
||||||
url: 'pages/TestListImageKnifeCallbackPage',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
if (this.showChild) {
|
|
||||||
ImageKnifeComponent(
|
|
||||||
{ imageKnifeOption: this.imageKnifeOption })
|
|
||||||
.height(this.currentHeight)
|
|
||||||
.width(this.currentWidth)
|
|
||||||
.margin({ top: 20, bottom: 20 })
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.width('100%')
|
|
||||||
}
|
|
||||||
}.alignItems(HorizontalAlign.Start)
|
|
||||||
}
|
|
||||||
|
|
||||||
formatDate(time: number | undefined) {
|
|
||||||
if (!time) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let date = new Date(time);
|
|
||||||
const year = date.getFullYear().toString()
|
|
||||||
let month = (date.getMonth() + 1).toString()
|
|
||||||
let day = date.getDate().toString()
|
|
||||||
let hour = date.getHours().toString()
|
|
||||||
let min = date.getMinutes().toString()
|
|
||||||
let seconds = date.getSeconds().toString()
|
|
||||||
let mill = date.getMilliseconds();
|
|
||||||
return `${year}-${month}-${day} ${hour}:${min}:${seconds}:${mill}`
|
|
||||||
}
|
|
||||||
|
|
||||||
analyzeStartCallBackData(req: ImageKnifeRequest | undefined) {
|
|
||||||
let data = req?.imageKnifeData;
|
|
||||||
if (data) {
|
|
||||||
if (typeof req?.imageKnifeOption.loadSrc == 'string') {
|
|
||||||
this.url = req?.imageKnifeOption.loadSrc;
|
|
||||||
}
|
|
||||||
this.componentWidth = req?.componentWidth;
|
|
||||||
this.componentHeight = req?.componentHeight;
|
|
||||||
this.reqStartTime = this.formatDate(data.timeInfo?.requestStartTime);
|
|
||||||
this.memoryStartTime = this.formatDate(data.timeInfo?.memoryCheckStartTime);
|
|
||||||
this.memoryEndTime = this.formatDate(data.timeInfo?.memoryCheckEndTime);
|
|
||||||
this.requestFrom = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
analyzeSuccessCallBackData(data: ImageKnifeData | undefined) {
|
|
||||||
if (data) {
|
|
||||||
this.imageWidth = data.imageWidth;
|
|
||||||
this.imageHeight = data.imageHeight;
|
|
||||||
this.imageSize = data.bufSize;
|
|
||||||
this.frameNum = data.frameCount;
|
|
||||||
this.httpCode = data.httpCode
|
|
||||||
this.decodeSize = JSON.stringify(data.decodeImages);
|
|
||||||
this.imageType = data.type;
|
|
||||||
this.reqEndTime = this.formatDate(data.timeInfo?.requestEndTime);
|
|
||||||
this.diskStartTime = this.formatDate(data.timeInfo?.diskCheckStartTime);
|
|
||||||
this.diskEndTime = this.formatDate(data.timeInfo?.diskCheckEndTime);
|
|
||||||
this.netStartTime = this.formatDate(data.timeInfo?.netRequestStartTime);
|
|
||||||
this.netEndTime = this.formatDate(data.timeInfo?.netRequestEndTime);
|
|
||||||
this.decodeStartTime = this.formatDate(data.timeInfo?.diskCheckStartTime);
|
|
||||||
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) {
|
|
||||||
if (data) {
|
|
||||||
this.errMsg = res;
|
|
||||||
this.errPhase = data.errorInfo?.phase;
|
|
||||||
this.errCode = data.errorInfo?.code;
|
|
||||||
this.httpCode = data.httpCode;
|
|
||||||
this.reqEndTime = this.formatDate(data.timeInfo?.requestEndTime);
|
|
||||||
this.diskStartTime = this.formatDate(data.timeInfo?.diskCheckStartTime);
|
|
||||||
this.diskEndTime = this.formatDate(data.timeInfo?.diskCheckEndTime);
|
|
||||||
this.netStartTime = this.formatDate(data.timeInfo?.netRequestStartTime);
|
|
||||||
this.netEndTime = this.formatDate(data.timeInfo?.netRequestEndTime);
|
|
||||||
this.decodeStartTime = this.formatDate(data.timeInfo?.diskCheckStartTime);
|
|
||||||
this.decodeEndTime = this.formatDate(data.timeInfo?.diskCheckEndTime);
|
|
||||||
this.reqCancelTime = this.formatDate(data.timeInfo?.requestCancelTime)
|
|
||||||
this.requestFrom = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
destroy() {
|
|
||||||
this.currentWidth = 200
|
|
||||||
this.currentHeight = 200
|
|
||||||
this.url = ''
|
|
||||||
this.imageType = ''
|
|
||||||
this.imageWidth = 0
|
|
||||||
this.imageHeight = 0
|
|
||||||
this.imageSize = 0
|
|
||||||
this.componentWidth = 0
|
|
||||||
this.componentHeight = 0
|
|
||||||
this.frameNum = 0
|
|
||||||
this.decodeSize = ''
|
|
||||||
this.errMsg = ''
|
|
||||||
this.errPhase = ''
|
|
||||||
this.errCode = 0
|
|
||||||
this.httpCode = 0
|
|
||||||
this.reqStartTime = ''
|
|
||||||
this.reqEndTime = ''
|
|
||||||
this.reqCancelTime = ''
|
|
||||||
this.memoryStartTime = ''
|
|
||||||
this.memoryEndTime = ''
|
|
||||||
this.diskStartTime = ''
|
|
||||||
this.diskEndTime = ''
|
|
||||||
this.netStartTime = ''
|
|
||||||
this.netEndTime = ''
|
|
||||||
this.decodeStartTime = ''
|
|
||||||
this.decodeEndTime = ''
|
|
||||||
this.showChild = true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,40 +22,40 @@ 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("预加载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("内存缓存获取gif").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("文件缓存获取gif").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")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex() {
|
Flex() {
|
||||||
Button($r('app.string.Preloading_static_images')).onClick(() => {
|
Button("预加载静态图").onClick(() => {
|
||||||
this.imageKnifeOption.loadSrc =
|
this.imageKnifeOption.loadSrc =
|
||||||
'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp'
|
'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp'
|
||||||
})
|
})
|
||||||
Button($r('app.string.Retrieve_images_from_memory')).onClick(() => {
|
Button("内存缓存获取").onClick(() => {
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
||||||
CacheStrategy.Memory)
|
CacheStrategy.Memory)
|
||||||
|
@ -63,7 +63,7 @@ struct TestIsUrlExist {
|
||||||
this.source = data!.source
|
this.source = data!.source
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
Button($r('app.string.Retrieve_images_from_disk')).onClick(() => {
|
Button("文件缓存获取").onClick(() => {
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
||||||
CacheStrategy.File)
|
CacheStrategy.File)
|
||||||
|
|
|
@ -1,103 +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 { ImageKnifeComponent} from '@ohos/libraryimageknife';
|
|
||||||
|
|
||||||
class ArrayElement {
|
|
||||||
public src: string = '';
|
|
||||||
public w: number = 0;
|
|
||||||
public h: number = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct TestListImageKnifeCallbackPage {
|
|
||||||
private wid: number = 200;
|
|
||||||
private hig: number = 200;
|
|
||||||
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://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/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/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/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/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/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/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/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/ed/v3/KMO4D6D2QGuVOCLX4AhOFA/ef51xAaLQuK7BsnuD9abog.jpg',
|
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/d9/v3/FSZH0aTdSqWxeAaxoPvi0g/RqxPxUCXQFiTMBfKTF9kkw.jpg',
|
|
||||||
'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://img-blog.csdn.net/20140514114029140',
|
|
||||||
'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
|
||||||
$r('app.media.pngSample'),
|
|
||||||
$r('app.media.rabbit')
|
|
||||||
]
|
|
||||||
private data: Array<ArrayElement> = [];
|
|
||||||
|
|
||||||
aboutToAppear(): void {
|
|
||||||
for (let i = 0; i < this.dataArray.length; i++) {
|
|
||||||
let element: ArrayElement = {
|
|
||||||
src: this.dataArray[i],
|
|
||||||
w: this.wid -(i*5),
|
|
||||||
h: this.hig -(i*5)
|
|
||||||
}
|
|
||||||
this.data.push(element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
build() {
|
|
||||||
List({ space: 3 }) {
|
|
||||||
ForEach(this.data, (item: ArrayElement) => {
|
|
||||||
ListItem() {
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption:
|
|
||||||
{
|
|
||||||
loadSrc: item.src,
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: (data) => {
|
|
||||||
console.log('listCache start:{ url:' + data?.imageKnifeOption.loadSrc +
|
|
||||||
',componentWidth:' + data?.componentWidth +
|
|
||||||
',componentHeight:' + data?.componentHeight +
|
|
||||||
'},' + JSON.stringify(data?.imageKnifeData))
|
|
||||||
},
|
|
||||||
onLoadFailed: (res, req) => {
|
|
||||||
console.log('listCache onLoadFailed:res:' + res + ';' + JSON.stringify(req?.imageKnifeData))
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageData,req) => {
|
|
||||||
console.log('listCache onLoadSuccess:' + JSON.stringify(req?.imageKnifeData))
|
|
||||||
},
|
|
||||||
onLoadCancel: (res, req) => {
|
|
||||||
console.log('listCache onLoadCancel:res:' + res + ';' + JSON.stringify(req?.imageKnifeData))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 },
|
|
||||||
}
|
|
||||||
}).height(item.w).width(item.h)
|
|
||||||
}.width('100%')
|
|
||||||
}, (item: ArrayElement,index) => (item.src+index))
|
|
||||||
}.width('100%').height('100%')
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,101 +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 { ImageKnife, ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife';
|
|
||||||
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct TestLoadCancelListenerPage {
|
|
||||||
@State currentWidth: number = 200
|
|
||||||
@State currentHeight: number = 200
|
|
||||||
@State showChild: boolean = true;
|
|
||||||
@State text: string = '';
|
|
||||||
@State ImageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc: '',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
border: { radius: 50 }
|
|
||||||
};
|
|
||||||
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
Text($r('app.string.onLoadCancel_reason', this.text)).margin(20).fontSize(15)
|
|
||||||
Button($r('app.string.rm_component_of_net'))
|
|
||||||
.margin(20)
|
|
||||||
.onClick(() => {
|
|
||||||
this.clearCache();
|
|
||||||
this.ImageKnifeOption = {
|
|
||||||
loadSrc: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: () => {
|
|
||||||
this.showChild = false;
|
|
||||||
},
|
|
||||||
onLoadCancel: (res) => {
|
|
||||||
this.text = res
|
|
||||||
console.log('TestLoadCancelListenerPage----onLoadCancel> url:' + res)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Button($r('app.string.component_display'))
|
|
||||||
.margin(20).onClick(() => {
|
|
||||||
this.text = '';
|
|
||||||
this.showChild = true;
|
|
||||||
this.ImageKnifeOption = {
|
|
||||||
loadSrc: '',
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
border: { radius: 50 }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Button($r('app.string.rm_component_of_local'))
|
|
||||||
.margin(20)
|
|
||||||
.onClick(() => {
|
|
||||||
this.clearCache();
|
|
||||||
this.ImageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.loading'),
|
|
||||||
objectFit: ImageFit.Contain,
|
|
||||||
onLoadListener: {
|
|
||||||
onLoadStart: () => {
|
|
||||||
this.showChild = false;
|
|
||||||
},
|
|
||||||
onLoadCancel: (res) => {
|
|
||||||
this.text = res
|
|
||||||
console.log('TestLoadCancelListenerPage----onLoadCancel> url:' + res)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
border: { radius: 50 }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (this.showChild) {
|
|
||||||
ImageKnifeComponent(
|
|
||||||
{ imageKnifeOption: this.ImageKnifeOption })
|
|
||||||
.height(150)
|
|
||||||
.width(150)
|
|
||||||
.backgroundColor(Color.Orange)
|
|
||||||
.margin({ top: 20 })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.height('100%')
|
|
||||||
.width('100%')
|
|
||||||
}
|
|
||||||
|
|
||||||
clearCache(){
|
|
||||||
ImageKnife.getInstance().removeAllMemoryCache();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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("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("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("加载图片(预加载后可断网加载)").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
|
||||||
|
|
|
@ -22,45 +22,45 @@ 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("预加载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("内存缓存获取gif").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("文件缓存获取gif").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})
|
||||||
}
|
}
|
||||||
|
|
||||||
Flex() {
|
Flex() {
|
||||||
Button($r('app.string.Preloading_static_images')).onClick(() => {
|
Button("预加载静态图").onClick(() => {
|
||||||
this.imageKnifeOption.loadSrc = 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp';
|
this.imageKnifeOption.loadSrc = 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp';
|
||||||
this.url = 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp';
|
this.url = 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp';
|
||||||
})
|
})
|
||||||
.margin({left:10})
|
.margin({left:10})
|
||||||
Button($r('app.string.Retrieve_images_from_memory')).onClick(() => {
|
Button("内存缓存获取").onClick(() => {
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
||||||
CacheStrategy.Memory)
|
CacheStrategy.Memory)
|
||||||
|
@ -69,7 +69,7 @@ struct TestRemoveCache {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.margin({left:10})
|
.margin({left:10})
|
||||||
Button($r('app.string.Retrieve_images_from_disk')).onClick(() => {
|
Button("文件缓存获取").onClick(() => {
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
||||||
CacheStrategy.File)
|
CacheStrategy.File)
|
||||||
|
@ -81,19 +81,19 @@ struct TestRemoveCache {
|
||||||
}.margin({ top: 10 })
|
}.margin({ top: 10 })
|
||||||
|
|
||||||
Flex() {
|
Flex() {
|
||||||
Button($r('app.string.Delete_all_caches')).onClick(() => {
|
Button("删除全部缓存").onClick(() => {
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.removeAllMemoryCache()
|
.removeAllMemoryCache()
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.removeAllFileCache()
|
.removeAllFileCache()
|
||||||
})
|
})
|
||||||
.margin({left:5})
|
.margin({left:5})
|
||||||
Button($r('app.string.Delete_all_memory_caches')).onClick(() => {
|
Button("删除全部内存缓存").onClick(() => {
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.removeAllMemoryCache()
|
.removeAllMemoryCache()
|
||||||
})
|
})
|
||||||
.margin({left:5})
|
.margin({left:5})
|
||||||
Button($r('app.string.Delete_all_file_caches')).onClick(() => {
|
Button("删除全部文件缓存").onClick(() => {
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.removeAllFileCache()
|
.removeAllFileCache()
|
||||||
})
|
})
|
||||||
|
@ -101,12 +101,12 @@ struct TestRemoveCache {
|
||||||
}.margin({ top: 10 })
|
}.margin({ top: 10 })
|
||||||
|
|
||||||
Flex() {
|
Flex() {
|
||||||
Button($r('app.string.Delete_all_custom_memory_caches')).onClick(() => {
|
Button("删除自定义内存缓存").onClick(() => {
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.removeMemoryCache(this.url)
|
.removeMemoryCache(this.url)
|
||||||
})
|
})
|
||||||
.margin({left:20})
|
.margin({left:20})
|
||||||
Button($r('app.string.Delete_all_custom_file_caches')).onClick(() => {
|
Button("删除自定义文件缓存").onClick(() => {
|
||||||
ImageKnife.getInstance()
|
ImageKnife.getInstance()
|
||||||
.removeFileCache(this.url)
|
.removeFileCache(this.url)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,68 +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 { ImageKnifeComponent, ImageKnife, ImageKnifeOption } from '@ohos/libraryimageknife'
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct TestSetCustomImagePage {
|
|
||||||
@State imageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc: $r('app.media.startIcon'),
|
|
||||||
placeholderSrc: $r('app.media.loading')
|
|
||||||
}
|
|
||||||
aboutToAppear(): void {
|
|
||||||
ImageKnife.getInstance().setCustomGetImage(custom)
|
|
||||||
}
|
|
||||||
aboutToDisappear(): void {
|
|
||||||
ImageKnife.getInstance().setCustomGetImage()
|
|
||||||
}
|
|
||||||
getResourceString(res:Resource){
|
|
||||||
return getContext().resourceManager.getStringSync(res.id)
|
|
||||||
}
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
Button(this.getResourceString($r('app.string.Custom_network_download')) + ' a').onClick(()=>{
|
|
||||||
this.imageKnifeOption ={
|
|
||||||
loadSrc: 'aaa',
|
|
||||||
placeholderSrc: $r('app.media.loading')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Button(this.getResourceString($r('app.string.Custom_network_download')) + ' b').onClick(()=>{
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: 'bbb',
|
|
||||||
placeholderSrc: $r('app.media.loading')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Button(this.getResourceString($r('app.string.Custom_network_download')) + ' c').onClick(()=>{
|
|
||||||
this.imageKnifeOption = {
|
|
||||||
loadSrc: 'ccc',
|
|
||||||
placeholderSrc: $r('app.media.loading')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: this.imageKnifeOption
|
|
||||||
}).width(300)
|
|
||||||
.height(300)
|
|
||||||
}
|
|
||||||
.width('100%')
|
|
||||||
.height('100%')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Concurrent
|
|
||||||
async function custom(context: Context, src: string | PixelMap | Resource,headers?: Record<string,Object>): Promise<ArrayBuffer | undefined> {
|
|
||||||
console.info('ImageKnife:: custom download:' + src)
|
|
||||||
// 举例写死从本地文件读取,也可以自己请求网络图片
|
|
||||||
let buffer = context.resourceManager.getMediaContentSync($r('app.media.pngSample').id).buffer as ArrayBuffer
|
|
||||||
return buffer
|
|
||||||
}
|
|
|
@ -1,79 +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 { ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife'
|
|
||||||
|
|
||||||
@ComponentV2
|
|
||||||
export struct ZuImage {
|
|
||||||
@Param @Require src: PixelMap | ResourceStr | string | undefined
|
|
||||||
@Param @Require placeholderSrc: PixelMap | ResourceStr | string | undefined
|
|
||||||
@Local errorholderSrc: PixelMap | ResourceStr | string | undefined
|
|
||||||
|
|
||||||
build() {
|
|
||||||
if (this.src) {
|
|
||||||
//当前版本存在bug
|
|
||||||
ImageKnifeComponent({
|
|
||||||
imageKnifeOption: {
|
|
||||||
loadSrc: this.src,
|
|
||||||
placeholderSrc: this.placeholderSrc,
|
|
||||||
errorholderSrc: this.errorholderSrc ?? this.placeholderSrc,
|
|
||||||
objectFit: ImageFit.Cover
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
Image(this.placeholderSrc)
|
|
||||||
.objectFit(ImageFit.Cover)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@ComponentV2
|
|
||||||
struct TestTaskResourcePage {
|
|
||||||
@Local stateMenus: Array<string> = [
|
|
||||||
'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://img-blog.csdn.net/20140514114029140',
|
|
||||||
'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
|
|
||||||
]
|
|
||||||
@Builder
|
|
||||||
_buildItem(item: string) {
|
|
||||||
Column({ space: 8 }) {
|
|
||||||
ZuImage({
|
|
||||||
src: item,
|
|
||||||
placeholderSrc: $r('app.media.loading')
|
|
||||||
}).width(44)
|
|
||||||
.height(44)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
build() {
|
|
||||||
|
|
||||||
Grid() {
|
|
||||||
ForEach(this.stateMenus, (item: string) => {
|
|
||||||
GridItem() {
|
|
||||||
this._buildItem(item)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}.width('100%')
|
|
||||||
.columnsTemplate('1fr 1fr 1fr 1fr 1fr')
|
|
||||||
.rowsGap(24)
|
|
||||||
.padding({
|
|
||||||
top: 24,
|
|
||||||
bottom: 24,
|
|
||||||
left: 24,
|
|
||||||
right: 24
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,7 +35,7 @@ struct TestWriteCacheStage {
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
Button($r('app.string.Write_memory_and_file')).margin({top:10}).onClick(async ()=>{
|
Button("写入内存文件缓存").margin({top:10}).onClick(async ()=>{
|
||||||
this.imageKnifeOption1 = {
|
this.imageKnifeOption1 = {
|
||||||
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'),
|
||||||
|
@ -46,9 +46,9 @@ struct TestWriteCacheStage {
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
imageKnifeOption: this.imageKnifeOption1
|
imageKnifeOption: this.imageKnifeOption1
|
||||||
}).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("写入内存缓存").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
|
||||||
|
@ -57,7 +57,7 @@ struct TestWriteCacheStage {
|
||||||
ImageKnifeComponent({
|
ImageKnifeComponent({
|
||||||
imageKnifeOption: this.imageKnifeOption2
|
imageKnifeOption: this.imageKnifeOption2
|
||||||
}).width(200).height(200).margin({top:10})
|
}).width(200).height(200).margin({top:10})
|
||||||
Button($r('app.string.Write_file')).margin({top:10}).onClick(async ()=>{
|
Button("写入文件缓存").margin({top:10}).onClick(async ()=>{
|
||||||
this.imageKnifeOption3 = {
|
this.imageKnifeOption3 = {
|
||||||
loadSrc:'https://img-blog.csdn.net/20140514114029140',
|
loadSrc:'https://img-blog.csdn.net/20140514114029140',
|
||||||
placeholderSrc:$r('app.media.loading'),
|
placeholderSrc:$r('app.media.loading'),
|
||||||
|
|
|
@ -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 }
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,12 @@ struct TransformPage {
|
||||||
ImageKnifeComponent({ imageKnifeOption: this.ImageKnifeOption }).height(200).width(200)
|
ImageKnifeComponent({ imageKnifeOption: this.ImageKnifeOption }).height(200).width(200)
|
||||||
.transform(this.matrix1)
|
.transform(this.matrix1)
|
||||||
// Image($r('app.media.rabbit')).objectFit(ImageFit.Contain).height(200).width(200).transform(this.matrix1)
|
// Image($r('app.media.rabbit')).objectFit(ImageFit.Contain).height(200).width(200).transform(this.matrix1)
|
||||||
Button($r('app.string.Enlarge')).onClick(()=>{
|
Button("放大").onClick(()=>{
|
||||||
this.custom_scale = this.custom_scale * 2
|
this.custom_scale = this.custom_scale * 2
|
||||||
this.matrix1 = matrix4.identity().scale({ x: this.custom_scale, y: this.custom_scale })
|
this.matrix1 = matrix4.identity().scale({ x: this.custom_scale, y: this.custom_scale })
|
||||||
})
|
})
|
||||||
|
|
||||||
Button($r('app.string.Reduce')).onClick(()=>{
|
Button("缩小").onClick(()=>{
|
||||||
this.custom_scale = this.custom_scale / 2
|
this.custom_scale = this.custom_scale / 2
|
||||||
this.matrix1 = matrix4.identity().scale({ x: this.custom_scale, y: this.custom_scale })
|
this.matrix1 = matrix4.identity().scale({ x: this.custom_scale, y: this.custom_scale })
|
||||||
})
|
})
|
||||||
|
|
|
@ -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')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,66 +12,105 @@
|
||||||
* 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 { CommonDataSource } from './model/CommonDataSource'
|
|
||||||
import { UserAvatar } from './User'
|
import { UserAvatar } from './User'
|
||||||
|
|
||||||
|
class CommonDataSource <T> implements IDataSource {
|
||||||
|
private dataArray: T[] = []
|
||||||
|
private listeners: DataChangeListener[] = []
|
||||||
|
|
||||||
|
constructor(element: []) {
|
||||||
|
this.dataArray = element
|
||||||
|
}
|
||||||
|
|
||||||
|
public getData(index: number) {
|
||||||
|
return this.dataArray[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
public totalCount(): number {
|
||||||
|
return this.dataArray.length
|
||||||
|
}
|
||||||
|
|
||||||
|
public addData(index: number, data: T[]): void {
|
||||||
|
this.dataArray = this.dataArray.concat(data)
|
||||||
|
this.notifyDataAdd(index)
|
||||||
|
}
|
||||||
|
|
||||||
|
unregisterDataChangeListener(listener: DataChangeListener): void {
|
||||||
|
const pos = this.listeners.indexOf(listener);
|
||||||
|
if (pos >= 0) {
|
||||||
|
this.listeners.splice(pos, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
registerDataChangeListener(listener: DataChangeListener): void {
|
||||||
|
if (this.listeners.indexOf(listener) < 0) {
|
||||||
|
this.listeners.push(listener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyDataAdd(index: number): void {
|
||||||
|
this.listeners.forEach((listener: DataChangeListener) => {
|
||||||
|
listener.onDataAdd(index)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
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',
|
"http://e.hiphotos.baidu.com/image/pic/item/a1ec08fa513d2697e542494057fbb2fb4316d81e.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/e2/v3/4zI1Xm_3STmV30aZXWRrKw/6aN7WodDRUiBApgffiLPCg.jpg',
|
"http://c.hiphotos.baidu.com/image/pic/item/30adcbef76094b36de8a2fe5a1cc7cd98d109d99.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/42/v3/2dSQCqERTP2TTPyssOMEbQ/zL1ebnKKQ_ilqTDcwCAkOw.jpg',
|
"http://h.hiphotos.baidu.com/image/pic/item/7c1ed21b0ef41bd5f2c2a9e953da81cb39db3d1d.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/78/v3/qQJpAtRGQe2e_VhbGHDgIw/b3zlit99S6GybD3XdNwqJw.jpg',
|
"http://g.hiphotos.baidu.com/image/pic/item/55e736d12f2eb938d5277fd5d0628535e5dd6f4a.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/55/v3/5DZ2LLqYSsK85-shqgLveQ/7ZXcyCWNTvOzQP5FFLBGkg.jpg',
|
"http://e.hiphotos.baidu.com/image/pic/item/4e4a20a4462309f7e41f5cfe760e0cf3d6cad6ee.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/3e/v3/LqRoLI-PRSu9Nqa8KdJ-pQ/dSqskBpSR9eraAMn7NBdqA.jpg',
|
"http://b.hiphotos.baidu.com/image/pic/item/9d82d158ccbf6c81b94575cfb93eb13533fa40a2.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/25/v3/jgB2ekkTRX-3yTYZalnANQ/xff_x9cbSPqb7fbNwgJa7A.jpg',
|
"http://e.hiphotos.baidu.com/image/pic/item/4bed2e738bd4b31c1badd5a685d6277f9e2ff81e.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/fb/v3/alXwXLHKSyCAIWt_ydgD2g/BCCuu25TREOitQxM7eYOEw.jpg',
|
"http://g.hiphotos.baidu.com/image/pic/item/0d338744ebf81a4c87a3add4d52a6059252da61e.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/63/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg',
|
"http://a.hiphotos.baidu.com/image/pic/item/f2deb48f8c5494ee5080c8142ff5e0fe99257e19.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/16/v3/fm2tO4TsRH6mv_D_nSSd5w/FscLpLwQQ-KuV7oaprFK2Q.jpg',
|
"http://f.hiphotos.baidu.com/image/pic/item/4034970a304e251f503521f5a586c9177e3e53f9.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/89/v3/UAUvtPHqRD-GWWANsEC57Q/zcRJCQebQ322Aby4jzmwmQ.jpg',
|
"http://b.hiphotos.baidu.com/image/pic/item/279759ee3d6d55fbb3586c0168224f4a20a4dd7e.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/30/v3/tUUzzx73R4yp8G--lMhuWQ/EBbcu_dLTT-Jj68XAh6mtA.jpg',
|
"http://img2.xkhouse.com/bbs/hfhouse/data/attachment/forum/corebbs/2009-11/2009113011534566298.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/76/v3/EyF6z4FISpCHhae38eEexw/OtyAiu-zSSevNQYvUdtVmA.jpg',
|
"http://a.hiphotos.baidu.com/image/pic/item/e824b899a9014c087eb617650e7b02087af4f464.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/37/v3/12rH1yiEQmK9wlOOcy5avQ/RzBXiEBRRqOC7LRkwNj6VA.jpg',
|
"http://c.hiphotos.baidu.com/image/pic/item/9c16fdfaaf51f3de1e296fa390eef01f3b29795a.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/9a/v3/TpRN4AIzRoyUXIqWdKoE0g/ShOnD_tfS46HDbpSWhbCkQ.jpg',
|
"http://d.hiphotos.baidu.com/image/pic/item/b58f8c5494eef01f119945cbe2fe9925bc317d2a.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/03/v3/H3X17s8eTdS2w56JgbB5jQ/a45sT-j8Sbe8sSQXTzeYvQ.jpg',
|
"http://h.hiphotos.baidu.com/image/pic/item/902397dda144ad340668b847d4a20cf430ad851e.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/10/v3/qaEzwkU0QeKb1yehnP2Xig/q7fxAlgMQKup-HUBayRLGQ.jpg',
|
"http://b.hiphotos.baidu.com/image/pic/item/359b033b5bb5c9ea5c0e3c23d139b6003bf3b374.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/96/v3/rMJJoAflTDSWa1z2pHs2wg/8dOqD0GlQBOCL5AvQok9FQ.jpg',
|
"http://a.hiphotos.baidu.com/image/pic/item/8d5494eef01f3a292d2472199d25bc315d607c7c.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/ed/v3/KMO4D6D2QGuVOCLX4AhOFA/ef51xAaLQuK7BsnuD9abog.jpg',
|
"http://b.hiphotos.baidu.com/image/pic/item/e824b899a9014c08878b2c4c0e7b02087af4f4a3.jpg",
|
||||||
'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/d9/v3/FSZH0aTdSqWxeAaxoPvi0g/RqxPxUCXQFiTMBfKTF9kkw.jpg',
|
"http://g.hiphotos.baidu.com/image/pic/item/6d81800a19d8bc3e770bd00d868ba61ea9d345f2.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://img-blog.csdnimg.cn/20191215043500229.png',
|
||||||
'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 +118,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 +128,6 @@ struct ReuseImage {
|
||||||
UserAvatar({
|
UserAvatar({
|
||||||
userInfo:this.userInfo
|
userInfo:this.userInfo
|
||||||
})
|
})
|
||||||
}.width('100%').height('100%')
|
}.width("100%").height("100%")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,20 +1,19 @@
|
||||||
/*
|
/*
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
|
||||||
import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife'
|
import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife'
|
||||||
import { dataSharePredicates } from '@kit.ArkData';
|
|
||||||
import { photoAccessHelper } from '@kit.MediaLibraryKit';
|
|
||||||
|
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
|
@ -32,21 +31,59 @@ struct DataShareUriLoadPage {
|
||||||
build() {
|
build() {
|
||||||
Scroll() {
|
Scroll() {
|
||||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
Text($r('app.string.Retrieve_media_gallery')).fontSize(15)
|
Text("获取媒体图库的uri用ImageKnife展示").fontSize(15)
|
||||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
Button($r('app.string.Click_load_Uri'))
|
Button("点击加载Uri并展示")
|
||||||
.onClick(async () => {
|
.onClick(() => {
|
||||||
let photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
|
// 获取mediaLibrary实例,后续用到此实例均采用此处获取的实例
|
||||||
photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
|
const context = getContext(this);
|
||||||
photoSelectOptions.maxSelectNumber = 1;
|
let media = mediaLibrary.getMediaLibrary(context);
|
||||||
let uris: Array<string> = [];
|
|
||||||
let photoViewPicker = new photoAccessHelper.PhotoViewPicker();
|
let imageType = mediaLibrary.MediaType.IMAGE;
|
||||||
let photoSelectResult: photoAccessHelper.PhotoSelectResult = await photoViewPicker.select(photoSelectOptions);
|
// 创建文件获取选项,此处参数为获取image类型的文件资源
|
||||||
uris = photoSelectResult.photoUris;
|
let imagesFetchOp:mediaLibrary.MediaFetchOptions = {
|
||||||
this.imageKnifeOption1 = {
|
selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ?',
|
||||||
loadSrc: uris[0],
|
selectionArgs: [imageType.toString()],
|
||||||
placeholderSrc:$r('app.media.loading')
|
};
|
||||||
}
|
// 获取文件资源,使用callback方式返回异步结果
|
||||||
|
media.getFileAssets(imagesFetchOp, (error, fetchFileResult) => {
|
||||||
|
// 判断获取的文件资源的检索结果集是否为undefined,若为undefined则接口调用失败
|
||||||
|
if (fetchFileResult == undefined) {
|
||||||
|
console.log('get fetchFileResult failed with error: ' + error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取文件检索结果集中的总数
|
||||||
|
const count = fetchFileResult.getCount();
|
||||||
|
// 判断结果集中的数量是否小于0,小于0时表示接口调用失败
|
||||||
|
if (count < 0) {
|
||||||
|
console.log('get count from fetchFileResult failed, count: ' + count);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 判断结果集中的数量是否等于0,等于0时表示接口调用成功,但是检索结果集为空,请检查文件获取选项参数配置是否有误和设备中是否存在相应文件
|
||||||
|
if (count == 0) {
|
||||||
|
console.log('The count of fetchFileResult is zero');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log('Get fetchFileResult successfully, count: ' + count);
|
||||||
|
// 获取文件检索结果集中的第一个资源,使用callback方式返回异步结果
|
||||||
|
fetchFileResult.getFirstObject((error, fileAsset) => {
|
||||||
|
// 检查获取的第一个资源是否为undefined,若为undefined则接口调用失败
|
||||||
|
if (fileAsset == undefined) {
|
||||||
|
console.log('get first object failed with error: ' + error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("fileAsset id=" + fileAsset.id + " fileAsset uri=" + fileAsset.uri + " fileAsset displayName=" + fileAsset.displayName)
|
||||||
|
|
||||||
|
// 加载图库第一张图片的uri
|
||||||
|
this.imageKnifeOption1 = {
|
||||||
|
loadSrc: fileAsset.uri,
|
||||||
|
placeholderSrc: $r('app.media.loading'),
|
||||||
|
errorholderSrc: $r('app.media.failed')
|
||||||
|
}
|
||||||
|
// 释放FetchFileResult实例并使其失效。无法调用其他方法
|
||||||
|
fetchFileResult.close();
|
||||||
|
});
|
||||||
|
});
|
||||||
}).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)
|
||||||
}.width('100%').backgroundColor(Color.Pink)
|
}.width('100%').backgroundColor(Color.Pink)
|
||||||
|
|
|
@ -1,55 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export class CommonDataSource <T> implements IDataSource {
|
|
||||||
private dataArray: T[] = []
|
|
||||||
private listeners: DataChangeListener[] = []
|
|
||||||
|
|
||||||
constructor(element: []) {
|
|
||||||
this.dataArray = element
|
|
||||||
}
|
|
||||||
|
|
||||||
public getData(index: number) {
|
|
||||||
return this.dataArray[index]
|
|
||||||
}
|
|
||||||
|
|
||||||
public totalCount(): number {
|
|
||||||
return this.dataArray.length
|
|
||||||
}
|
|
||||||
|
|
||||||
public addData(index: number, data: T[]): void {
|
|
||||||
this.dataArray = this.dataArray.concat(data)
|
|
||||||
this.notifyDataAdd(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
unregisterDataChangeListener(listener: DataChangeListener): void {
|
|
||||||
const pos = this.listeners.indexOf(listener);
|
|
||||||
if (pos >= 0) {
|
|
||||||
this.listeners.splice(pos, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
registerDataChangeListener(listener: DataChangeListener): void {
|
|
||||||
if (this.listeners.indexOf(listener) < 0) {
|
|
||||||
this.listeners.push(listener)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyDataAdd(index: number): void {
|
|
||||||
this.listeners.forEach((listener: DataChangeListener) => {
|
|
||||||
listener.onDataAdd(index)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,93 +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 {ImageKnife, ImageKnifeRequest} from '@ohos/libraryimageknife'
|
|
||||||
import { IDataSourcePrefetching } from '@kit.ArkUI';
|
|
||||||
import { HashMap } from '@kit.ArkTS';
|
|
||||||
|
|
||||||
const IMADE_UNAVAILABLE = $r('app.media.failed')
|
|
||||||
export interface InfoItem {
|
|
||||||
albumUrl: string | Resource
|
|
||||||
}
|
|
||||||
export default class DataSourcePrefetchingImageKnife implements IDataSourcePrefetching {
|
|
||||||
private dataArray: Array<InfoItem>
|
|
||||||
private readonly requestList: HashMap<number,ImageKnifeRequest> = new HashMap()
|
|
||||||
private listeners: DataChangeListener[] = [];
|
|
||||||
|
|
||||||
constructor(dataArray: Array<InfoItem>) {
|
|
||||||
this.dataArray = dataArray;
|
|
||||||
}
|
|
||||||
public getData(index: number) {
|
|
||||||
return this.dataArray[index]
|
|
||||||
}
|
|
||||||
|
|
||||||
public totalCount(): number {
|
|
||||||
return this.dataArray.length
|
|
||||||
}
|
|
||||||
|
|
||||||
public addData(index: number, data: InfoItem[]): void {
|
|
||||||
this.dataArray = this.dataArray.concat(data)
|
|
||||||
this.notifyDataAdd(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
unregisterDataChangeListener(listener: DataChangeListener): void {
|
|
||||||
const pos = this.listeners.indexOf(listener);
|
|
||||||
if (pos >= 0) {
|
|
||||||
this.listeners.splice(pos, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
registerDataChangeListener(listener: DataChangeListener): void {
|
|
||||||
if (this.listeners.indexOf(listener) < 0) {
|
|
||||||
this.listeners.push(listener)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyDataAdd(index: number): void {
|
|
||||||
this.listeners.forEach((listener: DataChangeListener) => {
|
|
||||||
listener.onDataAdd(index)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
async prefetch(index: number): Promise<void> {
|
|
||||||
let item = this.dataArray[index]
|
|
||||||
if (typeof item.albumUrl == 'string') {
|
|
||||||
// 图片预加载
|
|
||||||
let request = ImageKnife.getInstance().preload({
|
|
||||||
loadSrc:item.albumUrl,
|
|
||||||
onLoadListener:{
|
|
||||||
onLoadSuccess:()=>{
|
|
||||||
// 预加载成功,删除成功请求
|
|
||||||
this.requestList.remove(index)
|
|
||||||
},
|
|
||||||
onLoadFailed:()=>{
|
|
||||||
// 移除失败请求
|
|
||||||
this.requestList.remove(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
this.requestList.set(index,request)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 取消请求处理
|
|
||||||
cancel(index: number) {
|
|
||||||
if(this.requestList.hasKey(index)) {
|
|
||||||
// 返回MAP对象指定元素
|
|
||||||
const request = this.requestList.get(index)
|
|
||||||
// 取消请求
|
|
||||||
ImageKnife.getInstance().cancel(request)
|
|
||||||
// 移除被取消的请求对象
|
|
||||||
this.requestList.remove(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,146 +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 './DataSourcePrefetching'
|
|
||||||
|
|
||||||
export class PageViewModel {
|
|
||||||
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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/5/v3/tv8Vqf9hQrKpozGeZWg2mw/VEICB-bmQYi0Iv6TGADbhw.jpg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
albumUrl: 'https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/30/v3/4v1Ot5BRR6OFVQ9MGn9Xxg/xrPgRn0LS1ep-r7ewIuwiw.jpg'
|
|
||||||
},
|
|
||||||
]
|
|
||||||
static getItems() {
|
|
||||||
return PageViewModel.dataArray
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,11 +5,8 @@
|
||||||
"description": "$string:module_desc",
|
"description": "$string:module_desc",
|
||||||
"mainElement": "EntryAbility",
|
"mainElement": "EntryAbility",
|
||||||
"deviceTypes": [
|
"deviceTypes": [
|
||||||
"default",
|
"phone",
|
||||||
"tablet",
|
"tablet",
|
||||||
"tv",
|
|
||||||
"wearable",
|
|
||||||
"car",
|
|
||||||
"2in1"
|
"2in1"
|
||||||
],
|
],
|
||||||
"deliveryWithInstall": true,
|
"deliveryWithInstall": true,
|
||||||
|
@ -48,7 +45,18 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ohos.permission.GET_NETWORK_INFO",
|
"name": "ohos.permission.MEDIA_LOCATION",
|
||||||
|
"reason":"$string:app_permission_MEDIA_LOCATION",
|
||||||
|
"usedScene": {
|
||||||
|
"abilities": [
|
||||||
|
"EntryAbility"
|
||||||
|
],
|
||||||
|
"when": "always"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ohos.permission.READ_MEDIA",
|
||||||
|
"reason": "$string:app_permission_MEDIA_LOCATION",
|
||||||
"usedScene": {
|
"usedScene": {
|
||||||
"abilities": [
|
"abilities": [
|
||||||
"EntryAbility"
|
"EntryAbility"
|
||||||
|
|
|
@ -13,700 +13,12 @@
|
||||||
"value": "label"
|
"value": "label"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "app_permission_WRITE_IMAGEVIDEO",
|
"name": "app_permission_MEDIA_LOCATION",
|
||||||
"value": "获取写入媒体资源权限"
|
"value": "获取媒体图片"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "app_permission_READ_IMAGEVIDEO",
|
"name": "app_permission_READ_MEDIA",
|
||||||
"value": "获取读媒体资源权限"
|
"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_LocalImageShow",
|
|
||||||
"value": "LocalImageShow"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"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": "first frame"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Display_the_last_frame",
|
|
||||||
"value": "last frame"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"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": "local_r_file",
|
|
||||||
"value": "Local $r file"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "local_rawfile",
|
|
||||||
"value": "Local rawfile"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "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",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "image_format",
|
|
||||||
"value": "picture format:%s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "image_width",
|
|
||||||
"value": "image width:%d"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "image_height",
|
|
||||||
"value": "image height:%d"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cur_cache_limit",
|
|
||||||
"value": "%s:current cache limit:%fM"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cur_cache_image_num",
|
|
||||||
"value": "%s:current cache image number:%d"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cur_cache_size",
|
|
||||||
"value": "%s:current cache size:%fM"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "load_memory",
|
|
||||||
"value": "memory loaded picture"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "load_disk",
|
|
||||||
"value": "disk cache loads images"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_cur_memory_limit",
|
|
||||||
"value": "gets the current memory cache upper limit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_img_number_of_cache",
|
|
||||||
"value": "gets the number of images cached in memory"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_cur_memory_size",
|
|
||||||
"value": "gets the size of the current cache"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_cur_disk_limit",
|
|
||||||
"value": "Gets the current disk cache upper limit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_img_number_of_disk",
|
|
||||||
"value": "gets the number of images cached on disk"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_cur_disk_size",
|
|
||||||
"value": "gets the size of the current disk"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "select_color_btn",
|
|
||||||
"value": "click to select the color you want to change"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "click_img_to_change_color",
|
|
||||||
"value": "click on the image to change the image color"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_non_svg_color",
|
|
||||||
"value": "test non-SVG images for color change"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_svg_color",
|
|
||||||
"value": "Test svg picture color change"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "red",
|
|
||||||
"value": "red"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "yellow",
|
|
||||||
"value": "yellow"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "green",
|
|
||||||
"value": "green"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "blue",
|
|
||||||
"value": "blue"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "master_image",
|
|
||||||
"value": "master image:"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "rm_component_of_net",
|
|
||||||
"value": "remove Component - Network load picture"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "rm_component_of_local",
|
|
||||||
"value": "remove Component - Local resource picture"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "component_display",
|
|
||||||
"value": "recovery component display"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "onLoadCancel_reason",
|
|
||||||
"value": "onLoadCancel callback reason:%s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_cache_btn",
|
|
||||||
"value": "test data for in cache"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_change_color_btn",
|
|
||||||
"value": "test change color for image"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_cancel_callback_btn",
|
|
||||||
"value": "test callback of cancel"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "memory",
|
|
||||||
"value": "Memory"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "disk",
|
|
||||||
"value": "Disk"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Customize_RCP_network",
|
|
||||||
"value": "Customize RCP network request"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "request_concurrency",
|
|
||||||
"value": "Set request concurrency"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_callback",
|
|
||||||
"value": "test callback data of load pic"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gif",
|
|
||||||
"value": "gif"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "local_pic",
|
|
||||||
"value": "local picture"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "share_pic",
|
|
||||||
"value": "share picture"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "net_load_failed",
|
|
||||||
"value": "netWork load failed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "local_load_failed",
|
|
||||||
"value": "local load failed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "share_load_failed",
|
|
||||||
"value": "shared load failed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "list_pic",
|
|
||||||
"value": "load picture list"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "img_url",
|
|
||||||
"value": "url of the service setting:%s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "img_format",
|
|
||||||
"value": "picture format:%s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "img_master_size",
|
|
||||||
"value": "the original width and height of the picture-w:%d ,h:%d, size:%d"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "componentWH",
|
|
||||||
"value": "component width and height-w:%d ,h:%d "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "img_frame",
|
|
||||||
"value": "the frames of the animator:%d "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "img_content_size",
|
|
||||||
"value": "decoded width and height size of image:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "err_msg",
|
|
||||||
"value": "error message:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "err_phase",
|
|
||||||
"value": "error phase:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "err_code",
|
|
||||||
"value": "error code:%d "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "http_code",
|
|
||||||
"value": "http code:%d "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "req_start_time",
|
|
||||||
"value": "request start time:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "req_end_time",
|
|
||||||
"value": "request end time:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "req_cancel_time",
|
|
||||||
"value": "request cancel time:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "memory_start_time",
|
|
||||||
"value": "start checking the memory cache point in time:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "memory_end_time",
|
|
||||||
"value": "end Check the memory cache time point:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "disk_start_time",
|
|
||||||
"value": "start checking the disk cache point in time:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "disk_end_time",
|
|
||||||
"value": "end Check the disk cache time point:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "net_start_time",
|
|
||||||
"value": "start time of the network request:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "net_end_time",
|
|
||||||
"value": "end time of the network request:%s:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "decode_start_time",
|
|
||||||
"value": "decoding start time point:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "decode_end_time",
|
|
||||||
"value": "decoding end time point:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "request_data_from",
|
|
||||||
"value": "request from:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Image_Downsampling_Functionality",
|
|
||||||
"value": "Downsampling function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Sampling_pecification",
|
|
||||||
"value": "Downsampling specification"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Unreal_samples",
|
|
||||||
"value": "Unsampled size"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "After_the_sampling",
|
|
||||||
"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°"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
Before Width: | Height: | Size: 3.4 KiB |
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
||||||
<title>svg细图标</title>
|
|
||||||
<g id="细图标" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
||||||
<g id="dot_radiowaves_left_and_right" fill="#000000" fill-rule="nonzero">
|
|
||||||
<rect id="矩形" opacity="0" x="0" y="0" width="24" height="24"></rect>
|
|
||||||
<g id="编组" transform="translate(0.000000, 3.000000)" fill-opacity="0.90196079">
|
|
||||||
<path d="M12,7.01 C11.44,7.01 10.9633333,7.20666667 10.57,7.6 C10.1766667,7.98666667 9.98,8.45333333 9.98,9 C9.98,9.54666667 10.18,10.02 10.58,10.42 C10.98,10.82 11.4533333,11.02 12,11.02 C12.5466667,11.02 13.0133333,10.8233333 13.4,10.43 C13.7933333,10.0366667 13.99,9.56 13.99,9 C13.99,8.44 13.8,7.96666667 13.42,7.58 C13.0333333,7.2 12.56,7.01 12,7.01 Z" id="路径"></path>
|
|
||||||
<path d="M5.23,9 C5.23,10.1533333 5.50666667,11.2333333 6.06,12.24 C6.61333333,13.2466667 7.37666667,14.0633333 8.35,14.69 C8.53,14.8033333 8.72,14.8333333 8.92,14.78 C9.12,14.7333333 9.27333333,14.6233333 9.38,14.45 C9.49333333,14.27 9.52666667,14.08 9.48,13.88 C9.43333333,13.68 9.33,13.5266667 9.17,13.42 C8.41666667,12.92 7.82333333,12.2833333 7.39,11.51 C6.95666667,10.73 6.74,9.89333333 6.74,9 C6.74,8.10666667 6.95333333,7.26666667 7.38,6.48 C7.80666667,5.69333333 8.40333333,5.05333333 9.17,4.56 C9.34333333,4.44666667 9.45,4.29 9.49,4.09 C9.53,3.89 9.49333333,3.70333333 9.38,3.53 C9.27333333,3.35 9.12,3.23666667 8.92,3.19 C8.72,3.14333333 8.53,3.18333333 8.35,3.31 C7.37666667,3.93666667 6.61333333,4.75 6.06,5.75 C5.50666667,6.75 5.23,7.83333333 5.23,9 Z M14.59,14.45 C14.7033333,14.6233333 14.8533333,14.7333333 15.04,14.78 C15.22,14.8333333 15.4233333,14.8033333 15.65,14.69 C16.29,14.27 16.84,13.7666667 17.3,13.18 C17.7666667,12.5866667 18.1233333,11.9333333 18.37,11.22 C18.6166667,10.5066667 18.74,9.76666667 18.74,9 C18.74,7.83333333 18.47,6.75 17.93,5.75 C17.3833333,4.75 16.6233333,3.93666667 15.65,3.31 C15.47,3.18333333 15.2766667,3.14333333 15.07,3.19 C14.8633333,3.23666667 14.7033333,3.35 14.59,3.53 C14.4766667,3.70333333 14.44,3.88666667 14.48,4.08 C14.52,4.27333333 14.63,4.42666667 14.81,4.54 L14.83,4.56 C15.5833333,5.05333333 16.1766667,5.69333333 16.61,6.48 C17.0433333,7.26666667 17.26,8.10666667 17.26,9 C17.26,9.59333333 17.1633333,10.1666667 16.97,10.72 C16.7766667,11.2666667 16.4966667,11.7733333 16.13,12.24 C15.7633333,12.7066667 15.33,13.1 14.83,13.42 C14.6566667,13.5266667 14.5466667,13.68 14.5,13.88 C14.4466667,14.08 14.4766667,14.27 14.59,14.45 Z" id="形状"></path>
|
|
||||||
<path d="M0.77,9 C0.77,10.6666667 1.12,12.2466667 1.82,13.74 C2.52666667,15.2333333 3.51333333,16.5166667 4.78,17.59 C4.94,17.7166667 5.12,17.7733333 5.32,17.76 C5.52,17.7466667 5.69,17.6666667 5.83,17.52 C5.95666667,17.36 6.01333333,17.1766667 6,16.97 C5.98666667,16.7633333 5.9,16.5866667 5.74,16.44 C4.63333333,15.5133333 3.77666667,14.4 3.17,13.1 C2.56333333,11.8066667 2.26,10.44 2.26,9 C2.26,7.56 2.56333333,6.18666667 3.17,4.88 C3.77666667,3.58 4.64,2.46666667 5.76,1.54 C5.90666667,1.39333333 5.99,1.21666667 6.01,1.01 C6.03666667,0.803333333 5.97666667,0.626666667 5.83,0.48 C5.70333333,0.32 5.53666667,0.233333333 5.33,0.22 C5.12333333,0.2 4.94,0.253333333 4.78,0.38 C3.51333333,1.45333333 2.52666667,2.74333333 1.82,4.25 C1.12,5.75 0.77,7.33333333 0.77,9 Z M18.17,17.5 C18.2966667,17.66 18.4633333,17.7466667 18.67,17.76 C18.8766667,17.7733333 19.06,17.7166667 19.22,17.59 C20.0733333,16.89 20.8,16.0833333 21.4,15.17 C22,14.2566667 22.4533333,13.2766667 22.76,12.23 C23.0733333,11.1833333 23.23,10.1066667 23.23,9 C23.23,7.89333333 23.0733333,6.81666667 22.76,5.77 C22.4533333,4.72333333 22,3.74 21.4,2.82 C20.8,1.9 20.0733333,1.08666667 19.22,0.38 C19.06,0.253333333 18.8766667,0.2 18.67,0.22 C18.4633333,0.233333333 18.2966667,0.32 18.17,0.48 C18.0233333,0.64 17.96,0.823333333 17.98,1.03 C17.9933333,1.23666667 18.08,1.40666667 18.24,1.54 C18.9733333,2.14666667 19.6,2.85 20.12,3.65 C20.64,4.45 21.0366667,5.3 21.31,6.2 C21.5833333,7.10666667 21.72,8.04 21.72,9 C21.72,9.96 21.5833333,10.8933333 21.31,11.8 C21.0366667,12.7 20.6466667,13.5466667 20.14,14.34 C19.6266667,15.1333333 19,15.8333333 18.26,16.44 C18.1,16.5666667 18.0133333,16.7333333 18,16.94 C17.9866667,17.1533333 18.0433333,17.34 18.17,17.5 Z" id="形状"></path>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 922 KiB |
|
@ -3,6 +3,7 @@
|
||||||
"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",
|
||||||
|
@ -17,32 +18,6 @@
|
||||||
"pages/LoadStatePage",
|
"pages/LoadStatePage",
|
||||||
"pages/TestHspPreLoadImage",
|
"pages/TestHspPreLoadImage",
|
||||||
"pages/TestRemoveCache",
|
"pages/TestRemoveCache",
|
||||||
"pages/dataShareUriLoadPage",
|
"pages/dataShareUriLoadPage"
|
||||||
"pages/TestCommonImage",
|
|
||||||
"pages/ImageAnimatorPage",
|
|
||||||
"pages/TestSetCustomImagePage",
|
|
||||||
"pages/TestErrorHolderPage",
|
|
||||||
"pages/TestTaskResourcePage",
|
|
||||||
"pages/ImageKnifeReload",
|
|
||||||
"pages/LazyForEachCount",
|
|
||||||
"pages/LazyForEachCache",
|
|
||||||
"pages/PrefetchAndCacheCount",
|
|
||||||
"pages/PrefetchAndPreload",
|
|
||||||
"pages/TestCacheDataPage",
|
|
||||||
"pages/TestChangeColorPage",
|
|
||||||
"pages/TestLoadCancelListenerPage",
|
|
||||||
"pages/SetMaxRequestPage",
|
|
||||||
"pages/MaxRequest1",
|
|
||||||
"pages/MaxRequest2",
|
|
||||||
"pages/MaxRequest3",
|
|
||||||
"pages/TestImageKnifeCallbackPage",
|
|
||||||
"pages/TestListImageKnifeCallbackPage",
|
|
||||||
"pages/DownSamplePage",
|
|
||||||
"pages/AutoImageFit",
|
|
||||||
"pages/SingleImageCallBack",
|
|
||||||
"pages/MultipleImageCallBack",
|
|
||||||
"pages/LocalImage",
|
|
||||||
"pages/ErrorMessageDownload",
|
|
||||||
"pages/TestImageExif"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"string": [
|
||||||
|
{
|
||||||
|
"name": "module_desc",
|
||||||
|
"value": "module description"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EntryAbility_desc",
|
||||||
|
"value": "description"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EntryAbility_label",
|
||||||
|
"value": "label"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "app_permission_MEDIA_LOCATION",
|
||||||
|
"value": "获取媒体图片"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "app_permission_READ_MEDIA",
|
||||||
|
"value": "读媒体图片"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB |
|
@ -13,692 +13,12 @@
|
||||||
"value": "label"
|
"value": "label"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "app_permission_WRITE_IMAGEVIDEO",
|
"name": "app_permission_MEDIA_LOCATION",
|
||||||
"value": "获取写入媒体资源权限"
|
"value": "获取媒体图片"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "app_permission_READ_IMAGEVIDEO",
|
"name": "app_permission_READ_MEDIA",
|
||||||
"value": "获取读媒体资源权限"
|
"value": "读媒体图片"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_ImageAnimator",
|
|
||||||
"value": "测试ImageAnimator组件"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_multiple_images",
|
|
||||||
"value": "测试加载多张相同图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_Task_error",
|
|
||||||
"value": "测试占位图Task报错"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_HSP",
|
|
||||||
"value": "测试HSP场景预加载"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_SingleImage",
|
|
||||||
"value": "单个图片使用"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_LocalImageShow",
|
|
||||||
"value": "本地图片显示"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_custom_download",
|
|
||||||
"value": "全局自定义下载"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Multiple_images",
|
|
||||||
"value": "多图"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Display_long_image",
|
|
||||||
"value": "长图显示"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Image_scaling",
|
|
||||||
"value": "缩放图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Message_list",
|
|
||||||
"value": "消息列表"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Custom_cache_key",
|
|
||||||
"value": "自定义缓存key"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Preloading_images_to_cache",
|
|
||||||
"value": "预加载图片到文件缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Retrieve_image_display_from_cache",
|
|
||||||
"value": "从缓存获取图片显示"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_single_request_header",
|
|
||||||
"value": "测试单个请求头"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_write_cache_strategy",
|
|
||||||
"value": "测试写入缓存策略"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Image_Transformation",
|
|
||||||
"value": "图片变换"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Different_ObjectFit",
|
|
||||||
"value": "不同的ObjectFit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_image_loading_success_or_failure_events",
|
|
||||||
"value": "测试图片加载成功/失败事件"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_removing_image_cache_interface",
|
|
||||||
"value": "测试移除图片缓存接口"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_error_image_display",
|
|
||||||
"value": "测试错误图显示"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Display_the_first_frame",
|
|
||||||
"value": "第一帧"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Display_the_last_frame",
|
|
||||||
"value": "最后一帧"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Play",
|
|
||||||
"value": "播放"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Pause",
|
|
||||||
"value": "暂停"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Stop",
|
|
||||||
"value": "停止"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Infinite_loop",
|
|
||||||
"value": "无限循环"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Play_once",
|
|
||||||
"value": "播放一次"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Play_twice",
|
|
||||||
"value": "播放两次"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Local_SVG",
|
|
||||||
"value": "本地资源SVG图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "local_r_file",
|
|
||||||
"value": "本地$r文件"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "local_rawfile",
|
|
||||||
"value": "本地rawfile文件"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Under_context_file",
|
|
||||||
"value": "本地沙箱路径文件"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "local_other_module",
|
|
||||||
"value": "本地其他模块文件"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Network_images",
|
|
||||||
"value": "网络图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Custom_network_download",
|
|
||||||
"value": "自定义下载"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "PixelMap_loads_images",
|
|
||||||
"value": "PixelMap加载图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Enlarge",
|
|
||||||
"value": "放大"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Reduce",
|
|
||||||
"value": "缩小"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Click_on_add",
|
|
||||||
"value": "点击尺寸加50"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Click_on_reduce",
|
|
||||||
"value": "点击尺寸减50"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "The_key_fixed_1",
|
|
||||||
"value": "key固定为 1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "The_key_changes_timestamp",
|
|
||||||
"value": "key每次变化:时间戳"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Load",
|
|
||||||
"value": "加载"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Preloading_images_to_file_cache_using_URL",
|
|
||||||
"value": "url预加载图片到文件缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Preloading_images_to_file_cache_using_option",
|
|
||||||
"value": "option预加载图片到文件缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Load_image_offline_after_preloading",
|
|
||||||
"value": "加载图片(预加载后可断网加载)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Preloading_GIF",
|
|
||||||
"value": "预加载gif图"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Retrieve_GIF_from_memory",
|
|
||||||
"value": "内存缓存获取gif"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Retrieve_GIF_from_disk",
|
|
||||||
"value": "文件缓存获取gif"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Preloading_static_images",
|
|
||||||
"value": "预加载静态图"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Retrieve_images_from_memory",
|
|
||||||
"value": "内存缓存获取"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Retrieve_images_from_disk",
|
|
||||||
"value": "文件缓存获取"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Write_memory_and_file",
|
|
||||||
"value": "写入内存文件缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Write_memory",
|
|
||||||
"value": "写入内存缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Write_file",
|
|
||||||
"value": "写入文件缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Main_image_Fill",
|
|
||||||
"value": "主图Fill拉伸填充"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Maintain_proportion_filling",
|
|
||||||
"value": "占位图Contain保持比例填充"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Error_graph_None",
|
|
||||||
"value": "错误图None不变化"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Test_failure_success",
|
|
||||||
"value": "测试失败/成功场景"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Custom_download_failed",
|
|
||||||
"value": "自定义下载失败"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Retrieve_media_gallery",
|
|
||||||
"value": "获取媒体图库的uri用ImageKnife展示"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Click_load_Uri",
|
|
||||||
"value": "点击加载Uri并展示"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Delete_all_caches",
|
|
||||||
"value": "删除全部缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Delete_all_memory_caches",
|
|
||||||
"value": "删除全部内存缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Delete_all_file_caches",
|
|
||||||
"value": "删除全部文件缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Delete_all_custom_memory_caches",
|
|
||||||
"value": "删除自定义内存缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Delete_all_custom_file_caches",
|
|
||||||
"value": "删除自定义文件缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Blur_effect",
|
|
||||||
"value": "模糊效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Highlighting_effect",
|
|
||||||
"value": "高亮效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Ashing_effect",
|
|
||||||
"value": "灰化效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Inverse_effect",
|
|
||||||
"value": "反转效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Animation_filter_effect",
|
|
||||||
"value": "动画滤镜效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Crop_circular_effect",
|
|
||||||
"value": "裁剪圆形效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Crop_circular_with_border_effect",
|
|
||||||
"value": "裁剪圆形带边框效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Contrast_effect",
|
|
||||||
"value": "对比度效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Black_ink_filtering_effect",
|
|
||||||
"value": "乌墨色滤波效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Rotate",
|
|
||||||
"value": "旋转效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Corners",
|
|
||||||
"value": "圆角效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Kuwahara_Filter_effect",
|
|
||||||
"value": "桑原滤波效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Pixelated_Filter_effect",
|
|
||||||
"value": "像素化滤波效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Sketch_Filter_effect",
|
|
||||||
"value": "素描滤波效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Distortion_Filter_effect",
|
|
||||||
"value": "扭曲滤波效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Decorative_Filter_effect",
|
|
||||||
"value": "装饰滤波效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Square_cutting_effect",
|
|
||||||
"value": "正方形裁剪效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Top_cutting_effect",
|
|
||||||
"value": "上方裁剪效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Middle_cutting_effect",
|
|
||||||
"value": "中间裁剪效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Bottom_cutting_effect",
|
|
||||||
"value": "底下裁剪效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Mask_effect",
|
|
||||||
"value": "遮罩效果"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "TIPS",
|
|
||||||
"value": "测试失败场景请先关闭网络,并保证本地没有此网络图片的缓存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Network_reload",
|
|
||||||
"value": "网络恢复reload"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "preloading_prefetch",
|
|
||||||
"value": "动态预加载prefetch"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "image_format",
|
|
||||||
"value": "图片格式:%s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "image_width",
|
|
||||||
"value": "图片宽度:%d"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "image_height",
|
|
||||||
"value": "图片高度:%d"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cur_cache_limit",
|
|
||||||
"value": "%s:当前缓存上限:%fM"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cur_cache_image_num",
|
|
||||||
"value": "%s:当前缓存图片数量:%d"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cur_cache_size",
|
|
||||||
"value": "%s:当前缓存的大小:%fM"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "load_memory",
|
|
||||||
"value": "内存加载图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "load_disk",
|
|
||||||
"value": "磁盘缓存加载图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_cur_memory_limit",
|
|
||||||
"value": "获取当前内存缓存上限"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_img_number_of_cache",
|
|
||||||
"value": "获取当前内存缓存图片数量"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_cur_memory_size",
|
|
||||||
"value": "获取当前缓存的大小"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_cur_disk_limit",
|
|
||||||
"value": "获取当前磁盘缓存上限"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_img_number_of_disk",
|
|
||||||
"value": "获取当前磁盘缓存图片数量"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_cur_disk_size",
|
|
||||||
"value": "获取当前磁盘的大小"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "select_color_btn",
|
|
||||||
"value": "点击选择要更改的颜色"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "click_img_to_change_color",
|
|
||||||
"value": "点击图片更改图片颜色"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_non_svg_color",
|
|
||||||
"value": "测试非svg图片变色"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_svg_color",
|
|
||||||
"value": "测试svg图片变色"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "red",
|
|
||||||
"value": "红色"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "yellow",
|
|
||||||
"value": "黄色"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "green",
|
|
||||||
"value": "绿色"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "blue",
|
|
||||||
"value": "蓝色"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "master_image",
|
|
||||||
"value": "原图:"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "rm_component_of_net",
|
|
||||||
"value": "移除组件-网络加载图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "rm_component_of_local",
|
|
||||||
"value": "移除组件-本地资源图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "component_display",
|
|
||||||
"value": "恢复组件显示"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "onLoadCancel_reason",
|
|
||||||
"value": "onLoadCancel回调原因:%s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_cache_btn",
|
|
||||||
"value": "测试缓存数据"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_change_color_btn",
|
|
||||||
"value": "测试颜色变换"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_cancel_callback_btn",
|
|
||||||
"value": "测试加载取消回调接口"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "memory",
|
|
||||||
"value": "内存"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "disk",
|
|
||||||
"value": "磁盘"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Customize_RCP_network",
|
|
||||||
"value": "自定义rcp网络请求"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "request_concurrency",
|
|
||||||
"value": "设置请求并发度"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test_callback",
|
|
||||||
"value": "测试图片加载回调数据"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gif",
|
|
||||||
"value": "gif"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "local_pic",
|
|
||||||
"value": "本地图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "share_pic",
|
|
||||||
"value": "共享图片"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "net_load_failed",
|
|
||||||
"value": "网络加载失败"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "local_load_failed",
|
|
||||||
"value": "本地加载失败"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "share_load_failed",
|
|
||||||
"value": "共享图片加载失败"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "list_pic",
|
|
||||||
"value": "加载图片列表"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "img_url",
|
|
||||||
"value": "业务设置的url:%s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "img_format",
|
|
||||||
"value": "图片的格式:%s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "img_master_size",
|
|
||||||
"value": "图片的原始宽高大小-宽:%d ,高:%d, 大小:%d"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "componentWH",
|
|
||||||
"value": "component的宽高-宽:%d ,高:%d "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "img_frame",
|
|
||||||
"value": "动图帧数:%d "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "img_content_size",
|
|
||||||
"value": "图片解码后宽高大小:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "err_msg",
|
|
||||||
"value": "错误信息:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "err_phase",
|
|
||||||
"value": "发生错误阶段:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "err_code",
|
|
||||||
"value": "错误code:%d "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "http_code",
|
|
||||||
"value": "网络请求code:%d "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "req_start_time",
|
|
||||||
"value": "请求开始时间:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "req_end_time",
|
|
||||||
"value": "请求结束时间:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "req_cancel_time",
|
|
||||||
"value": "请求取消时间:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "memory_start_time",
|
|
||||||
"value": "开始检查内存缓存时间点:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "memory_end_time",
|
|
||||||
"value": "结束检查内存缓存时间点:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "disk_start_time",
|
|
||||||
"value": "开始检查磁盘缓存时间点:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "disk_end_time",
|
|
||||||
"value": "结束检查磁盘缓存时间点:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "net_start_time",
|
|
||||||
"value": "网络请求开始时间点:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "net_end_time",
|
|
||||||
"value": "网络请求结束时间点:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "decode_start_time",
|
|
||||||
"value": "解码开始时间点:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "decode_end_time",
|
|
||||||
"value": "解码结束时间点:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "request_data_from",
|
|
||||||
"value": "请求数据来自于:%s "
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Image_Downsampling_Functionality",
|
|
||||||
"value": "降采样功能"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Sampling_pecification",
|
|
||||||
"value": "降采样规格"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Unreal_samples",
|
|
||||||
"value": "未降采样大小"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "After_the_sampling",
|
|
||||||
"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°"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -13,9 +13,9 @@
|
||||||
* 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';
|
import { ImageKnifeOption, ImageKnifeRequest } from '@ohos/imageknife/Index';
|
||||||
import { DefaultJobQueue } from '@ohos/imageknife/src/main/ets/queue/DefaultJobQueue';
|
import { DefaultJobQueue } from '@ohos/imageknife/src/main/ets/utils/DefaultJobQueue';
|
||||||
import { IJobQueue } from '@ohos/imageknife/src/main/ets/queue/IJobQueue';
|
import { IJobQueue } from '@ohos/imageknife/src/main/ets/utils/IJobQueue';
|
||||||
import taskpool from '@ohos.taskpool';
|
import taskpool from '@ohos.taskpool';
|
||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
|
|
||||||
|
@ -55,12 +55,12 @@ export default function DefaultJobQueueTest() {
|
||||||
|
|
||||||
expect(job.getQueueLength()).assertEqual(7)
|
expect(job.getQueueLength()).assertEqual(7)
|
||||||
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("high1")
|
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("high1")
|
||||||
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("medium1")
|
|
||||||
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("medium2")
|
|
||||||
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("medium3")
|
|
||||||
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("medium4")
|
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("medium4")
|
||||||
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("low1")
|
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("medium3")
|
||||||
|
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("medium2")
|
||||||
|
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("medium1")
|
||||||
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("low2")
|
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("low2")
|
||||||
|
expect(job.pop()!.imageKnifeOption.loadSrc).assertEqual("low1")
|
||||||
expect(job.pop()).assertEqual(undefined)
|
expect(job.pop()).assertEqual(undefined)
|
||||||
expect(job.getQueueLength()).assertEqual(0)
|
expect(job.getQueueLength()).assertEqual(0)
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
|
||||||
import Constants from '../../../main/ets/common/Constants';
|
import Constants from '../../../main/ets/common/Constants';
|
||||||
import taskpool from '@ohos.taskpool';
|
import taskpool from '@ohos.taskpool';
|
||||||
import { GlobalContext } from '../../../main/ets/common/GlobalContext';
|
import { GlobalContext } from '../../../main/ets/common/GlobalContext';
|
||||||
import { FileCache } from '@ohos/imageknife/src/main/ets/cache/FileCache';
|
import { FileCache } from '@ohos/imageknife/src/main/ets/utils/FileCache';
|
||||||
import { IEngineKey, ImageKnifeOption } from '@ohos/imageknife';
|
|
||||||
import { DefaultEngineKey } from '@ohos/imageknife/src/main/ets/key/DefaultEngineKey';
|
|
||||||
|
|
||||||
|
|
||||||
export default function FileLruCacheTest() {
|
export default function FileLruCacheTest() {
|
||||||
|
@ -151,15 +149,6 @@ export default function FileLruCacheTest() {
|
||||||
fileCache.put(JSON.stringify("xxxxx"),buf)
|
fileCache.put(JSON.stringify("xxxxx"),buf)
|
||||||
expect(fileCache.get(JSON.stringify("xxxxx"))?.byteLength).assertEqual(1024 * 1024)
|
expect(fileCache.get(JSON.stringify("xxxxx"))?.byteLength).assertEqual(1024 * 1024)
|
||||||
});
|
});
|
||||||
it('fileCacheEngineKey', 0, () => {
|
|
||||||
let engineKey: IEngineKey = new DefaultEngineKey()
|
|
||||||
let imageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc:"abc"
|
|
||||||
}
|
|
||||||
let imageKey = engineKey.generateFileKey(imageKnifeOption.loadSrc,"")
|
|
||||||
let imageAnimatorKey = engineKey.generateFileKey(imageKnifeOption.loadSrc,"",true)
|
|
||||||
expect(imageKey == imageAnimatorKey).assertFalse()
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,ImageKnifeData } from "@ohos/imageknife"
|
import { ImageKnifeOption } from "@ohos/imageknife"
|
||||||
|
|
||||||
export default function ImageKnifeOptionTest() {
|
export default function ImageKnifeOptionTest() {
|
||||||
describe('ImageKnifeOptionTest',() => {
|
describe('ImageKnifeOptionTest',() => {
|
||||||
|
@ -39,29 +39,23 @@ export default function ImageKnifeOptionTest() {
|
||||||
it('onLoadListener', 0, () => {
|
it('onLoadListener', 0, () => {
|
||||||
let a = 'abc';
|
let a = 'abc';
|
||||||
let b: string = '';
|
let b: string = '';
|
||||||
let imageData:ImageKnifeData = {
|
let ImageKnifeOption: ImageKnifeOption = {
|
||||||
source: "",
|
|
||||||
imageWidth: 0,
|
|
||||||
imageHeight: 0,
|
|
||||||
}
|
|
||||||
let imageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc: $r("app.media.rabbit"),
|
loadSrc: $r("app.media.rabbit"),
|
||||||
onLoadListener: {
|
onLoadListener: {
|
||||||
onLoadFailed: (err) => {
|
onLoadFailed: (err) => {
|
||||||
console.error("Load Failed Reason: " + err);
|
console.error("Load Failed Reason: " + err);
|
||||||
},
|
},
|
||||||
onLoadSuccess: (data,imageknifeData) => {
|
onLoadSuccess: (data) => {
|
||||||
if(typeof data == 'string') {
|
if(typeof data == 'string') {
|
||||||
return b = data;
|
return b = data;
|
||||||
}
|
}
|
||||||
imageData = imageknifeData
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
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);
|
||||||
imageKnifeOption.onLoadListener.onLoadFailed(a);
|
ImageKnifeOption.onLoadListener.onLoadFailed(a);
|
||||||
}
|
}
|
||||||
expect(a).assertEqual(b);
|
expect(a).assertEqual(b);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,69 +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 { 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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -14,13 +14,10 @@
|
||||||
*/
|
*/
|
||||||
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';
|
||||||
import imageFormatAndSize from './imageFormatAndSize.test'
|
|
||||||
import loadCallBackData from './loadCallBackData.test'
|
|
||||||
import SamplingTest from './SamplingTest.test';
|
|
||||||
|
|
||||||
export default function testsuite() {
|
export default function testsuite() {
|
||||||
MemoryLruCacheTest();
|
MemoryLruCacheTest();
|
||||||
|
@ -29,7 +26,4 @@ export default function testsuite() {
|
||||||
ImageKnifeOptionTest();
|
ImageKnifeOptionTest();
|
||||||
ImageKnifeTest();
|
ImageKnifeTest();
|
||||||
Transform();
|
Transform();
|
||||||
SamplingTest()
|
|
||||||
imageFormatAndSize();
|
|
||||||
loadCallBackData();
|
|
||||||
}
|
}
|
|
@ -17,10 +17,8 @@ import image from '@ohos.multimedia.image';
|
||||||
|
|
||||||
|
|
||||||
import Constants from '../../../main/ets/common/Constants';
|
import Constants from '../../../main/ets/common/Constants';
|
||||||
import { MemoryLruCache } from '@ohos/imageknife/src/main/ets/cache/MemoryLruCache';
|
import { MemoryLruCache } from '@ohos/imageknife/src/main/ets/utils/MemoryLruCache';
|
||||||
import { ImageKnifeData } from '@ohos/imageknife/src/main/ets/model/ImageKnifeData';
|
import { ImageKnifeData } from '@ohos/imageknife/src/main/ets/model/ImageKnifeData';
|
||||||
import { IEngineKey, ImageKnifeOption,ImageKnifeRequestSource } from '@ohos/imageknife';
|
|
||||||
import { DefaultEngineKey } from '@ohos/imageknife/src/main/ets/key/DefaultEngineKey';
|
|
||||||
|
|
||||||
|
|
||||||
export default function MemoryLruCacheTest() {
|
export default function MemoryLruCacheTest() {
|
||||||
|
@ -120,16 +118,6 @@ export default function MemoryLruCacheTest() {
|
||||||
expect(memoryCache.get("ccc")).assertEqual(data)
|
expect(memoryCache.get("ccc")).assertEqual(data)
|
||||||
});
|
});
|
||||||
|
|
||||||
it('memoryCacheEngineKey', 0, () => {
|
|
||||||
let engineKey: IEngineKey = new DefaultEngineKey()
|
|
||||||
let imageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc:"abc"
|
|
||||||
}
|
|
||||||
let imageKey = engineKey.generateMemoryKey(imageKnifeOption.loadSrc,ImageKnifeRequestSource.SRC,imageKnifeOption)
|
|
||||||
let imageAnimatorKey = engineKey.generateMemoryKey(imageKnifeOption.loadSrc,ImageKnifeRequestSource.SRC,imageKnifeOption,true)
|
|
||||||
expect(imageKey == imageAnimatorKey).assertFalse()
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,84 +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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
|
|
||||||
import { Downsampler } from '@ohos/imageknife/src/main/ets/downsampling/Downsampler'
|
|
||||||
import { DownsampleStrategy } from '@ohos/imageknife'
|
|
||||||
|
|
||||||
export default function SamplingTest() {
|
|
||||||
describe('SamplingTest', () => {
|
|
||||||
// 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('AT_MOST', 0, () => {
|
|
||||||
let reqSize: Size =
|
|
||||||
new Downsampler().calculateScaling('jpg', 1024, 1024, 200,
|
|
||||||
200, DownsampleStrategy.AT_MOST)
|
|
||||||
let req = (reqSize.width < 1024 && reqSize.height < 1024)
|
|
||||||
expect(req).assertEqual(true);
|
|
||||||
})
|
|
||||||
it('FIT_CENTER_MEMORY', 1, () => {
|
|
||||||
let reqSize: Size =
|
|
||||||
new Downsampler().calculateScaling('jpg', 1024, 1024, 200,
|
|
||||||
200, DownsampleStrategy.FIT_CENTER_MEMORY)
|
|
||||||
let req = (reqSize.width < 1024 && reqSize.height < 1024)
|
|
||||||
expect(req).assertEqual(true);
|
|
||||||
})
|
|
||||||
it('FIT_CENTER_QUALITY', 2, () => {
|
|
||||||
let reqSize: Size =
|
|
||||||
new Downsampler().calculateScaling('jpg', 1024, 1024, 200,
|
|
||||||
200, DownsampleStrategy.FIT_CENTER_QUALITY)
|
|
||||||
let req = (reqSize.width < 1024 && reqSize.height < 1024)
|
|
||||||
expect(req).assertEqual(true);
|
|
||||||
})
|
|
||||||
it('CENTER_OUTSIDE_MEMORY', 3, () => {
|
|
||||||
let reqSize: Size =
|
|
||||||
new Downsampler().calculateScaling('jpg', 1024, 1024, 200,
|
|
||||||
200, DownsampleStrategy.CENTER_INSIDE_MEMORY)
|
|
||||||
let req = (reqSize.width < 1024 && reqSize.height < 1024)
|
|
||||||
expect(req).assertEqual(true);
|
|
||||||
})
|
|
||||||
it('CENTER_OUTSIDE_QUALITY', 4, () => {
|
|
||||||
let reqSize: Size =
|
|
||||||
new Downsampler().calculateScaling('jpg', 1024, 1024, 200,
|
|
||||||
200, DownsampleStrategy.CENTER_INSIDE_QUALITY)
|
|
||||||
let req = (reqSize.width < 1024 && reqSize.height < 1024)
|
|
||||||
expect(req).assertEqual(true);
|
|
||||||
})
|
|
||||||
it('AT_LEAST', 5, () => {
|
|
||||||
let reqSize: Size =
|
|
||||||
new Downsampler().calculateScaling('jpg', 1024, 1024, 200,
|
|
||||||
200, DownsampleStrategy.AT_LEAST)
|
|
||||||
let req = (reqSize.width < 1024 && reqSize.height < 1024)
|
|
||||||
expect(req).assertEqual(true);
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -1,88 +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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
|
|
||||||
import {
|
|
||||||
ImageKnifeOption,
|
|
||||||
ImageKnife,
|
|
||||||
ImageKnifeRequest,
|
|
||||||
CacheStrategy
|
|
||||||
} from "@ohos/imageknife"
|
|
||||||
import { common } from '@kit.AbilityKit';
|
|
||||||
|
|
||||||
export default function imageFormatAndSize() {
|
|
||||||
describe('imageFormatAndSize', () => {
|
|
||||||
// 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('getImageSizeInCache', 0, async () => {
|
|
||||||
let width = 0;
|
|
||||||
let height = 0;
|
|
||||||
let imageFormat: string = "";
|
|
||||||
let url: string =
|
|
||||||
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/ed/v3/KMO4D6D2QGuVOCLX4AhOFA/ef51xAaLQuK7BsnuD9abog.jpg"
|
|
||||||
let imageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc: url,
|
|
||||||
}
|
|
||||||
await new Promise<string>((resolve, reject) => {
|
|
||||||
imageKnifeOption.onLoadListener = {
|
|
||||||
onLoadSuccess: (data, imageknifeData) => {
|
|
||||||
resolve("")
|
|
||||||
},
|
|
||||||
onLoadFailed(err) {
|
|
||||||
reject(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let request = new ImageKnifeRequest(
|
|
||||||
imageKnifeOption,
|
|
||||||
imageKnifeOption.context !== undefined ? imageKnifeOption.context : getContext() as common.UIAbilityContext,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
showPixelMap(version: number, pixelMap: PixelMap | string) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
ImageKnife.getInstance().execute(request);
|
|
||||||
})
|
|
||||||
let data = await ImageKnife.getInstance()
|
|
||||||
.getCacheImage(url, CacheStrategy.Memory);
|
|
||||||
if (data) {
|
|
||||||
width = data.imageWidth
|
|
||||||
height = data.imageHeight
|
|
||||||
imageFormat = data.type!
|
|
||||||
}
|
|
||||||
expect(width != 0).assertTrue();
|
|
||||||
expect(height != 0).assertTrue();
|
|
||||||
expect(imageFormat != "").assertTrue();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,116 +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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
|
|
||||||
import {
|
|
||||||
ImageKnifeOption,
|
|
||||||
ImageKnife,
|
|
||||||
ImageKnifeRequest,
|
|
||||||
ImageKnifeData
|
|
||||||
} from "@ohos/imageknife"
|
|
||||||
import { common } from '@kit.AbilityKit';
|
|
||||||
|
|
||||||
export default function loadCallBackData() {
|
|
||||||
describe('loadCallBackData', () => {
|
|
||||||
// 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('startAndSuccess-CallBack', 0, async () => {
|
|
||||||
let startCallBack: ImageKnifeData | undefined = undefined;
|
|
||||||
let successCallBack: ImageKnifeData | undefined = undefined;
|
|
||||||
let url: string =
|
|
||||||
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/63/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg"
|
|
||||||
let imageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc: url,
|
|
||||||
}
|
|
||||||
await new Promise<string>((resolve, reject) => {
|
|
||||||
imageKnifeOption.onLoadListener = {
|
|
||||||
onLoadStart: (data) => {
|
|
||||||
startCallBack = data?.imageKnifeData;
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageknifeData,req) => {
|
|
||||||
successCallBack = req?.imageKnifeData;
|
|
||||||
resolve("")
|
|
||||||
},
|
|
||||||
onLoadFailed(err) {
|
|
||||||
reject(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let request = new ImageKnifeRequest(
|
|
||||||
imageKnifeOption,
|
|
||||||
imageKnifeOption.context !== undefined ? imageKnifeOption.context : getContext() as common.UIAbilityContext,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
showPixelMap(version: number, pixelMap: PixelMap | string) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
ImageKnife.getInstance().execute(request);
|
|
||||||
})
|
|
||||||
expect(startCallBack != undefined).assertTrue();
|
|
||||||
expect(successCallBack != undefined).assertTrue();
|
|
||||||
});
|
|
||||||
it('failed-CallBack', 0, async () => {
|
|
||||||
let failedCallBack: ImageKnifeData | undefined = undefined;
|
|
||||||
let url: string =
|
|
||||||
"https://contentcenter-drcn.dbankcdn.cn/pub_1/DevEcoSpace_1_900_9/163/v3/qbe6NZkCQyGcITvdWoZBgg/Y-5U1z3GT_yaK8CBD3jkwg.jpg"
|
|
||||||
let imageKnifeOption: ImageKnifeOption = {
|
|
||||||
loadSrc: url,
|
|
||||||
}
|
|
||||||
await new Promise<string>((resolve, reject) => {
|
|
||||||
imageKnifeOption.onLoadListener = {
|
|
||||||
onLoadStart: (data) => {
|
|
||||||
},
|
|
||||||
onLoadSuccess: (data, imageknifeData) => {
|
|
||||||
},
|
|
||||||
onLoadFailed(res,req) {
|
|
||||||
failedCallBack = req?.imageKnifeData;
|
|
||||||
resolve(res)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let request = new ImageKnifeRequest(
|
|
||||||
imageKnifeOption,
|
|
||||||
imageKnifeOption.context !== undefined ? imageKnifeOption.context : getContext() as common.UIAbilityContext,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
showPixelMap(version: number, pixelMap: PixelMap | string) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
ImageKnife.getInstance().execute(request);
|
|
||||||
})
|
|
||||||
expect(failedCallBack != undefined).assertTrue();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -5,11 +5,8 @@
|
||||||
"description": "$string:module_test_desc",
|
"description": "$string:module_test_desc",
|
||||||
"mainElement": "TestAbility",
|
"mainElement": "TestAbility",
|
||||||
"deviceTypes": [
|
"deviceTypes": [
|
||||||
"default",
|
"phone",
|
||||||
"tablet",
|
"tablet",
|
||||||
"tv",
|
|
||||||
"wearable",
|
|
||||||
"car",
|
|
||||||
"2in1"
|
"2in1"
|
||||||
],
|
],
|
||||||
"deliveryWithInstall": true,
|
"deliveryWithInstall": true,
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
## 1.0.4
|
|
||||||
- 修改门禁编译问题 修改点如下
|
|
||||||
- 修改src/main/cpp/boundscheck/CMakeLists.txt文件中的内容
|
|
||||||
- 修改src/main/cpp/util/DebugLog.h文件中hilog的大小写
|
|
||||||
|
|
||||||
## 1.0.3
|
## 1.0.3
|
||||||
- 安全编译开启Strip和Ftrapv
|
- 修改门禁编译问题 修改点如下
|
||||||
|
- 修改src/main/cpp/util/DebugLog.h文件中hilog的大小写
|
||||||
|
|
||||||
## 1.0.2
|
## 1.0.2
|
||||||
- 支持x86编译
|
- 支持x86编译
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"buildOption": {
|
"buildOption": {
|
||||||
"externalNativeOptions": {
|
"externalNativeOptions": {
|
||||||
"path": "./src/main/cpp/CMakeLists.txt",
|
"path": "./src/main/cpp/CMakeLists.txt",
|
||||||
"arguments": " -DCMAKE_BUILD_TYPE=Release",
|
"arguments": "",
|
||||||
"abiFilters": [
|
"abiFilters": [
|
||||||
"armeabi-v7a",
|
"armeabi-v7a",
|
||||||
"arm64-v8a",
|
"arm64-v8a",
|
||||||
|
|
|
@ -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.4",
|
"version": "1.0.3",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Tool"
|
"Tool"
|
||||||
],
|
],
|
||||||
|
|
|
@ -11,11 +11,8 @@ 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
|
||||||
|
@ -33,4 +30,4 @@ find_library (
|
||||||
GLES-lib
|
GLES-lib
|
||||||
GLESv3 )
|
GLESv3 )
|
||||||
|
|
||||||
target_link_libraries(nativeGpu PUBLIC boundscheck ${hilog-lib} ${EGL-lib} ${GLES-lib} libace_napi.z.so -s -ftrapv)
|
target_link_libraries(nativeGpu PUBLIC ${hilog-lib} ${EGL-lib} ${GLES-lib} libace_napi.z.so libc++.a)
|
|
@ -1,27 +0,0 @@
|
||||||
# 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)
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit a45b3aceed2c0138babc951850445d1cd010ce48
|
|
|
@ -535,10 +535,7 @@ 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);
|
||||||
if (memcpy_s(m_RenderImage.ppPlane[0],
|
memcpy(m_RenderImage.ppPlane[0], pData, width * height * DEFAULT_FOUR);
|
||||||
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,
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#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;
|
||||||
|
|
||||||
|
@ -42,7 +41,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_s(buf.get(), bufLen, 0, bufLen);
|
(void) memset(buf.get(), 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();
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#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
|
||||||
|
@ -49,7 +48,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;
|
||||||
|
@ -141,9 +140,7 @@ 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;
|
||||||
}
|
}
|
||||||
if (memcpy_s(nativePtr, srcLen, src, srcLen) != EOK) {
|
memcpy(nativePtr, src, srcLen);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,17 +149,10 @@ 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);
|
||||||
if (memcpy_s(tmp, totalLength, *buf, totalLength) != EOK) {
|
memcpy(tmp, *buf, totalLength);
|
||||||
return;
|
memset(*buf, DEFAULT_ZERO, sizeof(uint8_t)*totalLength);
|
||||||
}
|
|
||||||
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++) {
|
||||||
if (memcpy_s(*buf + oneLineLength * i, oneLineLength,
|
memcpy(*buf + oneLineLength * i, tmp + totalLength - oneLineLength * (i+1), oneLineLength);
|
||||||
tmp + totalLength - oneLineLength * (i+1), oneLineLength) != EOK) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"hvigorVersion": "4.0.2",
|
"modelVersion": "5.0.0",
|
||||||
"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" */
|
||||||
|
@ -19,4 +18,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 */
|
||||||
}
|
}
|
||||||
}
|
}
|