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

发布于 2024-10-11 21:18:14 字数 495 浏览 1 评论 0原文

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

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 文件都会发生这种情况;就这个。
alt text

在 Photo Shop 中重新保存并不能解决这个问题,除非我切换到 8bpp。我需要安装什么东西来支持这个“特殊”png 文件吗?在 Windows 上运行良好。

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");

I get the following error

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

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

alt text

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

墟烟 2024-10-18 21:18:14

我尝试在 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)  

错误

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

似乎与您在 Mac 上使用的具有相同的性质。快速谷歌搜索没有返回任何有关如何修复它的信息。我的建议是尝试使用 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 上没有导致错误。

希望这有帮助,问候

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)  

Error

PNG images with 48bpp aren't supported
by libgdiplus

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;

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

hope this helps, regards

凉薄对峙 2024-10-18 21:18:14

您是否检查过是否有任何 MacOS X 应用程序可以查看图像(也许使用 libpng)?

Have you checked to see if any MacOS X application can view the image (maybe using libpng)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文