From 0563c1ffcf530a5d87bb1effa038dbf43b013c58 Mon Sep 17 00:00:00 2001 From: yangfan Date: Wed, 27 Mar 2024 11:02:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9xts=E5=8D=A1=E6=AD=BB?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangfan Change-Id: I995739203a88df823d2d87e6214449a39874e30d --- .../kits/js/common/image_source_napi.cpp | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/frameworks/kits/js/common/image_source_napi.cpp b/frameworks/kits/js/common/image_source_napi.cpp index 015808b21..75b579e10 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -580,7 +580,33 @@ STATIC_COMPLETE_FUNC(GetImageInfo) napi_value result = nullptr; auto context = static_cast(data); if (context->status == SUCCESS) { - napi_value result = GetImageInfoNapiValue(env, &(context->imageInfo), nullptr); + napi_create_object(env, &result); + + napi_value size = nullptr; + napi_create_object(env, &size); + + napi_value sizeWith = nullptr; + napi_create_int32(env, context->imageInfo.size.width, &sizeWith); + napi_set_named_property(env, size, "width", sizeWith); + + napi_value sizeHeight = nullptr; + napi_create_int32(env, context->imageInfo.size.height, &sizeHeight); + napi_set_named_property(env, size, "height", sizeHeight); + + napi_set_named_property(env, result, "size", size); + + napi_value pixelFormatValue = nullptr; + napi_create_int32(env, static_cast(context->imageInfo.pixelFormat), &pixelFormatValue); + napi_set_named_property(env, result, "pixelFormat", pixelFormatValue); + + napi_value colorSpaceValue = nullptr; + napi_create_int32(env, static_cast(context->imageInfo.colorSpace), &colorSpaceValue); + napi_set_named_property(env, result, "colorSpace", colorSpaceValue); + + napi_value alphaTypeValue = nullptr; + napi_create_int32(env, static_cast(context->imageInfo.alphaType), &alphaTypeValue); + napi_set_named_property(env, result, "alphaType", alphaTypeValue); + if (!IMG_IS_OK(status)) { context->status = ERROR; IMAGE_LOGE("napi_create_int32 failed!"); -- Gitee