![]() |
|
[VB.Net] Screencapture in 6 lines - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.li/Forum-Visual-Basic-NET-Framework) +--- Thread: [VB.Net] Screencapture in 6 lines (/Thread-VB-Net-Screencapture-in-6-lines) Pages:
1
2
|
[VB.Net] Screencapture in 6 lines - Coder-san - 03-30-2011 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 GraphicsYou can use this to create a RemoteDesktop app, Magnifier, Screen Capture application, and many more.
RE: [VB.Net] Screencapture in 6 lines - 1234hotmaster - 03-30-2011 nice i was going to post it ![]() 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 ):Code: Dim pb As New PictureBox
SendKeys.Send("{PRTSC}")
pb.Image = Clipboard.GetImage()
pb.Image.Save("C:\1.png", Imaging.ImageFormat.PNG)
Clipboard.Clear()RE: [VB.Net] Screencapture in 6 lines - Coder-san - 03-30-2011 Do not save as BMP. Use either PNG or JPEG. Your program will thank you. :p RE: [VB.Net] Screencapture in 6 lines - 1234hotmaster - 03-30-2011 You mean the size will be huge?
RE: [VB.Net] Screencapture in 6 lines - Coder-san - 03-30-2011 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] RE: [VB.Net] Screencapture in 6 lines - 1234hotmaster - 03-30-2011 wow cool! image codecs! never knew this was possible ![]() PS: can you make a guide how to capture screen and save as .avi ( vid ) ? RE: [VB.Net] Screencapture in 6 lines - Coder-san - 03-30-2011 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. RE: [VB.Net] Screencapture in 6 lines - darkscorpion - 03-30-2011 thank you coder you have helped us a lot.
RE: [VB.Net] Screencapture in 6 lines - 1llusion - 03-30-2011 Thanks a bunch You saved me a lot of googling
RE: [VB.Net] Screencapture in 6 lines - Coder-san - 05-10-2011 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. |