如何将图片框中产生的渐变图像转换为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);
我有一个黑色的图片框。
答案 0 :(得分: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
对象中,以便更容易查看。