Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 我怎样才能用画上的内容重新画一个画框?_.net - Fatal编程技术网

.net 我怎样才能用画上的内容重新画一个画框?

.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

我有一个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.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