forked from floraachy/ImageKnife
FileUtil.readFile接口和file格式图片同步关闭fd
Signed-off-by: zgf <zenggaofeng2@h-partners.com>
This commit is contained in:
parent
4872cc64f7
commit
6dcf2840b3
|
@ -1,3 +1,12 @@
|
||||||
|
## 3.0.2-rc.0
|
||||||
|
- FileUtil.readFile接口和file格式图片同步关闭fd
|
||||||
|
|
||||||
|
## 3.0.1
|
||||||
|
- 修复animatorOption属性设置初始化值失效
|
||||||
|
- 网络请求code为206、204时返回arraybuffer
|
||||||
|
- ImageKnifeComponent显示非必要文件缓存初始化
|
||||||
|
- 修复webp静态图无法设置图形变换
|
||||||
|
|
||||||
## 3.0.1-rc.2
|
## 3.0.1-rc.2
|
||||||
- 修复自定义下载失败无失败回调
|
- 修复自定义下载失败无失败回调
|
||||||
- 增加全局配置自定义下载接口
|
- 增加全局配置自定义下载接口
|
||||||
|
|
|
@ -175,7 +175,7 @@ export class ImageKnifeDispatcher {
|
||||||
requestSource: requestSource,
|
requestSource: requestSource,
|
||||||
isWatchProgress: isWatchProgress,
|
isWatchProgress: isWatchProgress,
|
||||||
memoryKey: memoryKey,
|
memoryKey: memoryKey,
|
||||||
fileCacheFolder: ImageKnife.getInstance().getFileCache().getCacheFolder(),
|
fileCacheFolder: ImageKnife.getInstance().getFileCache()?.getCacheFolder(),
|
||||||
isAnimator:isAnimator
|
isAnimator:isAnimator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ async function requestJob(request: RequestJobRequest, requestList?: List<ImageKn
|
||||||
});
|
});
|
||||||
|
|
||||||
await promise.then((data: number) => {
|
await promise.then((data: number) => {
|
||||||
if (data == 200) {
|
if (data == 200 || data == 204 || data == 201 || data == 206) {
|
||||||
resBuf = combineArrayBuffers(arrayBuffers)
|
resBuf = combineArrayBuffers(arrayBuffers)
|
||||||
} else {
|
} else {
|
||||||
loadError = "HttpDownloadClient has error, http code =" + JSON.stringify(data)
|
loadError = "HttpDownloadClient has error, http code =" + JSON.stringify(data)
|
||||||
|
@ -496,7 +496,7 @@ async function requestJob(request: RequestJobRequest, requestList?: List<ImageKn
|
||||||
let buf = new ArrayBuffer(stat.size);
|
let buf = new ArrayBuffer(stat.size);
|
||||||
await fs.read(file.fd, buf).then((readLen) => {
|
await fs.read(file.fd, buf).then((readLen) => {
|
||||||
resBuf = buf;
|
resBuf = buf;
|
||||||
fs.close(file.fd);
|
fs.closeSync(file.fd);
|
||||||
}).catch((err:BusinessError) => {
|
}).catch((err:BusinessError) => {
|
||||||
loadError = 'LoadDataShareFileClient fs.read err happened uri=' + request.src + " err.msg=" + err?.message + " err.code=" + err?.code;
|
loadError = 'LoadDataShareFileClient fs.read err happened uri=' + request.src + " err.msg=" + err?.message + " err.code=" + err?.code;
|
||||||
})
|
})
|
||||||
|
@ -608,19 +608,23 @@ async function requestJob(request: RequestJobRequest, requestList?: List<ImageKn
|
||||||
}
|
}
|
||||||
let resPixelmap: PixelMap | undefined = undefined
|
let resPixelmap: PixelMap | undefined = undefined
|
||||||
if (typeValue === 'gif' || typeValue === 'webp') {
|
if (typeValue === 'gif' || typeValue === 'webp') {
|
||||||
|
let frameCount = await imageSource.getFrameCount()
|
||||||
let size = (await imageSource.getImageInfo()).size
|
let size = (await imageSource.getImageInfo()).size
|
||||||
|
if (frameCount == undefined || frameCount == 1) {
|
||||||
|
} else {
|
||||||
let base64Help = new util.Base64Helper()
|
let base64Help = new util.Base64Helper()
|
||||||
|
|
||||||
let base64str = "data:image/" + typeValue + ";base64," + base64Help.encodeToStringSync(new Uint8Array(resBuf))
|
let base64str = "data:image/" + typeValue + ";base64," + base64Help.encodeToStringSync(new Uint8Array(resBuf))
|
||||||
LogUtil.log("ImageKnife_DataTime_requestJob_createPixelMap.end_GIF:"+request.src)
|
LogUtil.log("ImageKnife_DataTime_requestJob_createPixelMap.end_GIF:" + request.src)
|
||||||
LogUtil.log("ImageKnife_DataTime_requestJob.end_GIF:"+request.src)
|
LogUtil.log("ImageKnife_DataTime_requestJob.end_GIF:" + request.src)
|
||||||
return {
|
return {
|
||||||
pixelMap: base64str,
|
pixelMap: base64str,
|
||||||
bufferSize: bufferSize,
|
bufferSize: bufferSize,
|
||||||
fileKey: fileKey,
|
fileKey: fileKey,
|
||||||
size:size,
|
size: size,
|
||||||
type:typeValue
|
type: typeValue
|
||||||
};
|
};
|
||||||
|
}
|
||||||
} else if(typeValue == "svg") {
|
} else if(typeValue == "svg") {
|
||||||
let hValue = Math.round(request.componentHeight);
|
let hValue = Math.round(request.componentHeight);
|
||||||
let wValue = Math.round(request.componentWidth);
|
let wValue = Math.round(request.componentWidth);
|
||||||
|
|
|
@ -22,12 +22,9 @@ import { ImageKnifeRequestSource } from '../model/ImageKnifeData';
|
||||||
@Component
|
@Component
|
||||||
export struct ImageKnifeAnimatorComponent {
|
export struct ImageKnifeAnimatorComponent {
|
||||||
@Watch('watchImageKnifeOption') @ObjectLink imageKnifeOption: ImageKnifeOption;
|
@Watch('watchImageKnifeOption') @ObjectLink imageKnifeOption: ImageKnifeOption;
|
||||||
@Watch('watchAnimatorOption') @State animatorOption: AnimatorOption = new AnimatorOption();
|
@State animatorOption: AnimatorOption = new AnimatorOption();
|
||||||
@State pixelMap: PixelMap | string | undefined = undefined
|
@State pixelMap: PixelMap | string | undefined = undefined
|
||||||
@State imageAnimator: Array<ImageFrameInfo> | undefined = undefined
|
@State imageAnimator: Array<ImageFrameInfo> | undefined = undefined
|
||||||
@State state: AnimationStatus = AnimationStatus.Running
|
|
||||||
@State iterations: number = -1
|
|
||||||
@State reverse: boolean = false
|
|
||||||
@State adaptiveWidth: Length = '100%'
|
@State adaptiveWidth: Length = '100%'
|
||||||
@State adaptiveHeight: Length = '100%'
|
@State adaptiveHeight: Length = '100%'
|
||||||
@State objectFit: ImageFit = ImageFit.Contain
|
@State objectFit: ImageFit = ImageFit.Contain
|
||||||
|
@ -64,9 +61,9 @@ export struct ImageKnifeAnimatorComponent {
|
||||||
.width(this.adaptiveWidth)
|
.width(this.adaptiveWidth)
|
||||||
.height(this.adaptiveHeight)
|
.height(this.adaptiveHeight)
|
||||||
.border(this.imageKnifeOption.border)
|
.border(this.imageKnifeOption.border)
|
||||||
.state(this.state)
|
.state(this.animatorOption.state == undefined ? AnimationStatus.Running : this.animatorOption.state)
|
||||||
.iterations(this.iterations)
|
.iterations(this.animatorOption.iterations == undefined ? -1 : this.animatorOption.iterations)
|
||||||
.reverse(this.reverse)
|
.reverse(this.animatorOption.reverse == undefined ? false : this.animatorOption.reverse)
|
||||||
.onSizeChange((oldValue:SizeOptions, newValue:SizeOptions) => {
|
.onSizeChange((oldValue:SizeOptions, newValue:SizeOptions) => {
|
||||||
this.currentWidth = newValue.width as number
|
this.currentWidth = newValue.width as number
|
||||||
this.currentHeight = newValue.height as number
|
this.currentHeight = newValue.height as number
|
||||||
|
@ -84,18 +81,6 @@ export struct ImageKnifeAnimatorComponent {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
watchAnimatorOption(){
|
|
||||||
if(this.animatorOption.state != undefined) {
|
|
||||||
this.state = this.animatorOption.state
|
|
||||||
}
|
|
||||||
if(this.animatorOption.iterations != undefined) {
|
|
||||||
this.iterations = this.animatorOption.iterations
|
|
||||||
}
|
|
||||||
if(this.animatorOption.reverse != undefined) {
|
|
||||||
this.reverse = this.animatorOption.reverse
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watchImageKnifeOption() {
|
watchImageKnifeOption() {
|
||||||
if (this.request !== undefined) {
|
if (this.request !== undefined) {
|
||||||
this.request.requestState = ImageKnifeRequestState.DESTROY
|
this.request.requestState = ImageKnifeRequestState.DESTROY
|
||||||
|
|
|
@ -176,6 +176,7 @@ export class FileUtils {
|
||||||
let length = stat.size;
|
let length = stat.size;
|
||||||
let buf = new ArrayBuffer(length);
|
let buf = new ArrayBuffer(length);
|
||||||
await fs.read(fd, buf);
|
await fs.read(fd, buf);
|
||||||
|
await fs.close(fd)
|
||||||
return buf
|
return buf
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let err: BusinessError = error as BusinessError;
|
let err: BusinessError = error as BusinessError;
|
||||||
|
|
Loading…
Reference in New Issue