完善3.x README.md,使用5.0 API12

Signed-off-by: madixin <madixin@huawei.com>
This commit is contained in:
madixin 2024-05-02 10:14:23 +08:00
parent e8f081523b
commit be0f5ff8ef
11 changed files with 99 additions and 175 deletions

View File

@ -1,11 +1,11 @@
## 3.0.0-rc.1
- 新增从内存或文件缓存获取图片数据接口getCacheImage
- 新增图片预加载preLoadCache并会犯文件缓存路径
- 新增图片预加载preLoadCache并返回文件缓存路径
- ImageKnifeOption新增writeCacheStrategy存入策略(只存入内存或文件缓存)
- ImageKnifeOption新增onlyRetrieveFromCache仅用缓存加载
- 新增单个和全局请求头
- 补齐自定key特性
- 获取组件宽高改用onSizeChange
- 获取组件宽高改用onSizeChange 需要API12
## 3.0.0-rc.0
- 使用Image组件替换Canvas组件渲染并重构大部分的实现逻辑提升渲染性能
@ -27,6 +27,31 @@
- 支持进行图片变换: 支持图像像素源图片变换效果。
- 抗锯齿相关参数
## 2.2.0-rc.2
- ImageKnife支持heic图片修改demo按钮控制组件是否展示
- ImageKnife控制可视化区域图片
## 2.2.0-rc.1
- 修改ImageKnife跳过网络,点击默认,图片没有传入宽高,无显示bug
- ImageKnife支持根据自定义key获取已缓存的图片
- ImageKnife加载图片支持自定义网络栈和图片加载组件
- 适配复用场景触发懒加载onDataReloaded
- ImageKnife控制重要图片请求加载优先级
## 2.2.0-rc.0
- 修复自定义DataFetch接口实现不生效问题
- 修改磁盘缓存到子线程
- 更新SDK到API12
- 适配Sendable内存共享优化
- 修改全局请求头覆盖request请求头
- imageKnife支持heic测试demo独立页面展示
- drawLifeCycle支持gif图
## 2.1.2
- 修改ImageKnife跳过网络从内存中获取图片 cacheType参数未使用bug
- 新增WEBP图片解析能力。
- 新增gif图片支持暂停播放功能
## 2.1.2-rc.12
- 新增gif播放次数功能
- 新增磁盘预加载返回文件路径接口prefetchToDiskCache

View File

@ -16,14 +16,16 @@
- 支持通过设置transform缩放图片
- 并发请求数量,支持请求排队队列的优先级
- 支持生命周期已销毁的图片,不再发起请求
- 自定义缓存key
- 自定义请求头规格
- 支持writeCacheStrategy控制缓存的存入策略(只存入内存或文件缓存)
- 支持preLoadCache预加载图片
- 支持onlyRetrieveFromCache仅用缓存加载
待实现特性
- svg图片显示
- gif/webp动图显示与控制
- 内存降采样优化,节约内存的占用
- 支持自定义图片加载
- 支持自定义图片解码
- 支持自定义key的实现
- 支持进行图片变换: 支持图像像素源图片变换效果。
注意3.x版本相对2.x版本做了重大的重构主要体现在
@ -36,7 +38,6 @@
- 不支持drawLifeCycle接口通过canvas自会图片
- mainScaleTypeborder等参数新版本与系统Image保持一致
- gif/webp动图播放与控制
- signature自定义key的实现
- 支持进行图片变换: 支持图像像素源图片变换效果。
- 抗锯齿相关参数
@ -151,8 +152,8 @@ ImageKnifeComponent({ ImageKnifeOption:
| setEngineKeyImpl | CustomEngineKeyImpl | 全局配置缓存key |
## 约束与限制
API11
在下述版本验证通过:
DevEco Studio 5.0 Canary35.0.3.221--SDK:API12
## 贡献代码
使用过程中发现任何问题都可以提 [issue](https://gitee.com/openharmony-tpc/ImageKnife/issues)
@ -163,5 +164,4 @@ API11
本项目基于 [Apache License 2.0](https://gitee.com/openharmony-tpc/ImageKnife/blob/master/LICENSE) ,请自由的享受和参与开源。
## 遗留问题
- reuse组件错位问题
- 添加组件闪动问题

View File

@ -32,7 +32,7 @@ struct Index {
});
})
Button("多图 + Foreach").margin({top:10}).onClick(()=>{
Button("多图 + LazyForEach").margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/ManyPhotoShowPage',
@ -44,13 +44,13 @@ struct Index {
});
})
Button("长图").margin({top:10}).onClick(()=>{
Button("长图显示").margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/LongImagePage',
});
})
Button("缩放").margin({top:10}).onClick(()=>{
Button("缩放图片").margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/TransformPage',
@ -62,25 +62,25 @@ struct Index {
});
})
Button("自定义key").margin({top:10}).onClick(()=>{
Button("自定义缓存key").margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/SignatureTestPage',
});
})
Button("测试文件缓存预加载").onClick(()=>{
Button("预加载图片到文件缓存").margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/TestPrefetchToFileCache',
});
})
Button("测试获取内存文件缓存").onClick(()=>{
Button("从缓存获取图片显示").margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/TestIsUrlExist',
});
})
Button("测试单个请求头").onClick(()=>{
Button("测试单个请求头").margin({top:10}).onClick(()=>{
router.push({
uri: 'pages/TestHeader',

View File

@ -33,7 +33,7 @@ struct SignatureTestPage {
Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("Signature固定为 1").fontSize(15)
Text("key固定为 1").fontSize(15)
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button("加载")
.onClick(() => {
@ -46,7 +46,7 @@ struct SignatureTestPage {
ImageKnifeComponent({ ImageKnifeOption: this.imageKnifeOption1 }).width(300).height(300)
}.width('100%').backgroundColor(Color.Pink)
Text("设置Signature每次为时间戳").fontSize(15)
Text("key每次变化时间戳").fontSize(15)
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button("加载")
.onClick(() => {

View File

@ -12,66 +12,74 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ImageKnifeComponent,ImageKnife,ImageKnifeOption,ReadCacheStrategyType } from '@ohos/imageknife'
import { ImageKnifeComponent, ImageKnife, ImageKnifeOption, ReadCacheStrategyType } from '@ohos/imageknife'
@Entry
@Component
struct TestIsUrlExist {
@State imageKnifeOption: ImageKnifeOption = {
loadSrc:$r('app.media.startIcon'),
placeholderSrc:$r('app.media.loading')
loadSrc: $r('app.media.startIcon'),
placeholderSrc: $r('app.media.loading')
}
@State source: PixelMap | string = ""
@State source1: PixelMap | string = ""
@State source: PixelMap | string | Resource = $r("app.media.startIcon")
@State source1: PixelMap | string | Resource = $r("app.media.startIcon")
build() {
Column() {
Flex(){
Button("加载gif图").onClick(()=>{
this.imageKnifeOption.loadSrc = "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658"
Flex() {
Button("预加载gif图").onClick(() => {
this.imageKnifeOption.loadSrc =
"https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658"
})
Button("内存缓存获取gif").onClick(()=>{
Button("内存缓存获取gif").onClick(() => {
ImageKnife.getInstance()
.getCacheImage("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",ReadCacheStrategyType.Memory)
.then((data)=>{
this.source = data!.source
.getCacheImage("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
ReadCacheStrategyType.Memory)
.then((data) => {
this.source = data !== undefined ? data.source : $r("app.media.startIcon")
})
})
Button("文件缓存获取gif").onClick(()=>{
Button("文件缓存获取gif").onClick(() => {
ImageKnife.getInstance()
.getCacheImage("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",ReadCacheStrategyType.File)
.then((data)=>{
this.source1 = data!.source
})
})
}
Flex(){
Button("加载静态图").onClick(()=>{
this.imageKnifeOption.loadSrc = 'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp'
})
Button("内存缓存获取").onClick(()=>{
ImageKnife.getInstance()
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',ReadCacheStrategyType.Memory)
.then((data)=>{
this.source = data!.source
})
})
Button("文件缓存获取").onClick(()=>{
ImageKnife.getInstance()
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',ReadCacheStrategyType.File)
.then((data)=>{
this.source1 = data!.source
.getCacheImage("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
ReadCacheStrategyType.File)
.then((data) => {
this.source1 = data !== undefined ? data.source : $r("app.media.startIcon")
})
})
}
Flex() {
Button("预加载静态图").onClick(() => {
this.imageKnifeOption.loadSrc =
'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp'
})
Button("内存缓存获取").onClick(() => {
ImageKnife.getInstance()
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
ReadCacheStrategyType.Memory)
.then((data) => {
this.source = data!.source
})
})
Button("文件缓存获取").onClick(() => {
ImageKnife.getInstance()
.getCacheImage('https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp',
ReadCacheStrategyType.File)
.then((data) => {
this.source1 = data!.source
})
})
}.margin({ top: 10 })
ImageKnifeComponent({
ImageKnifeOption: this.imageKnifeOption
}).width(200).height(200)
Image(this.source)
.width(200).height(200).backgroundColor(Color.Pink)
Image(this.source1)
.width(200).height(200).backgroundColor(Color.Pink)
}).width(200).height(200).margin({ top: 10 })
Image(this.source).margin({ top: 10 })
.width(200).height(200)
Image(this.source1).margin({ top: 10 })
.width(200).height(200)
}
.height('100%') .width('100%')
.height('100%').width('100%')
}
}

View File

@ -27,15 +27,15 @@ struct TestPrefetchToFileCachePage {
}
build() {
Column() {
Button("磁盘预加载").onClick(async ()=>{
Button("预加载图片到文件缓存").margin({top:10}).onClick(async ()=>{
await this.preload("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658")
})
Button("加载图片").onClick(()=>{
Button("加载图片(预加载后可断网加载)").margin({top:10}).onClick(()=>{
this.imageKnifeOption.loadSrc = "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658"
})
ImageKnifeComponent({
ImageKnifeOption: this.imageKnifeOption
}).width(300).height(300)
}).width(300).height(300).margin({top:30})
}
.height('100%') .width('100%')
}

View File

@ -1,7 +1,6 @@
{
"hvigorVersion": "4.0.2",
"modelVersion": "5.0.0",
"dependencies": {
"@ohos/hvigor-ohos-plugin": "4.0.2"
},
"execution": {
// "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */

File diff suppressed because one or more lines are too long

54
hvigorw
View File

@ -1,54 +0,0 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Hvigor startup script, version 1.0.0
#
# Required ENV vars:
# ------------------
# NODE_HOME - location of a Node home dir
# or
# Add /usr/local/nodejs/bin to the PATH environment variable
# ----------------------------------------------------------------------------
HVIGOR_APP_HOME="`pwd -P`"
HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
#NODE_OPTS="--max-old-space-size=4096"
fail() {
echo "$*"
exit 1
}
set_executable_node() {
EXECUTABLE_NODE="${NODE_HOME}/bin/node"
if [ -x "$EXECUTABLE_NODE" ]; then
return
fi
EXECUTABLE_NODE="${NODE_HOME}/node"
if [ -x "$EXECUTABLE_NODE" ]; then
return
fi
fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
}
# Determine node to start hvigor wrapper script
if [ -n "${NODE_HOME}" ]; then
set_executable_node
else
EXECUTABLE_NODE="node"
command -v ${EXECUTABLE_NODE} &> /dev/null || fail "ERROR: NODE_HOME not set and 'node' command not found"
fi
# Check hvigor wrapper script
if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ]; then
fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
fi
if [ -z "${NODE_OPTS}" ]; then
NODE_OPTS="--"
fi
# start hvigor-wrapper script
exec "${EXECUTABLE_NODE}" "${NODE_OPTS}" \
"${HVIGOR_WRAPPER_SCRIPT}" "$@"

View File

@ -1,54 +0,0 @@
@rem
@rem ----------------------------------------------------------------------------
@rem Hvigor startup script for Windows, version 1.0.0
@rem
@rem Required ENV vars:
@rem ------------------
@rem NODE_HOME - location of a Node home dir
@rem or
@rem Add %NODE_HOME%/bin to the PATH environment variable
@rem ----------------------------------------------------------------------------
@rem
@echo off
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
set NODE_EXE=node.exe
@rem set NODE_OPTS="--max-old-space-size=4096"
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
if not defined NODE_OPTS set NODE_OPTS="--"
@rem Find node.exe
if defined NODE_HOME (
set NODE_HOME=%NODE_HOME:"=%
set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%
)
%NODE_EXE% --version >NUL 2>&1
if "%ERRORLEVEL%" == "0" (
"%NODE_EXE%" "%NODE_OPTS%" "%WRAPPER_MODULE_PATH%" %*
) else if exist "%NODE_EXE_PATH%" (
"%NODE_EXE%" "%NODE_OPTS%" "%WRAPPER_MODULE_PATH%" %*
) else (
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
)
if "%ERRORLEVEL%" == "0" (
if "%OS%" == "Windows_NT" endlocal
) else (
exit /b %ERRORLEVEL%
)

View File

@ -1,4 +1,5 @@
{
"modelVersion": "5.0.0",
"name": "imageknife",
"version": "1.0.0",
"description": "Please describe the basic information.",
@ -8,6 +9,6 @@
"dependencies": {
},
"devDependencies": {
"@ohos/hypium": "1.0.13"
"@ohos/hypium": "1.0.16"
}
}
}