我有屏幕截图程序,我想在单击picturebox1(其中捕获的图片)时将其打开 [英] i have screen shot program and i want when click on the picturebox1 ( which the picture captured in it ) it open

查看:96
本文介绍了我有屏幕截图程序,我想在单击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

推荐答案

我认为这就是您所描述的:

I think that this is what you are describing:

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(其中捕获的图片)时将其打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆