From af4e92c9e789075a972f6b2ed9d4619475486126 Mon Sep 17 00:00:00 2001 From: huchao Date: Sun, 10 Aug 2025 17:35:13 +0800 Subject: [PATCH] modify getimgeinfo ishdr Signed-off-by: huchao --- frameworks/innerkitsimpl/codec/src/image_source.cpp | 1 + frameworks/kits/js/common/image_source_napi.cpp | 9 +++------ interfaces/innerkits/include/image_type.h | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/frameworks/innerkitsimpl/codec/src/image_source.cpp b/frameworks/innerkitsimpl/codec/src/image_source.cpp index 99fe4a84c..c853ff3bc 100644 --- a/frameworks/innerkitsimpl/codec/src/image_source.cpp +++ b/frameworks/innerkitsimpl/codec/src/image_source.cpp @@ -1624,6 +1624,7 @@ uint32_t ImageSource::GetImageInfo(uint32_t index, ImageInfo &imageInfo) CHECK_ERROR_RETURN_RET_LOG(cond, ERR_IMAGE_DECODE_FAILED, "[ImageSource]get the image size fail on get image info, width:%{public}d," "height:%{public}d.", info.size.width, info.size.height); + info.isHdr = IsHdrImage(); imageInfo = info; return SUCCESS; } diff --git a/frameworks/kits/js/common/image_source_napi.cpp b/frameworks/kits/js/common/image_source_napi.cpp index 8f8ba3000..d51d1e1af 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -1037,7 +1037,6 @@ STATIC_NAPI_VALUE_FUNC(GetImageInfo) { napi_value result = nullptr; auto imageInfo = static_cast(data); - auto rImageSource = static_cast(ptr); napi_create_object(env, &result); napi_value size = nullptr; @@ -1069,11 +1068,9 @@ STATIC_NAPI_VALUE_FUNC(GetImageInfo) &encodedFormatValue); napi_set_named_property(env, result, "mimeType", encodedFormatValue); - if (rImageSource != nullptr) { - napi_value isHdrValue = nullptr; - napi_get_boolean(env, rImageSource->IsHdrImage(), &isHdrValue); - napi_set_named_property(env, result, "isHdr", isHdrValue); - } + napi_value isHdrValue = nullptr; + napi_get_boolean(env, imageInfo->isHdr, &isHdrValue); + napi_set_named_property(env, result, "isHdr", isHdrValue); return result; } diff --git a/interfaces/innerkits/include/image_type.h b/interfaces/innerkits/include/image_type.h index 7debf06f2..528afd72c 100644 --- a/interfaces/innerkits/include/image_type.h +++ b/interfaces/innerkits/include/image_type.h @@ -224,6 +224,7 @@ struct ImageInfo { AlphaType alphaType = AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN; int32_t baseDensity = 0; std::string encodedFormat; + bool isHdr = false; }; struct YUVDataInfo { -- Gitee