如何使用 C# 在 Tizen 手表中使用 Skiasharp 加载图像

How to load Image using Skiasharp in Tizen watch using C#

我正在使用 C# Xamarin 和 SkiaSharp 从资源文件夹中渲染图像。但是我无法获得正确的图像位置。

运行项目时我在哪里可以找到这张图片?我尝试寻找但没有结果:

您可以使用 DirectoryInfo 获取资源目录路径

https://samsung.github.io/TizenFX/API4/api/Tizen.Applications.DirectoryInfo.html#Tizen_Applications_DirectoryInfo_Resource

这里有一个例子说明如何使用

https://github.com/xamarin/Xamarin.Forms/blob/b59bb767a4367240983e93ab8e1a9a050dfea23b/Xamarin.Forms.Platform.Tizen/ResourcePath.cs#L27-L30

谢谢@Seungkenun Le。根据他的评论,我编写了一个简单的函数来获取 Xamarin 的 Tizen Watch 中的资源路径:

    /// <summary>
    /// Gets the resource path.
    /// </summary>
    /// <returns></returns>
    internal static string GetResourcePath()
    {
        Tizen.Applications.Application app = Tizen.Applications.Application.Current;
        if (app != null)
        {
            string resourcePath = app.DirectoryInfo.Resource;
            if (Directory.Exists(resourcePath))
            {
                return resourcePath;
            }
        }

        return string.Empty;
    }