我有一个图像,我只想在其中添加一些随机行。我对c#绘图功能不是很熟悉。
有没有什么简单的方法可以在已经存在的位图对象中添加4-7条不同长度的线条之间的不同位置?
发布于 2013-05-20 19:12:44
尝试如下所示:
Random rnd = new Random();
Graphics g = Graphics.FromImage(bitmap);
for (int i=0; i<n; i++) {
// calculate line start and end point here using the Random class:
int x0 = rnd.Next(0, bitmap.Width);
int y0 = rnd.Next(0, bitmap.Height);
int x1 = rnd.Next(0, bitmap.Width);
int y1 = rnd.Next(0, bitmap.Height);
g.DrawLine(Pens.White, x0, y0, x1, x1);
}https://stackoverflow.com/questions/16648176
复制相似问题