如何将一个索引像素格式的图像转换为32位图像?图像、转换为、如何将、像素

由网友(じ無情De葬暧〃)分享简介:我有我得到的对象使用Graphics.FromImage(图像)的图像,并尝试加载到一个图形,但是这将引发异常,如果图像有一个索引像素格式。I have an image that I get and attempt to load into a graphics object using Graphics.From...

我有我得到的对象使用Graphics.FromImage(图像)的图像,并尝试加载到一个图形,但是这将引发异常,如果图像有一个索引像素格式。

I have an image that I get and attempt to load into a graphics object using Graphics.FromImage(image), however this throws an exception if the image has an indexed pixel format.

有没有办法安全地转换成索引图像?

Is there a way to safely convert an indexed image?

更新:感谢乔的小费只是绘制旧形象在新的,而不是我试图将其转换。这使得有很大的意义。

Update: Thanks to Joe for the tip to just draw the old image over the new one, instead I was trying to convert it. This makes a lot of sense.

推荐答案

一个简单的方法是创建一个同样大小的新形象(有32位像素格式)。然后创建的是的图形物体图像,绘制原在它的上面。

One easy way is to create a new image of the same size (with a 32-bit pixel format). Then create a graphics object for that image and draw the original on top of it.

阅读全文

相关推荐

最新文章