我如何使用Visual Studio for Mac在C#中读取一个JPEG文件到内存中?
我的代码。
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。
要在应用程序的bundle之外加载图像(从Mac文件系统)。
NSImage image = new NSImage("/Users/person/Desktop/image.jpeg")
re: 在C#代码中使用图像 (Xamarin.Mac)