我有一个尺寸为 100x50 的图像,我想在中心画一个点 - 即 50x25。我该怎么做?
问问题
14723 次
4 回答
2
您可以使用setPixle()函数。
于 2012-08-14T06:27:31.120 回答
2
Graphics g = pictureBox1.CreateGraphics();
g.DrawEllipse(Pens.Black, new Rectangle(50, 25, 1, 1));
看这里保存图片
它不会在表单加载时使用,因此您应该在表单paint
事件中添加代码:
private void Form1_Paint(object sender, PaintEventArgs e)
{
Application.DoEvents();
Graphics g = pictureBox1.CreateGraphics();
g.DrawEllipse(Pens.DarkBlue, new Rectangle(120, 90, 1, 1));
}
于 2012-08-14T06:16:09.173 回答
2
Image img = pictureBox1.Image;
Graphics g = Graphics.FromImage(img);
g.DrawEllipse(Pens.DarkBlue, new Rectangle(50, 25, 1, 1));
g.DrawImage(img, new Point(0, 0));
img.Save("d:\\img.Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
于 2012-08-14T07:09:15.787 回答
0
试试这个其他问题:
Rectangle bounds = new Rectangle(10, 20, 50, 60);
Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen(Point.Empty,Point.Empty, bounds.Size);
bitmap.Save("d:\\img.Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
此代码将捕获具有边界矩形边界的屏幕。
于 2012-08-14T07:31:22.703 回答