判断和处理imageSource.getImageInfo为空的场景,返回错误信息

Signed-off-by: madixin <madixin@huawei.com>
This commit is contained in:
madixin 2024-11-09 14:54:24 +08:00
parent f552f57713
commit 630b0df448
2 changed files with 21 additions and 4 deletions

View File

@ -1,5 +1,7 @@
## 3.2.0 ## 3.2.0
- PixelMap size exceeds the maximum value of memory cache and is not cached - Fix bug: PixelMap size exceeds the maximum value of memory cache and is not cached
- Dealing with exception scenarios where imageSource.getImageInfo return undefined
## 3.2.0-rc.2 ## 3.2.0-rc.2
- Added callback information for image loading - Added callback information for image loading
- Added the interface for obtaining the upper limit and size of the current cache and the number of images corresponding to the current cache - Added the interface for obtaining the upper limit and size of the current cache and the number of images corresponding to the current cache

View File

@ -123,7 +123,12 @@ export class ImageKnifeLoader {
return return
} }
let size = (await imageSource.getImageInfo()).size let imageInfoSync = imageSource.getImageInfoSync()
if (imageInfoSync == undefined){
ImageKnifeLoader.makeEmptyResult(request, "Fail to get image info of imageSource")
return
}
let size = imageInfoSync.size
callBackData.imageWidth = size.width; callBackData.imageWidth = size.width;
callBackData.imageHeight = size.height; callBackData.imageHeight = size.height;
try { try {
@ -194,7 +199,12 @@ export class ImageKnifeLoader {
return return
} }
let size = (await imageSource.getImageInfo()).size let imageInfoSync = imageSource.getImageInfoSync()
if (imageInfoSync == undefined){
ImageKnifeLoader.makeEmptyResult(request, "Fail to get image info of imageSource")
return
}
let size = imageInfoSync.size
let scale = size.height / size.width let scale = size.height / size.width
let hValue = Math.round(request.componentHeight); let hValue = Math.round(request.componentHeight);
let wValue = Math.round(request.componentWidth); let wValue = Math.round(request.componentWidth);
@ -265,7 +275,12 @@ export class ImageKnifeLoader {
} }
let frameCount = await imageSource.getFrameCount() let frameCount = await imageSource.getFrameCount()
let size = (await imageSource.getImageInfo()).size let imageInfoSync = imageSource.getImageInfoSync()
if (imageInfoSync == undefined){
ImageKnifeLoader.makeEmptyResult(request, "Fail to get image info of imageSource")
return
}
let size = imageInfoSync.size
callBackData.frameCount = frameCount; callBackData.frameCount = frameCount;
callBackData.imageWidth = size.width; callBackData.imageWidth = size.width;
callBackData.imageHeight = size.height; callBackData.imageHeight = size.height;