这是我的第一个问题。我创建了 WPF 应用程序,其中image control
源设置为随机图像的位图数组。它工作完美。该数组包含以下信息R,G,B
每个像素的顺序。
现在,我必须在 Mac 的 Cocoa 应用程序中做同样的事情,但我遇到了问题,因为我是第一次这样做。我创造了NSImageView
,将其暴露为outlet
并尝试设置Image
如下ViewDidLoad()
method:
IMW.Image = GetImage();
public static NSImage GetImage(){
NSData nsdata = NSData.FromArray(bbb.ToArray()); // the same array as in WPF app
NSBitmapImageRep nip = new NSBitmapImageRep(nsdata);
NSImage image = new NSImage(nsdata);
return image;
}
尝试运行应用程序时总是出现错误:
Could not initialize an instance of the type 'AppKit.NSBitmapImageRep':
the native 'initWithData:' method returned nil.
It is possible to ignore this condition by setting
MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false.
看起来字节数组有问题,但我不明白为什么它在 WPF 应用程序中有效。
非常感谢!
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)