diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/image.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/image.ts index c29b6af6a4c0db94ca9182109c0841b927a54ade..07f5c3fac3bf0aaaa1c60f6d8ff8bcf09c746ddd 100644 --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/image.ts +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/component/image.ts @@ -594,8 +594,6 @@ export interface ImageSourceSize { width: number; height: number; } -export interface ColorContent { -} export interface ImageCompleteEvent { width: number; height: number; @@ -820,18 +818,7 @@ export class ArkImageComponent extends ArkCommonMethodComponent implements Image } public fillColor(value: ResourceColor | undefined | ResourceColor | ColorContent | undefined): this { if (this.checkPriority("fillColor")) { - const value_type = runtimeType(value) - if ((RuntimeType.NUMBER == value_type) || (RuntimeType.NUMBER == value_type) || (RuntimeType.STRING == value_type) || (RuntimeType.OBJECT == value_type) || (RuntimeType.UNDEFINED == value_type)) { - const value_casted = value as (ResourceColor | undefined) - this.getPeer()?.fillColor0Attribute(value_casted) - return this - } - if ((RuntimeType.NUMBER == value_type) || (RuntimeType.NUMBER == value_type) || (RuntimeType.STRING == value_type) || (RuntimeType.OBJECT == value_type) || (RuntimeType.OBJECT == value_type) || (RuntimeType.UNDEFINED == value_type)) { - const value_casted = value as (ResourceColor | ColorContent | undefined) - this.getPeer()?.fillColor1Attribute(value_casted) - return this - } - throw new Error("Can not select appropriate overload") + hookSetImageFillColor(this.getPeer().getPeerPtr(), value) } return this } diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/component/image.ts b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/component/image.ts new file mode 100644 index 0000000000000000000000000000000000000000..61a77f04657b3bea1024f199a9f73dbbe583c28e --- /dev/null +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/src/handwritten/component/image.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class ColorContent { + constructor() {} + public static readonly ORIGIN: ColorContent = new ColorContent(); +} +function fillColor0Attribute(peer: KPointer, value: ResourceColor | undefined): void { + const thisSerializer: Serializer = Serializer.hold() + let value_type: int32 = RuntimeType.UNDEFINED + value_type = runtimeType(value) + thisSerializer.writeInt8(value_type as int32) + if ((RuntimeType.UNDEFINED) != (value_type)) { + const value_value = value! + let value_value_type: int32 = RuntimeType.UNDEFINED + value_value_type = runtimeType(value_value) + if (TypeChecker.isColor(value_value)) { + thisSerializer.writeInt8(0 as int32) + const value_value_0 = value_value as Color + thisSerializer.writeInt32(TypeChecker.Color_ToNumeric(value_value_0)) + } + else if (RuntimeType.NUMBER == value_value_type) { + thisSerializer.writeInt8(1 as int32) + const value_value_1 = value_value as number + thisSerializer.writeNumber(value_value_1) + } + else if (RuntimeType.STRING == value_value_type) { + thisSerializer.writeInt8(2 as int32) + const value_value_2 = value_value as string + thisSerializer.writeString(value_value_2) + } + else if (RuntimeType.OBJECT == value_value_type) { + thisSerializer.writeInt8(3 as int32) + const value_value_3 = value_value as Resource + thisSerializer.writeResource(value_value_3) + } + } + ArkUIGeneratedNativeModule._ImageAttribute_fillColor0(peer, thisSerializer.asBuffer(), thisSerializer.length()) + thisSerializer.release() +} +function fillColor1Attribute(peer: KPointer, value: ColorContent | undefined): void { + const thisSerializer: Serializer = Serializer.hold() + let value_type: int32 = RuntimeType.UNDEFINED + value_type = runtimeType(value) + thisSerializer.writeInt8(value_type as int32) + const value_value = value! + thisSerializer.writeInt8(1 as int32) + const value_value_1 = value_value as ColorContent + thisSerializer.writeColorContent(value_value_1) + ArkUIGeneratedNativeModule._ImageAttribute_fillColor1(peer, thisSerializer.asBuffer(), thisSerializer.length()) + thisSerializer.release() +} + +function hookSetImageFillColor(peer: KPointer, value: ResourceColor | undefined | ResourceColor | ColorContent | undefined): void { + if (value instanceof ColorContent) { + const value_casted = value as ColorContent + fillColor1Attribute(peer, value_casted) + } else { + const value_casted = value as (ResourceColor | undefined) + fillColor0Attribute(peer, value_casted) + } +} diff --git a/frameworks/core/interfaces/native/implementation/image_modifier.cpp b/frameworks/core/interfaces/native/implementation/image_modifier.cpp index 4241b0ad8bf67fbaf91db1c5221a8c8734d8fecd..fcea70de448bc14e210d138ad82d122b4c898715 100644 --- a/frameworks/core/interfaces/native/implementation/image_modifier.cpp +++ b/frameworks/core/interfaces/native/implementation/image_modifier.cpp @@ -195,8 +195,7 @@ void FillColor1Impl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - //auto convValue = value ? Converter::OptConvert(*value) : std::nullopt; - //ImageModelNG::SetFillColor1(frameNode, convValue); + ImageModelNG::ResetImageFill(frameNode); } void ObjectFitImpl(Ark_NativePointer node, const Opt_ImageFit* value)