Login Register






[VB.Net] Screencapture in 6 lines filter_list
Author
Message
[VB.Net] Screencapture in 6 lines #1
Code:
Dim rect As New Rectangle(Point.Empty, Screen.PrimaryScreen.Bounds.Size) 'Creating a rectangle of Screen's Size Dim bmp As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height) 'Creating a Bitmap of Screen's Size Dim g As Graphics = Graphics.FromImage(bmp) 'Creating Graphics from the Bitmap g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size) 'Copying the Screen pic.Image = bmp 'Using the bitmap in our PictureBox g.Dispose() 'Disposing our Graphics

You can use this to create a RemoteDesktop app, Magnifier, Screen Capture application, and many more. Smile
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: [VB.Net] Screencapture in 6 lines #2
nice i was going to post it Tongue

and for saving it you can:
Code:
pic.Image.Save("C:\1.bmp", Imaging.ImageFormat.Bmp)

another way but a weird one is ( i thought of this way Biggrin ):

Code:
Dim pb As New PictureBox SendKeys.Send("{PRTSC}") pb.Image = Clipboard.GetImage() pb.Image.Save("C:\1.png", Imaging.ImageFormat.PNG) Clipboard.Clear()
(This post was last modified: 03-30-2011, 11:32 AM by Skullmeat.)
Pierce the life fibers with your drill.

Reply

RE: [VB.Net] Screencapture in 6 lines #3
Do not save as BMP. Use either PNG or JPEG. Your program will thank you. :p
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: [VB.Net] Screencapture in 6 lines #4
You mean the size will be huge? Tongue
Pierce the life fibers with your drill.

Reply

RE: [VB.Net] Screencapture in 6 lines #5
Yeah.

There is also a way to assign quality to an image while saving.

EDIT: found

[link=http://www.vbforums.com/showthread.php?t=343063]save JPEG images with any quality[/link]
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: [VB.Net] Screencapture in 6 lines #6
wow cool! image codecs! never knew this was possible Tongue

PS: can you make a guide how to capture screen and save as .avi ( vid ) ?
(This post was last modified: 03-30-2011, 11:49 AM by Skullmeat.)
Pierce the life fibers with your drill.

Reply

RE: [VB.Net] Screencapture in 6 lines #7
There is a way, I have somewhere in my PC.
You can use VirtualDub if you just want to create a video from your frames.
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: [VB.Net] Screencapture in 6 lines #8
thank you coder you have helped us a lot. Smile

Reply

RE: [VB.Net] Screencapture in 6 lines #9
Thanks a bunch Smile You saved me a lot of googling Tongue
Staff will never ever ask you for your personal information.
We know everything about you anyway.

Reply

RE: [VB.Net] Screencapture in 6 lines #10
A simple tweak can be done in this to allow Cursor to show in your Screenshot.

Spoiler: Screenshot With Cursor
[altimg=http://i.imgur.com/chTsc.jpg]Screenshot with Cursor[/altimg]


Just after CopyFromScreen, add this line of code.
Code:
DefaultCursor.Draw(g, New Rectangle(MousePosition, DefaultCursor.Size))

The Cursor quality is bad because Draw is ignoring Alpha channel.
[Image: rytwG00.png]
Redcat Revolution!

Reply