在这里寻求帮助,我有一个名为 PB1 的透明图片框(使用紫红色作为透明度键),其中 PB1.Location.X = 145,PB1.Location Y = 7 和一个名为 btnTakePic 的按钮。代码如下:
Private Sub btnTakePic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTakePic.Click
Dim Bound As Rectangle
Dim Pic As Graphics
Dim screenshot As System.Drawing.Bitmap
Bound = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(PB1.Bounds.Width, PB1.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
Pic = Graphics.FromImage(screenshot)
Pic.CopyFromScreen(CInt(LocPBX.Text), CInt(LocPBY.Text), 0, 0, Bounds.Size, CopyPixelOperation.SourceCopy)
PB1.Image = screenshot
PB1.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
Private Sub Main_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LocationChanged
LocX.Text = Me.Location.X
LocY.Text = Me.Location.Y
LocPBX.Text = Val(PB1.Location.X) + Val(LocX.Text) + 3
LocPBY.Text = Val(PB1.Location.Y) + Val(LocY.Text + 25)
End Sub
现在的问题是:它生成的截图正是我想要的,但是当我点击 btnTakePic 时,图片将与旧图片重叠,我想从内存中删除旧图片截图并用新图片替换,怎么办那 ?