|
-
Oct 28th, 2009, 08:14 PM
#1
Thread Starter
New Member
[RESOLVED] Save screenshot as jpeg
Hello, I'm using the below code to capture desktop screenshot, it is working but doesn’t encode the screenshot result in real jpeg, I came to know that from the huge size of the saved jpeg file around 5MB!!!
Can anyone please help in fixing this issue?
Code:
Dim ScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenGrab)
g.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)
screenGrab.Save("C:\Screenshot.jpeg")
-
Oct 28th, 2009, 08:23 PM
#2
Re: Save screenshot as jpeg
Well obviously its not going to work:
Code:
Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
You're creating a new Bitmap
I once heard a quote: "You can put a Tuxedo on a goat, but it's still a goat."
Basically, you can save a file as a jpeg, but if you create it as a bitmap, it's still a bitmap.
-
Oct 28th, 2009, 08:29 PM
#3
Re: Save screenshot as jpeg
The Save method is overloaded. You can specify the file format as well as the path. Let Intellisense guide you. Put the cursor at the end of that line and hit Backspace and Intellisense should popup and provide you with your options. If it doesn't then just hit Ctrl+Space.
-
Oct 28th, 2009, 09:09 PM
#4
Addicted Member
Re: Save screenshot as jpeg
Code:
Private Sub SaveImage()
Dim BMPname As String
Dim graph As Graphics = Nothing
Try
Dim bmp As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
graph = Graphics.FromImage(bmp)
graph.CopyFromScreen(0, 0, 0, 0, bmp.Size)
BMPname = "C:\Screenshot.jpeg"
bmp.Save(BMPname,System.Drawing.Imaging.ImageFormat.Jpeg)
Finally
graph.Dispose()
End Try
End Sub
-
Oct 29th, 2009, 04:39 AM
#5
Thread Starter
New Member
Re: [RESOLVED] Save screenshot as jpeg
Thank you Smartacus
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|