无法将位图对象分配给从编码器返回的 QR 码图像



我安装了Xamarin工作室并尝试使用System.Drawing框架工作,但它不起作用。我想要这个框架的原因是能够定义一个位图对象。此位图对象分配给 QR 码图像。谁能帮助我如何将图像分配给位图,因为我不能在 xamarin studio 框架中使用位图。

我想做的是:

       //create a qr code
QRCodeEncoder encoder = new QRCodeEncoder();
  // Assign a bitmap image to the encoder since the encoder.encode returns bitmap image
    Bitmap img = encoder.Encode("http://www.monkeywow.com");
  // save the image in to images folder
   img.save("www.monkeywow.com/images/imp.jpg", ImageFormat.jpg);

问题是我不能使用Bitmap img,因为我无法将System.Drawing导入Xamarin。我试过了,但没有奏效。由于编码器返回位图,我不知道如何获取图像,以便我可以将其保存在我想要的任何位置。

要在屏幕上显示图像,请使用 UIImage。 若要使用低级位图,请使用 CoreImage 框架。

http://docs.xamarin.com/guides/ios/application_fundamentals/working_with_images/

http://docs.xamarin.com/recipes/ios/media/coreimage/

Xamarin.iOS 包含一些System.Drawing类型,例如 Rectangle[F]Point[F]Size[F],内部monotouch.dll,以简化(跨平台)项目之间的代码共享。

但是,System.Drawing.dll程序集本身不是 Xamarin.iOS 附带的移动配置文件的一部分。

就像@Jason提到的,有几种原生的方法可以在iOS上制作图形(OpenGL将是另一种)。

另一种选择是使用 https://github.com/mono/sysdrawing-coregraphics 的代码,该代码在CoreGraphics之上提供了部分System.Drawing API。

最新更新