From 95c948057b2ea73b25f018ea997aeb3f8c35f1a9 Mon Sep 17 00:00:00 2001 From: tandyyan Date: Mon, 24 Jun 2024 19:40:11 +0800 Subject: [PATCH] feat(ohos): c api - image mode fix --- .../renderer/native/src/components/image_view.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/framework/ohos/src/main/cpp/impl/renderer/native/src/components/image_view.cc b/framework/ohos/src/main/cpp/impl/renderer/native/src/components/image_view.cc index 0bd87ea5ea5..89cb18dfa58 100644 --- a/framework/ohos/src/main/cpp/impl/renderer/native/src/components/image_view.cc +++ b/framework/ohos/src/main/cpp/impl/renderer/native/src/components/image_view.cc @@ -55,8 +55,17 @@ bool ImageView::SetProp(const std::string &propKey, const HippyValue &propValue) } return true; } else if (propKey == "resizeMode") { - auto value = HRValueUtils::GetInt32(propValue); - const HRImageResizeMode mode = (HRImageResizeMode)value; + HRImageResizeMode mode = HRImageResizeMode::Contain; + auto value = HRValueUtils::GetString(propValue); + if (value == "center") { + mode = HRImageResizeMode::Center; + } else if (value == "contain") { + mode = HRImageResizeMode::Contain; + } else if (value == "cover") { + mode = HRImageResizeMode::Cover; + } else if (value == "stretch") { + mode = HRImageResizeMode::FitXY; + } GetLocalRootArkUINode().SetResizeMode(mode); return true; } else if (propKey == "defaultSource") {