| | |
Using CopyFromScreen
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2008
Posts: 27
Reputation:
Solved Threads: 0
Can someone please explain to me how to use CopyFromScreen. I'm trying to cut out a piece of the screenshot and then convert to tiff using the encoder tiffbitmapencoder. This will later be passed on to the OCR MODI function to get the text from the image. However, as always, I have no clue as to what I am doing. I looked on the msdn site and am left in confusion as to what the parameters actually mean. (http://msdn2.microsoft.com/en-us/library/fw1kt6f9.aspx). Im guessing the coordinates of the source rectangle mean the bottom right corner and destination means top left corner. I found some sample code on the internet (forget where) and it looks like this to take the screenshot:
Is it even possible to use this to get a portion of the screenimage? My best guess as of now is it would look like this:
gfxScreenshot.CopyFromScreen(bottomrightX,bottomrightY,topleftX,topleftY,SIZE. Copy...)
SIZE would be simply the BPMIMAGE.Size where BMPIMAGE is the portion I want to cut out. If I've got this all wrong could someone please explain how to do this properly? I know one method of doing it which is by copying pixel for pixel the image but im hoping there is a more direct method of doing this. As well, if you could give a few pointers on converting to tiff if you've got any. I just need to be able to pass this to MODI and thats it so nothing too crazy is needed.
Thanks in advance.
C# Syntax (Toggle Plain Text)
private static Bitmap bmpScreenshot; private static Graphics gfxScreenshot; bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb); gfxScreenshot = Graphics.FromImage(bmpScreenshot); gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
Is it even possible to use this to get a portion of the screenimage? My best guess as of now is it would look like this:
gfxScreenshot.CopyFromScreen(bottomrightX,bottomrightY,topleftX,topleftY,SIZE. Copy...)
SIZE would be simply the BPMIMAGE.Size where BMPIMAGE is the portion I want to cut out. If I've got this all wrong could someone please explain how to do this properly? I know one method of doing it which is by copying pixel for pixel the image but im hoping there is a more direct method of doing this. As well, if you could give a few pointers on converting to tiff if you've got any. I just need to be able to pass this to MODI and thats it so nothing too crazy is needed.
Thanks in advance.
Last edited by WolfPack; Mar 25th, 2008 at 11:33 am. Reason: Added code tags. Use them when you post code.
![]() |
Similar Threads
- Simple Text Recognition (C#)
- Capture and save vb.NET form (VB.NET)
- Screen Grab a Hidden Fom (VB.NET)
Other Threads in the C# Forum
- Previous Thread: i need a code for open my wndows accont
- Next Thread: how to add watermark in image
Views: 3651 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button c# chat check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption event excel file files form format forms ftp function gdi+ http httpwebrequest image index input install java label list listbox listener login math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





