保存我的屏幕截图 [英] saving my screen shot

查看:55
本文介绍了保存我的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在通过编码来获取我的表单的打印屏幕,但问题是,它仅存储应用程序的开始路径,我想设置我想要的目标路径来存储该屏幕快照图像,我正在使用以下代码这个..

hi all i am taking print screen of my form throug coding but the problem is, its storing only the application start path, i want to set my desired destination path for storing that screen shot image, i am using the below coding for this ..

Dim path As String
      clear()
      ' Dim b As Bitmap = New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height, Imaging.PixelFormat.Format32bppArgb)
      Dim b As Bitmap = New Bitmap(Me.Width, Me.Height, Imaging.PixelFormat.Format32bppArgb)
      Dim gfx As Graphics = Graphics.FromImage(b)
      gfx.CopyFromScreen(My.Computer.Screen.Bounds.X, My.Computer.Screen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)
      path = "C:\Documents and Settings\Nano\My Documents\My Pictures"
      b.Save("my2.jpg", Imaging.ImageFormat.Jpeg)

      MsgBox("Screen Shot Taken Succecssfully", MsgBoxStyle.Information)



在此先谢谢您.



Thanks in advance.

推荐答案

try:
try:
Dim b As Bitmap = New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height, Imaging.PixelFormat.Format32bppArgb)
Dim gfx As Graphics = Graphics.FromImage(b)
gfx.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)

path = "C:\Documents and Settings\Nano\My Documents\My Pictures\my2.jpg"
b.Save(path, Imaging.ImageFormat.Jpeg)



您发布的代码已将图像与应用程序可执行文件保存在同一文件夹中.

或者,从Web使用此功能(只需提供路径名):



The code you posted has saved the image in the same folder as your applications executable.

Edited: Or, use this function from the web (just provide the path name):

Function ScreenToPicture(ByVal Location As String) As String
 
        Try
            Dim currentScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
            Dim ScreenToBitmap As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
            Dim gGraphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(ScreenToBitmap)
 
            gGraphics.CopyFromScreen(New Point(0, 0), New Point(0, 0), currentScreenSize)
            ScreenToBitmap.Save(Location)
 
            Return Location
 
        Catch ex As Exception
            Return ex.Message
        End Try
 
    End Function


这篇关于保存我的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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