Pre Merge pull request !103 from zgf/gif
This commit is contained in:
commit
bf60236697
|
@ -1,3 +1,6 @@
|
||||||
|
## 2.1.2-rc.6
|
||||||
|
- 新增设置gif播放次数功能
|
||||||
|
|
||||||
## 2.1.2-rc.5
|
## 2.1.2-rc.5
|
||||||
- moduleContext新增缓存策略,缓存上限5,缓存策略Lru
|
- moduleContext新增缓存策略,缓存上限5,缓存策略Lru
|
||||||
- 适配DevEco Studio 4.1(4.1.3.415)--SDK:API11( 4.1.0.56)
|
- 适配DevEco Studio 4.1(4.1.3.415)--SDK:API11( 4.1.0.56)
|
||||||
|
|
|
@ -108,7 +108,7 @@ imageKnifeOption = {
|
||||||
### ImageKnifeOption参数列表
|
### ImageKnifeOption参数列表
|
||||||
|
|
||||||
| 参数名称 | 入参内容 | 功能简介 |
|
| 参数名称 | 入参内容 | 功能简介 |
|
||||||
| ---------------------------- | ------------------------------------------------------------ |-----------------------------------------------|
|
| ---------------------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
|
||||||
| loadSrc | string\ | PixelMap\ |Resource | 图片数据源 |
|
| loadSrc | string\ | PixelMap\ |Resource | 图片数据源 |
|
||||||
| mainScaleType | ScaleType | 设置主图展示样式(可选) |
|
| mainScaleType | ScaleType | 设置主图展示样式(可选) |
|
||||||
| strategy | DiskStrategy | 设置磁盘缓存策略(可选) |
|
| strategy | DiskStrategy | 设置磁盘缓存策略(可选) |
|
||||||
|
@ -126,7 +126,7 @@ imageKnifeOption = {
|
||||||
| canRetryClick | boolean | 设置重试图层是否点击重试(可选) |
|
| canRetryClick | boolean | 设置重试图层是否点击重试(可选) |
|
||||||
| onlyRetrieveFromCache | boolean | 仅使用缓存加载数据(可选) |
|
| onlyRetrieveFromCache | boolean | 仅使用缓存加载数据(可选) |
|
||||||
| isCacheable | boolean | 是否开启一级内存缓存(可选) |
|
| isCacheable | boolean | 是否开启一级内存缓存(可选) |
|
||||||
| gif | {<br/> // 返回一周期动画gif消耗的时间<br/> loopFinish?: (loopTime?) => void<br/> // gif播放速率相关<br/> speedFactory?: number<br/> // 直接展示gif第几帧数据<br/> seekTo?: number<br/> } | GIF播放控制能力(可选) |
|
| gif | {<br/> // 返回一周期动画gif消耗的时间<br/> loopFinish?: (loopTime?) => void<br/> // gif播放速率相关<br/> speedFactory?: number<br/> // 直接展示gif第几帧数据<br/> seekTo?: number<br/> // 设置gif播放次数<br/> playTimes?: number<br/> } | GIF播放控制能力(可选) |
|
||||||
| transformation | BaseTransform<PixelMap> | 单个变换(可选) |
|
| transformation | BaseTransform<PixelMap> | 单个变换(可选) |
|
||||||
| transformations | Array<BaseTransform<PixelMap>> | 多个变换,目前仅支持单个变换(可选) |
|
| transformations | Array<BaseTransform<PixelMap>> | 多个变换,目前仅支持单个变换(可选) |
|
||||||
| allCacheInfoCallback | IAllCacheInfoCallback | 输出缓存相关内容和信息(可选) |
|
| allCacheInfoCallback | IAllCacheInfoCallback | 输出缓存相关内容和信息(可选) |
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"name": "entry",
|
"name": "entry",
|
||||||
"description": "example description",
|
"description": "example description",
|
||||||
"repository": {},
|
"repository": {},
|
||||||
"version": "2.1.2-rc.5",
|
"version": "2.1.2-rc.6",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ohos/libraryimageknife": "file:../sharedlibrary",
|
"@ohos/libraryimageknife": "file:../sharedlibrary",
|
||||||
"@ohos/sharedlibrary2": "file:../sharedlibrary2",
|
"@ohos/sharedlibrary2": "file:../sharedlibrary2",
|
||||||
|
|
|
@ -189,6 +189,10 @@ struct IndexFunctionDemo {
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
|
|
||||||
}).margin({ top: 15 })
|
}).margin({ top: 15 })
|
||||||
|
Button("测试gif播放次数")
|
||||||
|
.onClick(() => {
|
||||||
|
router.pushUrl({ url: "pages/testGifPlayTimes" });
|
||||||
|
}).margin({ top: 15 })
|
||||||
}.width('100%').height(60).backgroundColor(Color.Pink)
|
}.width('100%').height(60).backgroundColor(Color.Pink)
|
||||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* 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'
|
||||||
|
|
||||||
|
@Entry
|
||||||
|
@Component
|
||||||
|
struct TestGifPlayTimes {
|
||||||
|
@State ImageKnifeOption1: ImageKnifeOption = {
|
||||||
|
loadSrc: $r('app.media.icon'),
|
||||||
|
placeholderSrc: $r('app.media.icon_loading'),
|
||||||
|
errorholderSrc: $r('app.media.icon_failed')
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
Scroll() {
|
||||||
|
Column() {
|
||||||
|
Text("测试gif播放次数").fontSize(25)
|
||||||
|
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
|
Button("加载网络gif").onClick(() => {
|
||||||
|
this.ImageKnifeOption1 = {
|
||||||
|
loadSrc: "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
|
||||||
|
placeholderSrc: $r('app.media.icon_loading'),
|
||||||
|
errorholderSrc: $r('app.media.icon_failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Button("设置gif播放1次").onClick(() => {
|
||||||
|
this.ImageKnifeOption1 = {
|
||||||
|
loadSrc: "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
|
||||||
|
placeholderSrc: $r('app.media.icon_loading'),
|
||||||
|
errorholderSrc: $r('app.media.icon_failed'),
|
||||||
|
gif: {
|
||||||
|
playTimes: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Button("设置gif播放2次").onClick(() => {
|
||||||
|
this.ImageKnifeOption1 = {
|
||||||
|
loadSrc: "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658",
|
||||||
|
placeholderSrc: $r('app.media.icon_loading'),
|
||||||
|
errorholderSrc: $r('app.media.icon_failed'),
|
||||||
|
gif: {
|
||||||
|
playTimes: 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageKnifeComponent({ imageKnifeOption: this.ImageKnifeOption1 }).width(300).height(300).borderWidth(3)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,6 +38,7 @@
|
||||||
"pages/testImageAntiAliasingWithPage",
|
"pages/testImageAntiAliasingWithPage",
|
||||||
"pages/testImageKnifeRouter1",
|
"pages/testImageKnifeRouter1",
|
||||||
"pages/testImageKnifeRouter2",
|
"pages/testImageKnifeRouter2",
|
||||||
"pages/RequestOptionLoadImage"
|
"pages/RequestOptionLoadImage",
|
||||||
|
"pages/testGifPlayTimes"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -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": "2.1.2-rc.5",
|
"version": "2.1.2-rc.6",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pako": "^2.1.0",
|
"pako": "^2.1.0",
|
||||||
"@ohos/disklrucache": "^2.0.2-rc.0",
|
"@ohos/disklrucache": "^2.0.2-rc.0",
|
||||||
|
|
|
@ -41,6 +41,8 @@ export struct ImageKnifeComponent {
|
||||||
private gifLoopDuration: number = 0
|
private gifLoopDuration: number = 0
|
||||||
private startGifLoopTime: number = 0
|
private startGifLoopTime: number = 0
|
||||||
private endGifLoopTime: number = 0
|
private endGifLoopTime: number = 0
|
||||||
|
// gif 播放次数
|
||||||
|
private playTimes: number = 0
|
||||||
// 抗锯齿属性
|
// 抗锯齿属性
|
||||||
private imageSmoothingQuality: ImageSmoothingQuality = 'low';
|
private imageSmoothingQuality: ImageSmoothingQuality = 'low';
|
||||||
private imageSmoothingEnabled: boolean = true;
|
private imageSmoothingEnabled: boolean = true;
|
||||||
|
@ -708,6 +710,14 @@ export struct ImageKnifeComponent {
|
||||||
}
|
}
|
||||||
// draw Frame
|
// draw Frame
|
||||||
this.drawFrame(this.renderFrames_frames, this.renderFrames_index, this.renderFrames_context, this.renderFrames_compWidth, this.renderFrames_compHeight);
|
this.drawFrame(this.renderFrames_frames, this.renderFrames_index, this.renderFrames_context, this.renderFrames_compWidth, this.renderFrames_compHeight);
|
||||||
|
// gif播放次数
|
||||||
|
if (this.renderFrames_frames != undefined && this.renderFrames_index === (this.renderFrames_frames.length - 1) && this.imageKnifeOption.gif != undefined ) {
|
||||||
|
this.playTimes++
|
||||||
|
if (this.imageKnifeOption.gif.playTimes == this.playTimes){
|
||||||
|
this.autoPlay = false
|
||||||
|
this.playTimes = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
//如果gif动图只有一帧的情况下,不进行后面代码的逐帧绘制循环
|
//如果gif动图只有一帧的情况下,不进行后面代码的逐帧绘制循环
|
||||||
if (this.renderFrames_frames != undefined && this.renderFrames_frames.length <= 1) {
|
if (this.renderFrames_frames != undefined && this.renderFrames_frames.length <= 1) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -42,6 +42,7 @@ export interface GifOptions{
|
||||||
loopFinish?: (loopTime?:number) => void
|
loopFinish?: (loopTime?:number) => void
|
||||||
speedFactory?: number
|
speedFactory?: number
|
||||||
seekTo?: number
|
seekTo?: number
|
||||||
|
playTimes?:number
|
||||||
}
|
}
|
||||||
export interface TransformOptions{
|
export interface TransformOptions{
|
||||||
transformType: number,
|
transformType: number,
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
"name": "imageknife",
|
"name": "imageknife",
|
||||||
"description": "example description",
|
"description": "example description",
|
||||||
"repository": {},
|
"repository": {},
|
||||||
"version": "2.1.2-rc.5",
|
"version": "2.1.2-rc.6",
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue