本文介绍了我有屏幕截图程序,我想在单击picturebox1(其中捕获的图片)时将其打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是项目的代码:-
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Enabled = True
Me.Opacity = 0
Dim bounds As Rectangle
Dim ss As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
ss = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
graph = Graphics.FromImage(ss)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
Me.PictureBox1.Image = (ss)
Me.Opacity = 100
Dim save As New SaveFileDialog()
Try
save.Title = "save file "
save.FileName = "takepic.jpg"
save.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif|PNG image|*.png"
If save.ShowDialog() = DialogResult.OK Then
PictureBox1.Image.Save(save.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
End If
Catch ex As Exception
End Try
End Sub
End Class
推荐答案
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Opacity = 0
Dim bounds As Rectangle
Dim ss As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
ss = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
graph = Graphics.FromImage(ss)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
Me.PictureBox1.Image = (ss)
Me.Opacity = 100
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim save As New SaveFileDialog()
save.Title = "save file "
save.FileName = "takepic.jpg"
save.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif|PNG image|*.png"
If save.ShowDialog() = DialogResult.OK Then
PictureBox1.Image.Save(save.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
End If
End Sub
End Class
这篇关于我有屏幕截图程序,我想在单击picturebox1(其中捕获的图片)时将其打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!