在运行Mono的Mac OSX上无法在C#中加载PNG

mil*_*lus 1 c# macos mono png bitmap

在C#中,我正在尝试使用最新的Mono在Mac OSX上加载png文件

using System.Drawing;
Bitmap bmp = new Bitmap("test.png");
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

Either the image format is unknown or you don't have the required libraries to decode this format [GDI+ status: UnknownImageFormat]
Run Code Online (Sandbox Code Playgroud)

所有png文件都不会发生这种情况; 就是这个.
替代文字

除非我切换到8bpp,否则在照相馆重新开始不会修复它.我需要安装什么来支持这个"特殊"的png文件吗?在窗户上工作正常.

ser*_*nko 5

我已经尝试在我的ubuntu上使用mono加载此文件并获得以下异常:

** (mono_load_bitmap:3490): WARNING **: PNG images with 48bpp aren't supported by libgdiplus.
Either the image format is unknown or you don't have the required libraries to decode this format [GDI+ status: UnknownImageFormat]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (System.String filename, Boolean useIcm) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (System.String filename) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (string)  
Run Code Online (Sandbox Code Playgroud)

错误

libgdiplus不支持48bpp的PNG图像

似乎与你在Mac上的那个性质相同.快速谷歌搜索没有返回任何有关如何解决它的信息.我的建议是尝试用Gdk.Pixbuf类打开它:

Gdk.Pixbuf pic = new Gdk.Pixbuf("test.png");
// shows pixbuf in the Gtk.Image widget
Gtk.Image image = new Gtk.Image();      
image.Pixbuf = pic;
Run Code Online (Sandbox Code Playgroud)

这个调用没有导致我的ubuntu出错.

希望这有帮助,问候