diff --git a/frameworks/innerkitsimpl/codec/src/image_source.cpp b/frameworks/innerkitsimpl/codec/src/image_source.cpp index 99fe4a84c4fd9c21bd7bc09d3b61aa83f8a8e0e5..c853ff3bc5387fccffbf68ddf5c73f5b31f0bf2f 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 8f8ba30007e0731f6f6be825312f8eabcc424559..d51d1e1af60b33514e600afe9de2fbccb13ef359 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 7debf06f24c10cff5a336a82611db57aa2514010..528afd72c2a1dbc33db189dc5f29934976234da8 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 {