diff --git a/CHANGELOG.md b/CHANGELOG.md index b3ecc5a..dcad63b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 3.0.0-rc.7 +- 修复成功回调获取不到宽高 + ## 3.0.0-rc.6 - 支持多种组合变换 - 支持全局配置是否在子线程请求加载图片,默认在子线程 diff --git a/entry/src/main/ets/pages/LoadStatePage.ets b/entry/src/main/ets/pages/LoadStatePage.ets index 0f7c2a1..f5484b1 100644 --- a/entry/src/main/ets/pages/LoadStatePage.ets +++ b/entry/src/main/ets/pages/LoadStatePage.ets @@ -36,7 +36,8 @@ struct LoadStatePage { }, border: { radius: 50 } } - + @State currentWidth: number = 200 + @State currentHeight: number = 200 build() { Column() { Text('测试失败场景请先关闭网络,并保证本地没有此网络图片的缓存') @@ -57,8 +58,10 @@ struct LoadStatePage { onLoadFailed: (err) => { console.error("Load Failed Reason: " + err + " cost " + (new Date().getTime() - this.starTime) + " milliseconds"); }, - onLoadSuccess: (data) => { + onLoadSuccess: (data,width,height) => { console.info("Load Successful: cost " + (new Date().getTime() - this.starTime) + " milliseconds"); + this.currentWidth = width! + this.currentHeight = height! return data; }, }, @@ -68,7 +71,7 @@ struct LoadStatePage { } .margin({ top: 20 }) - ImageKnifeComponent({ imageKnifeOption: this.ImageKnifeOption }).height(200).width(200) + ImageKnifeComponent({ imageKnifeOption: this.ImageKnifeOption }).height(this.currentHeight).width(this.currentWidth) .margin({ top: 20 }) } diff --git a/library/oh-package.json5 b/library/oh-package.json5 index 81e22b2..a584ba0 100644 --- a/library/oh-package.json5 +++ b/library/oh-package.json5 @@ -14,7 +14,7 @@ "main": "index.ets", "repository": "https://gitee.com/openharmony-tpc/ImageKnife", "type": "module", - "version": "3.0.0-rc.6", + "version": "3.0.0-rc.7", "dependencies": { "@ohos/gpu_transform": "^1.0.2" }, diff --git a/library/src/main/ets/ImageKnifeDispatcher.ets b/library/src/main/ets/ImageKnifeDispatcher.ets index c3682bf..9eb9609 100644 --- a/library/src/main/ets/ImageKnifeDispatcher.ets +++ b/library/src/main/ets/ImageKnifeDispatcher.ets @@ -267,8 +267,8 @@ export class ImageKnifeDispatcher { let ImageKnifeData: ImageKnifeData = { source: pixelmap!, - imageWidth: 0, - imageHeight: 0 + imageWidth: requestJobResult.size == undefined ? 0 : requestJobResult.size.width, + imageHeight: requestJobResult.size == undefined ? 0 : requestJobResult.size.height }; // 保存内存缓存 @@ -303,7 +303,7 @@ export class ImageKnifeDispatcher { if (requestWithSource.request.imageKnifeOption.onLoadListener && requestWithSource.request.imageKnifeOption.onLoadListener.onLoadSuccess) { // 回调请求成功 - requestWithSource.request.imageKnifeOption.onLoadListener.onLoadSuccess(ImageKnifeData.source); + requestWithSource.request.imageKnifeOption.onLoadListener.onLoadSuccess(ImageKnifeData.source,ImageKnifeData.imageWidth,ImageKnifeData.imageHeight); LogUtil.log("ImageKnife_DataTime_getAndShowImage_onLoadSuccess:"+currentRequest.imageKnifeOption.loadSrc) } } else if (requestWithSource.source == ImageKnifeRequestSource.ERROR_HOLDER) {