更新说明:
1、 屏蔽了taskpool解码能力 2、 支持2.1.1-rc.1 到 2.1.1-rc.5功能 Signed-off-by: 明月清风 <qiufeihu1@h-partners.com>
This commit is contained in:
parent
e7270a35bf
commit
38d287abba
|
@ -3,7 +3,7 @@
|
|||
"bundleName": "com.openharmony.imageknife",
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "2.1.1-rc.5",
|
||||
"versionName": "2.1.2",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:app_name",
|
||||
"distributedNotificationEnabled": true
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## 2.1.2
|
||||
- 屏蔽了taskpool解码能力
|
||||
- 支持2.1.1-rc.1 到 2.1.1-rc.5功能
|
||||
|
||||
## 2.1.1-rc.5
|
||||
- .jpg .png .gif解码功能使用taskpool实现
|
||||
- 修复了内存缓存张数设置为1时gif图片消失的问题
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"name": "entry",
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "2.1.1-rc.5",
|
||||
"version": "2.1.2",
|
||||
"dependencies": {
|
||||
"@ohos/libraryimageknife": "file:../sharedlibrary",
|
||||
"@ohos/disklrucache": "^2.0.2-rc.0",
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"main": "index.ets",
|
||||
"repository": "https://gitee.com/openharmony-tpc/ImageKnife",
|
||||
"type": "module",
|
||||
"version": "2.1.1-rc.5",
|
||||
"version": "2.1.2",
|
||||
"dependencies": {
|
||||
"pako": "^2.1.0",
|
||||
"@ohos/disklrucache": "^2.0.2-rc.0",
|
||||
|
|
|
@ -26,15 +26,40 @@ export class ParseImageUtil implements IParseImage<PixelMap> {
|
|||
|
||||
// scale(0,1)
|
||||
parseImageThumbnail(scale: number, imageinfo: ArrayBuffer, onCompleteFunction: (value: PixelMap) => void | PromiseLike<PixelMap>, onErrorFunction: (reason?: BusinessError | string) => void) {
|
||||
taskPoolExecutePixelMap(imageinfo,scale,onCompleteFunction,onErrorFunction);
|
||||
|
||||
let imageSource: image.ImageSource = image.createImageSource(imageinfo); // 步骤一:文件转为pixelMap 然后变换 给Image组件
|
||||
imageSource.getImageInfo().then((value) => {
|
||||
let hValue = Math.round(value.size.height * scale);
|
||||
let wValue = Math.round(value.size.width * scale);
|
||||
let defaultSize: image.Size = {
|
||||
height: hValue,
|
||||
width: wValue
|
||||
};
|
||||
let opts: image.DecodingOptions = {
|
||||
editable: true,
|
||||
desiredSize: defaultSize
|
||||
};
|
||||
|
||||
imageSource.createPixelMap(opts).then((pixelMap: image.PixelMap) => {
|
||||
onCompleteFunction(pixelMap);
|
||||
imageSource.release()
|
||||
}).catch((err: string) => {
|
||||
onErrorFunction(err);
|
||||
imageSource.release()
|
||||
})
|
||||
|
||||
}).catch((err: string) => {
|
||||
onErrorFunction(err);
|
||||
imageSource.release()
|
||||
})
|
||||
|
||||
// taskPoolExecutePixelMap(imageinfo,scale,onCompleteFunction,onErrorFunction); //多线程接口
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Concurrent
|
||||
async function taskParseImage(arrayBuffer: ArrayBuffer,scale: number): Promise<PixelMap> {
|
||||
async function taskParseImage(arrayBuffer: ArrayBuffer, scale: number): Promise<PixelMap> {
|
||||
let imageSource: image.ImageSource = image.createImageSource(arrayBuffer); // 步骤一:文件转为pixelMap 然后变换 给Image组件
|
||||
let value = await imageSource.getImageInfo();
|
||||
let hValue = Math.round(value.size.height * scale);
|
||||
|
@ -48,14 +73,14 @@ async function taskParseImage(arrayBuffer: ArrayBuffer,scale: number): Promise<P
|
|||
desiredSize: defaultSize
|
||||
};
|
||||
let pixelMap = await imageSource.createPixelMap(opts)
|
||||
LogUtil.log( "ceshi321 : Succeeded in creating pixelmap taskpool " + pixelMap.getPixelBytesNumber())
|
||||
LogUtil.log("ceshi321 : Succeeded in creating pixelmap taskpool " + pixelMap.getPixelBytesNumber())
|
||||
imageSource.release()
|
||||
return pixelMap;
|
||||
}
|
||||
|
||||
function taskPoolExecutePixelMap(arrayBuffer: ArrayBuffer, scale: number, onCompleteFunction: (value: PixelMap) => void | PromiseLike<PixelMap>, onErrorFunction: (reason?: BusinessError | string) => void) {
|
||||
LogUtil.log("ceshi321 : arrayBuffer长度" + arrayBuffer.byteLength)
|
||||
let task = new taskpool.Task(taskParseImage, arrayBuffer,scale)
|
||||
let task = new taskpool.Task(taskParseImage, arrayBuffer, scale)
|
||||
task.setTransferList([])
|
||||
taskpool.execute(task).then((pixelmap: image.PixelMap) => {
|
||||
LogUtil.log('ceshi321 : Succeeded in creating pixelmap Ui .' + pixelmap.getPixelBytesNumber())
|
||||
|
|
|
@ -35,7 +35,48 @@ export interface gifBackData {
|
|||
|
||||
export class GIFParseImpl implements IParseGif {
|
||||
parseGifs(imageinfo: ArrayBuffer, callback: (data?: GIFFrame[], err?: BusinessError | string) => void) {
|
||||
taskPoolExecutePixelMapList(imageinfo,callback);
|
||||
// 硬解码流程
|
||||
let imageSource = image.createImageSource(imageinfo);
|
||||
let decodeOpts: image.DecodingOptions = {
|
||||
sampleSize: 1,
|
||||
editable: true,
|
||||
rotate: 0
|
||||
}
|
||||
let data:GIFFrame[] = [];
|
||||
imageSource.createPixelMapList(decodeOpts).then((pixelList: Array<PixelMap>) => {
|
||||
//sdk的api接口发生变更:从.getDelayTime() 变为.getDelayTimeList()
|
||||
imageSource.getDelayTimeList().then(delayTimes => {
|
||||
if (pixelList.length > 0) {
|
||||
let pixelmap1 = pixelList[0];
|
||||
pixelmap1.getImageInfo().then(imageInfo => {
|
||||
for (let i = 0; i < pixelList.length; i++) {
|
||||
let frame = new GIFFrame();
|
||||
frame.drawPixelMap = pixelList[i];
|
||||
frame.dims = { width: imageInfo.size.width, height: imageInfo.size.height, top: 0, left: 0 }
|
||||
if (i < delayTimes.length) {
|
||||
frame.delay = delayTimes[i];
|
||||
} else {
|
||||
frame.delay = delayTimes[delayTimes.length - 1]
|
||||
}
|
||||
data.push(frame)
|
||||
}
|
||||
callback(data,undefined)
|
||||
imageSource.release();
|
||||
}).catch((err: string) => {
|
||||
imageSource.release();
|
||||
callback(undefined,err)
|
||||
})
|
||||
}
|
||||
}).catch((err: string) => {
|
||||
imageSource.release();
|
||||
callback(undefined,err)
|
||||
})
|
||||
}).catch((err: string) => {
|
||||
imageSource.release();
|
||||
callback(undefined,err)
|
||||
})
|
||||
// taskPoolExecutePixelMapList(imageinfo,callback); //多线程接口
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
"name": "imageknife",
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "2.1.1-rc.5",
|
||||
"version": "2.1.2",
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue