【问题标题】:How to convert resulted thresolded image in picturebox to 8bbp pixel format如何将图片框中的结果阈值图像转换为 8bbp 像素格式
【发布时间】: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


【解决方案1】:

一个快速的谷歌产生了这个答案

http://social.msdn.microsoft.com/Forums/vstudio/en-US/edd45c87-366c-4af8-a6fe-8ba9b1ffb002/a-graphics-object-cannot-be-created-from-an-image-that-has-an-indexed-pixel-format?forum=csharpgeneral

索引图像是带有调色板的图像。 GDI+ 不支持绘制到索引图像。在非索引图像上绘制索引图像,然后在非索引图像上绘制文本:

  Bitmap newBitmap = new Bitmap(bm.Width, bm.Height);
  Graphics graphics = Graphics.FromImage(newBitmap);
  graphics.DrawImage(bm, 0, 0);

【讨论】:

  • 问题是如何将picturebox中的结果图片转换为8bpp?
猜你喜欢
  • 2014-03-11
  • 1970-01-01
  • 1970-01-01
  • 2013-06-16
  • 2020-02-29
  • 2010-09-21
  • 2012-07-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多