언어 설정

Menu
Sites
Language
Changing ElmSharp.Image.Color with Xamarin Forms

I'm trying to figure out how to tint an image using Xamarin Forms' Image control. I've setup a custom ImageRenderer, linking it to the Image clasy by exporting the renderer attribute using :

 

[assembly: ExportRenderer(typeof(VImage), typeof(VImageRenderer))]
namespace TizenWatchfaceTest
{
    public class VImageRenderer : ImageRenderer
	{
		public static void Init()
		{
		}

		protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
		{
			SetTint();

			base.OnElementChanged(e);
		}

		protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
		{
			if (e.PropertyName == VImage.TintColorProperty.PropertyName || e.PropertyName == VImage.SourceProperty.PropertyName)
				SetTint();

			base.OnElementPropertyChanged(sender, e);
		}

		void SetTint()
		{
			if (Control == null || Element == null)
				return;

			VImage vi = Element as VImage;

			Control.Color = vi.TintColor.ToNative();
		}
	}
}

 

VImage just extends Xamarin.Forms.Image, adding a bindable property for the tint color. I can't tell at the moment if this approach is supported with Tizen.Net or if ElmSharp.Image.Color doesn't work the way I think it does. The result right now on my watch is no tinting at all.

 

Is there a better approach to tint an image with Tizen.Net? I initially played with setting BackgroundColor in Xamarin.Forms.Image, but if you have any transparent pixels in your image, they show up colored (which is not the behavior I want).

Responses

1 댓글
Tizen .NET

Hi thank you for reaching us.

It seems `SetBlendColor()` is what you are looking for. Please refer the following and see if it works for you.

https://docs.microsoft.com/ko-kr/dotnet/api/xamarin.forms.platformconfiguration.tizenspecific.image.setblendcolor?view=xamarin-forms

Xamarin.Forms.PlatformConfiguration.TizenSpecific.Image.SetBlendColor(img, Color.Red);

Thanks.