如何将图像框中的解析图像转换为8bbp像素格式?我试过这段代码,但不起作用?
Bitmap orig = new Bitmap(thresholded);
Bitmap clone = new Bitmap(width , height , System.Drawing.Imaging.PixelFormat.Format8bppIndexed );
using (Graphics gr = Graphics.FromImage(clone))
{
gr.DrawImage(orig, new Rectangle(0, 0, width, height));
}错误是“不能从具有索引像素格式的图像创建Graphics对象”。
我需要你的帮助。
发布于 2014-02-12 17:17:58
一个快速的google给出了这个答案
索引图像是带有调色板的图像。GDI+不支持绘制索引图像。在非索引图像上绘制索引图像,然后在非索引图像上绘制文本:
Bitmap newBitmap = new Bitmap(bm.Width, bm.Height);
Graphics graphics = Graphics.FromImage(newBitmap);
graphics.DrawImage(bm, 0, 0);https://stackoverflow.com/questions/21734692
复制相似问题