.net 我怎样才能用画上的内容重新画一个画框?
我有一个picturebox,可以获得类似以下内容的输出:.net 我怎样才能用画上的内容重新画一个画框?,.net,.net,我有一个picturebox,可以获得类似以下内容的输出: e = New PrintPageEventArgs(PictureBox1.CreateGraphics, New Rectangle(New Point(25, 25), New Size(New Point(825, 1075))), e.PageBounds, e.PageSettings) 'Draw box e.Graphics.DrawRectangle(Pens.Gray, 20, 30, e.PageBounds.W
e = New PrintPageEventArgs(PictureBox1.CreateGraphics, New Rectangle(New Point(25, 25), New Size(New Point(825, 1075))), e.PageBounds, e.PageSettings)
'Draw box
e.Graphics.DrawRectangle(Pens.Gray, 20, 30, e.PageBounds.Width - 100, e.PageBounds.Height - 130)
DrawnImage = PictureBox1.Image
我需要在绘画活动中更新它:
Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
PictureBox1.Image = DrawnImage
End Sub
问题是DrawnImage为NULL。如何捕获图像?我需要使用位图,而不是从picturebox创建图形对象 有关完整的说明,请参见此处:
Dim b As New Bitmap(PictureBox1.Width, PictureBox1.Height)
e = New PrintPageEventArgs(Graphics.GraphicsFromImage(b), New Rectangle(New Point(25, 25), New Size(New Point(825, 1075))), e.PageBounds, e.PageSettings)
'Draw box
e.Graphics.DrawRectangle(Pens.Gray, 20, 30, e.PageBounds.Width - 100, e.PageBounds.Height - 130)
PictureBox1.Image = b