繁体   English   中英

尝试在 Visual Studio for Mac 中读取 C# 中的 JPEG 图像时出现 System.PlatformNotSupportedException

[英]System.PlatformNotSupportedException when trying to read a JPEG image in C# in Visual Studio for Mac

如何使用 Visual Studio for Mac 将 JPEG 文件读入 C# 中的 memory?

我的代码:

using AppKit;
using Foundation;

namespace TouristFree
{
    [Register("AppDelegate")]
    public class AppDelegate : NSApplicationDelegate
    {
        public AppDelegate()
        {
        }

        public override void DidFinishLaunching(NSNotification notification)
        {
            var filename = "/Users/person/Desktop/image.jpeg";
            var image = System.Drawing.Image.FromFile(filename);   // <— error here
        }
    }
}

引发 System.PlatformNotSupportedException。

要加载应用程序包之外的图像(从 Mac 文件系统):

NSImage image = new NSImage("/Users/person/Desktop/image.jpeg")

回复: 在 C# 代码 (Xamarin.Mac) 中使用图像

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM