Pre Merge pull request !205 from taxuexunji/master
This commit is contained in:
commit
198eba83b2
|
@ -8,6 +8,7 @@
|
||||||
- 适配Sendable内存共享优化
|
- 适配Sendable内存共享优化
|
||||||
- 修改全局请求头覆盖request请求头
|
- 修改全局请求头覆盖request请求头
|
||||||
- imageKnife支持heic测试demo独立页面展示
|
- imageKnife支持heic测试demo独立页面展示
|
||||||
|
- webp单帧图片直接返回pixelMap不返回frame
|
||||||
|
|
||||||
## 2.1.2-rc.12
|
## 2.1.2-rc.12
|
||||||
- 新增gif播放次数功能
|
- 新增gif播放次数功能
|
||||||
|
|
|
@ -186,7 +186,7 @@ struct testImageKnifeCache {
|
||||||
Button('默认')
|
Button('默认')
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.index_ = 2;
|
this.index_ = 2;
|
||||||
imageKnife?.isUrlExist(this.url).then(this.loadSuccess)
|
imageKnife?.isUrlExist(this.url, CacheType.Default, this.comSize).then(this.loadSuccess)
|
||||||
.catch(this.loadError);
|
.catch(this.loadError);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,13 +393,18 @@ export class ImageKnife {
|
||||||
|
|
||||||
if ((ImageKnifeData.GIF == filetype || ImageKnifeData.WEBP == filetype) && !request.dontAnimateFlag) {
|
if ((ImageKnifeData.GIF == filetype || ImageKnifeData.WEBP == filetype) && !request.dontAnimateFlag) {
|
||||||
let gifParseImpl = new GIFParseImpl()
|
let gifParseImpl = new GIFParseImpl()
|
||||||
gifParseImpl.parseGifs(cached, (data?: GIFFrame[], err?: BusinessError | string) => {
|
gifParseImpl.parseGifs(cached, (data?: GIFFrame[] | PixelMap, err?: BusinessError | string) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
onError(err)
|
onError(err)
|
||||||
}
|
}
|
||||||
LogUtil.log("gifProcess data is null:" + (data == null));
|
LogUtil.log("gifProcess data is null:" + (data == null));
|
||||||
if (!!data) {
|
if (!!data) {
|
||||||
let imageKnifeData = ImageKnifeData.createImageGIFFrame(ImageKnifeType.GIFFRAME, data);
|
let imageKnifeData: ImageKnifeData;
|
||||||
|
if((typeof (data as image.PixelMap).isEditable) == 'boolean') {
|
||||||
|
imageKnifeData = ImageKnifeData.createImagePixelMap(ImageKnifeType.PIXELMAP, (data as image.PixelMap));
|
||||||
|
}else {
|
||||||
|
imageKnifeData = ImageKnifeData.createImageGIFFrame(ImageKnifeType.GIFFRAME, (data as GIFFrame[]));
|
||||||
|
}
|
||||||
LogUtil.log('gifProcess 生成gif 返回数据类型')
|
LogUtil.log('gifProcess 生成gif 返回数据类型')
|
||||||
onComplete(imageKnifeData)
|
onComplete(imageKnifeData)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -536,7 +536,7 @@ export class RequestManager {
|
||||||
|
|
||||||
private gifProcess(onComplete: (value: PixelMap | GIFFrame[]) => void | PromiseLike<ImageKnifeData>, onError: (reason?: BusinessError | string) => void, arraybuffer: ArrayBuffer, typeValue: string, cacheStrategy?: (cacheData: ImageKnifeData) => void) {
|
private gifProcess(onComplete: (value: PixelMap | GIFFrame[]) => void | PromiseLike<ImageKnifeData>, onError: (reason?: BusinessError | string) => void, arraybuffer: ArrayBuffer, typeValue: string, cacheStrategy?: (cacheData: ImageKnifeData) => void) {
|
||||||
let gifParseImpl = new GIFParseImpl()
|
let gifParseImpl = new GIFParseImpl()
|
||||||
gifParseImpl.parseGifs(arraybuffer, (data?: GIFFrame[], err?: BusinessError | string) => {
|
gifParseImpl.parseGifs(arraybuffer, (data?: GIFFrame[] | PixelMap, err?: BusinessError | string) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
onError(err)
|
onError(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ export interface gifBackData {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GIFParseImpl implements IParseGif {
|
export class GIFParseImpl implements IParseGif {
|
||||||
parseGifs(imageinfo: ArrayBuffer, callback: (data?: GIFFrame[], err?: BusinessError | string) => void) {
|
parseGifs(imageinfo: ArrayBuffer, callback: (data?: GIFFrame[] | PixelMap, err?: BusinessError | string) => void) {
|
||||||
// 硬解码流程
|
// 硬解码流程
|
||||||
let imageSource = image.createImageSource(imageinfo);
|
let imageSource = image.createImageSource(imageinfo);
|
||||||
let decodeOpts: image.DecodingOptions = {
|
let decodeOpts: image.DecodingOptions = {
|
||||||
|
@ -44,6 +44,9 @@ export class GIFParseImpl implements IParseGif {
|
||||||
}
|
}
|
||||||
let data:GIFFrame[] = [];
|
let data:GIFFrame[] = [];
|
||||||
imageSource.createPixelMapList(decodeOpts).then((pixelList: Array<PixelMap>) => {
|
imageSource.createPixelMapList(decodeOpts).then((pixelList: Array<PixelMap>) => {
|
||||||
|
if(pixelList.length == 1){
|
||||||
|
callback(pixelList[0],undefined)
|
||||||
|
}else {
|
||||||
//sdk的api接口发生变更:从.getDelayTime() 变为.getDelayTimeList()
|
//sdk的api接口发生变更:从.getDelayTime() 变为.getDelayTimeList()
|
||||||
imageSource.getDelayTimeList().then(delayTimes => {
|
imageSource.getDelayTimeList().then(delayTimes => {
|
||||||
if (pixelList.length > 0) {
|
if (pixelList.length > 0) {
|
||||||
|
@ -71,6 +74,7 @@ export class GIFParseImpl implements IParseGif {
|
||||||
imageSource.release();
|
imageSource.release();
|
||||||
callback(undefined,err)
|
callback(undefined,err)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}).catch((err: string) => {
|
}).catch((err: string) => {
|
||||||
imageSource.release();
|
imageSource.release();
|
||||||
callback(undefined,err)
|
callback(undefined,err)
|
||||||
|
|
|
@ -17,5 +17,5 @@ import { GIFFrame } from './GIFFrame'
|
||||||
import worker from '@ohos.worker';
|
import worker from '@ohos.worker';
|
||||||
export interface IParseGif{
|
export interface IParseGif{
|
||||||
// gif解析
|
// gif解析
|
||||||
parseGifs:(imageinfo: ArrayBuffer, callback: (data?:GIFFrame[], err?:BusinessError|string) => void, worker?:worker.ThreadWorker,runMainThread?:boolean)=>void
|
parseGifs:(imageinfo: ArrayBuffer, callback: (data?:GIFFrame[] | PixelMap, err?:BusinessError|string) => void, worker?:worker.ThreadWorker,runMainThread?:boolean)=>void
|
||||||
}
|
}
|
Loading…
Reference in New Issue