在C#中无法加载PNG Mac OSX上运行的单 [英] Cannot load PNG in C# on Mac OSX running Mono

查看:683
本文介绍了在C#中无法加载PNG Mac OSX上运行的单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In C#, I'm trying to load a png file on Mac OSX using the latest Mono

using System.Drawing;
Bitmap bmp = new Bitmap("test.png");

我收到以下错误

Either the image format is unknown or you don't have the required libraries to decode this format [GDI+ status: UnknownImageFormat]

它并不适用于所有PNG文件发生;仅这一个。
结果

It doesn't happen with all png files; just this one.

在照相馆重新保存不能解决问题,除非我切换到8bpp。有什么我需要安装支持这种特殊的PNG文件?在Windows上运行正常。

Resaving in photo shop doesn't fix it unless I switch to 8bpp. Is there something I need to install to support this "special" png file? Works fine on windows.

推荐答案

我试过装上我的Ubuntu与单这个文件,并得到了以下异常:

I've tried loading this file with mono on my ubuntu and got the following exception:

** (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)  

错误

与48bpp PNG图像不支持
  通过libgdiplus

PNG images with 48bpp aren't supported by libgdiplus

似乎是同样的性质,你在你的Mac具有之一。快速谷歌搜索没有返回就如何解决它的任何信息。我的建议是尝试使用 Gdk.Pixbuf 类:

seem to be of the same nature as the one you're having on your mac. Quick google search didn't return any info on how to fix it. My suggestion is try to open it with Gdk.Pixbuf class:

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

这一呼吁并没有在我的Ubuntu导致错误。

this call didn't result an error on my ubuntu.

希望这可以帮助,至于

这篇关于在C#中无法加载PNG Mac OSX上运行的单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆