Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
i want capture picture from screen when user click on button
please F1 F1 F1 F1 F1 F1 F1

i see code and example in this site
but this code very complex and i,m confuded
Posted

1 solution

Try:
using (Bitmap b = new Bitmap(requiredWidth, requiredHeight))
    {
    using (Graphics g = Graphics.FromImage(b))
        {
        g.CopyFromScreen(sourcePoint, new Point(0,0), new Size(requiredWidth, requiredHeight));
        }
    b.Save(filePath, ImageFormat.Bmp);
    }


[edit]Forgot a closing brace, wrong name of object in Save - OriginalGriff[/edit]
 
Share this answer
 
v2
Comments
jiji2663 21-Jun-11 3:51am    
what's sourcePoint???
OriginalGriff 21-Jun-11 3:58am    
As the name implies: it is the point at which you want to start capturing from the source. Since I don't know where you want to start, I didn't put a point in...
For the top left hand corner of the screen, use:
Point sourcePoint = new Point(0,0);
jiji2663 21-Jun-11 4:02am    
i want get picture from desktop(full screen)
OriginalGriff 21-Jun-11 4:12am    
Then set sourcePoint to the TLHC, and requiredWidth and requiredHeight to the screen width and height...
Sergey Alexandrovich Kryukov 21-Jun-11 15:39pm    
Yes, this is the solution, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900