0
我有這樣的代碼:如何在新的位圖上繪製已知的矩形大小?
Bitmap newbmp = new Bitmap(512, 512);
foreach (Point s in CommonList)
{
w.WriteLine("The following points are the same" + s);
newbmp.SetPixel(s.X, s.Y, Color.Red);
}
w.Close();
newbmp.Save(@"c:\newbmp\newbmp.bmp", ImageFormat.Bmp);
newbmp.Dispose();
的代碼是不是在一個繪畫事件。
然後,我有一個pictureBox1的Paint事件:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if (cloudPoints != null)
{
if (DrawIt)
{
e.Graphics.DrawRectangle(pen, rect);
pointsAffected = cloudPoints.Where(pt => rect.Contains(pt));
CloudEnteringAlert.pointtocolorinrectangle = pointsAffected.ToList();
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height, PixelFormat.Format32bppArgb);
CloudEnteringAlert.Paint(e.Graphics, 1, 200, bmp);
}
}
}
Paint事件我畫一個矩形。變量rect。
我想在newbmp上繪製矩形矩形。保存newbmp以在他身上繪製這個矩形。
如何在newbmp上繪製矩形?
您應該創建一個圖形對象:圖形G = Graphics.FromImage(newbmp)){在這裏使用所有的圖形命令!} – TaW 2015-01-31 20:29:56