2014-02-12 43 views
0

如何将图像框中的结果thresolded图像转换为8bbp像素格式?我试过这段代码,但它不起作用?转换为8bbp像素格式

Bitmap orig = new Bitmap(thresholded); 
      Bitmap clone = new Bitmap(width , height , System.Drawing.Imaging.PixelFormat.Format8bppIndexed); 

      Graphics graphics = Graphics.FromImage(orig); 
      graphics.DrawImage(clone, 0, 0); 

我得到一个黑色的picturebox。

回答

1

试试这个:

Point originPoint = new Point(0,0); 
Rectangle rect = new Rectangle(originPoint, pictureBox.Image.Size); 
Bitmap bitImage = (Bitmap)pictureBox.Image; 
Bitmap formattedImage = bitImage.Clone(rect, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); 
pictureBox.Image = formattedImage; 

formmattedImage对象包含你在找什么,我把它放回System.Windows.Forms.PictureBox对象我有我的形式只是为了使其更容易看到。