如何将一个索引像素格式的图像转换为32位图像? [英] How to convert an Indexed pixel format image to a 32-bit image?

查看:389
本文介绍了如何将一个索引像素格式的图像转换为32位图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我得到的对象使用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.

这篇关于如何将一个索引像素格式的图像转换为32位图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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