Using CopyFromScreen

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 27
Reputation: Barbarrosa is an unknown quantity at this point 
Solved Threads: 0
Barbarrosa Barbarrosa is offline Offline
Light Poster

Using CopyFromScreen

 
0
  #1
Mar 24th, 2008
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:

  1. private static Bitmap bmpScreenshot;
  2. private static Graphics gfxScreenshot;
  3.  
  4. bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb); gfxScreenshot = Graphics.FromImage(bmpScreenshot);
  5. 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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 3651 | Replies: 0
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC