我有灰色的位图图像。
Image<Gray, byte> cannyImage = new Image<Gray, byte>(pathImg);
Bitmap drawImg = cannyImage.ToBitmap();
我想在此图像上绘制一些形状:
Graphics g = Graphics.FromImage(drawImg);
g.DrawLines(new Pen(Color.Purple), shapes[0].sample.pointsArray);
在代码的最后一行,我得到此错误:
无法从具有索引像素格式的图像创建Graphics对象。
知道如何在灰色位图图像上绘制彩色形状吗?
先感谢您!
最佳答案
转换为Bgr(RGB),然后尝试代码。
Image<Bgr, Byte> cannyBgr = cannyImage.Convert<Bgr, Byte>();
Bitmap drawImg = cannyBgr.ToBitmap();
关于.net - 如何在灰色位图图像上绘制彩色形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15989760/