Pre Merge pull request !308 from zgf/master
This commit is contained in:
commit
034fcf8cfc
|
@ -10,6 +10,7 @@
|
|||
- svg解码宽高单位给位px
|
||||
- 修复复用场景下从内存获取图片后又清空了画布导致图片不显示
|
||||
- 修复复用场景主图比占位图绘制快后下次不显示占位图问题
|
||||
- 增加gif图duration的默认值,以及默认播放次数
|
||||
|
||||
## 2.2.0-rc.2
|
||||
- ImageKnife支持下采样
|
||||
|
|
|
@ -58,6 +58,10 @@ struct TestGifPlayTimesPage {
|
|||
}
|
||||
|
||||
ImageKnifeComponent({ imageKnifeOption: this.ImageKnifeOption1 }).width(300).height(300).borderWidth(3)
|
||||
Text("gif自带默播放一次")
|
||||
ImageKnifeComponent({ imageKnifeOption: {
|
||||
loadSrc:$r('app.media.diamond_1')
|
||||
} }).width(300).height(300).borderWidth(3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
|
@ -808,6 +808,7 @@ export class ImageKnife {
|
|||
let imageKnifeData = ImageKnifeData.createImageGIFFrame(ImageKnifeType.GIFFRAME, data as GIFFrame[]);
|
||||
let requestList: List<RequestOption> | undefined = this.executingJobMap.get(request.uuid);
|
||||
LogUtil.info("VISIBLE: taskpool execute done. data as GIFFrame: " + requestList?.length);
|
||||
imageKnifeData.iterations = data[0].iterations
|
||||
// 组件被销毁会删除请求,因此requestList可能是undefined
|
||||
if(requestList != undefined) {
|
||||
requestList.forEach((requestOption: RequestOption)=>{
|
||||
|
|
|
@ -56,6 +56,8 @@ export struct ImageKnifeComponent {
|
|||
private imageSmoothingEnabled: boolean = true;
|
||||
// 是否是gif图片
|
||||
private isGif: boolean = false
|
||||
|
||||
private gifPlayTimes: number = 0
|
||||
defaultLifeCycle: IDrawLifeCycle = {
|
||||
|
||||
// 展示占位图
|
||||
|
@ -875,7 +877,7 @@ export struct ImageKnifeComponent {
|
|||
this.renderFrames_context = context
|
||||
this.renderFrames_compWidth = compWidth
|
||||
this.renderFrames_compHeight = compHeight
|
||||
|
||||
this.gifPlayTimes = data.iterations
|
||||
this.renderFrames()
|
||||
}
|
||||
}
|
||||
|
@ -916,6 +918,13 @@ export struct ImageKnifeComponent {
|
|||
// draw Frame
|
||||
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.gifPlayTimes != 0 && this.imageKnifeOption.gif == undefined ) {
|
||||
this.playTimes++
|
||||
if (this.gifPlayTimes == this.playTimes){
|
||||
this.imageKnifeOption.autoPlay = false;
|
||||
this.playTimes = 0
|
||||
}
|
||||
}
|
||||
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){
|
||||
|
@ -961,7 +970,11 @@ export struct ImageKnifeComponent {
|
|||
if (this.renderFrames_frames != undefined && this.renderFrames_index >= this.renderFrames_frames.length) {
|
||||
this.renderFrames_index = 0;
|
||||
}
|
||||
this.gifTimerId = setTimeout(this.renderFrames, delayTime)
|
||||
if (delayTime == 0) {
|
||||
this.gifTimerId = setTimeout(this.renderFrames, 100)
|
||||
} else {
|
||||
this.gifTimerId = setTimeout(this.renderFrames, delayTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ export class ImageKnifeData {
|
|||
static PNG = 'png';
|
||||
static BMP = 'bmp';
|
||||
static WEBP = 'webp';
|
||||
iterations: number = 0
|
||||
waitSaveDisk = false;
|
||||
imageKnifeType: ImageKnifeType | undefined = undefined;
|
||||
drawPixelMap: DrawPixelMap | undefined = undefined;
|
||||
|
|
|
@ -44,4 +44,6 @@ export class GIFFrame {
|
|||
|
||||
// 表示透明度的可选颜色索引
|
||||
transparentIndex: number
|
||||
|
||||
iterations?:number
|
||||
}
|
|
@ -67,11 +67,18 @@ export class GIFParseImpl implements IParseGif {
|
|||
}
|
||||
})
|
||||
let data: GIFFrame[] = [];
|
||||
let iterations: number = 0
|
||||
imageSource.createPixelMapList(decodeOpts).then((pixelList: Array<PixelMap>) => {
|
||||
//sdk的api接口发生变更:从.getDelayTime() 变为.getDelayTimeList()
|
||||
imageSource.getDelayTimeList().then(delayTimes => {
|
||||
imageSource.getDelayTimeList().then(async (delayTimes) => {
|
||||
if (pixelList.length > 0) {
|
||||
let pixelmap1 = pixelList[0];
|
||||
try {
|
||||
let dataTimes = await imageSource.getImageProperty(image.PropertyKey.GIF_LOOP_COUNT)
|
||||
iterations = Number(dataTimes)
|
||||
} catch (e) {
|
||||
iterations = 1
|
||||
}
|
||||
pixelmap1.getImageInfo().then(imageInfo => {
|
||||
for (let i = 0; i < pixelList.length; i++) {
|
||||
let frame = new GIFFrame();
|
||||
|
@ -84,6 +91,7 @@ export class GIFParseImpl implements IParseGif {
|
|||
}
|
||||
data.push(frame)
|
||||
}
|
||||
data[0].iterations = iterations
|
||||
callback(data, undefined)
|
||||
imageSource.release();
|
||||
}).catch((err: string) => {
|
||||
|
|
Loading…
Reference in New Issue