[Mono-list] Make a screenshot

Vincent Arnoux vincent.arnoux@rfo.atmel.com
Fri, 28 Jan 2005 10:31:45 +0100


Hello,
I am looking for a way to make a screenshot in C# without using an 
external application. I only found so far .NET specific method, but they 
look not to work with Mono.
Let me give you the Java code I would use to do so as an example :
        BufferedImage buf = null;
        BufferedImage bufFinal = null;
        Rectangle screenArea = new Rectangle(303, 0, 850, 900);
        Dimension screenshotFinalDimension = new Dimension(500, 500);

        try {
            buf = new Robot().createScreenCapture(screenArea);
        } catch (AWTException e) {
            e.printStackTrace();
        }
        bufFinal = new BufferedImage(screenshotFinalDimension.width, 
screenshotFinalDimension.height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = (Graphics2D) bufFinal.getGraphics();
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g.drawImage(buf, 0, 0, screenshotFinalDimension.width, 
screenshotFinalDimension.height, null);
        g.dispose();

        try {
            ImageIO.write(bufFinal, "jpeg", new File("myScreenshot));
        } catch (IOException e) {
            e.printStackTrace();
        }



Thanks,
Vincent