【发布时间】:2014-02-13 01:17:58
【问题描述】:
如何将图片框中的阈值图像转换为 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));
}
错误是“无法从具有索引像素格式的图像创建图形对象。”
我需要你的帮助。
【问题讨论】:
-
错误是“异常未处理”
-
您需要更智能的代码才能知道如何构建只有 256 种颜色的调色板,并且仍然可以获得不错的结果。顺便说一句,今天毫无意义,这在 20 年前就不再重要了。有传言说 FreeImage 有可靠的转换器。
标签: c# image-processing