我的 class 中的图像可以使用什么类型

What type can I use for an Image in my class

我在 C# 中有以下 class:

class User
{
  string ID { get; set; }
  string Name { get; set; }
  Image Avatar { get; set; }
}

Image 类型在 Xamarin.forms 和 System.Drawing 中不可用,那么正确的类型是什么?

编辑: 图像将本地存储在设备的文件系统上或在线存储在 AWS S3 存储上。

编辑 2: class 包含在 .net standard 2 class 库中,我在 [=] 中将其用作模型27=] 应用程序。因此我不能在库中使用 Xamarin.Forms.Image.

基于Documentation

System.Drawing is not supported in the Unified API for the Xamarin.Mac .NET 4.5 or Mobile frameworks. System.Drawing support can be added to iOS and OS X using the sysdrawing-coregraphics library.

也引用自 Cheesebaron here:

If you look at http://docs.xamarin.com/guides/android/advanced_topics/assemblies you will see that System.Drawing is not a part of the Assemblies shipped with Xamarin.Android, the same goes for Xamarin.iOS.

You will need to use the Android counterparts to filter images.

由于@S.Akbari 的 System.Drawing 不是 Xamarin.AndroidXamarin.iOS 的一部分。通常在 Xamarin.Forms 应用程序中,您应该使用 Xamarin.Forms.Image 对象来显示来自设备或来自 url 来源的图像。

可以找到文档 here.

试试 Splat - 它有 cross-platform image class. Combine it with Akavache 缓存图像,瞧。

我决定走另一条路 - byte[],因为 Xamarin.Forms.Image 有一个从流加载图像的方法:

ImageSource.FromStream(() => new MemoryStream(imageByteArray));

为什么我没有选择 Splat?它看起来很有前途,但我有一些反对外部依赖的东西,解决方案似乎很重,特别是考虑到它只是针对模型。