Re: Capture screen shot to file
Jean-Philippe Leboeuf <[email protected]> Tue, 01 Aug 2006 11:51:35 +0200
| Newsgroups | gmane.comp.mozilla.jrex |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I am actualy working on a kind of "Common Browser API" (currently
integrating JRex and JDIC, but there are plans for Konqueror and others).
To take a screenshot, using the Robot class works for JDIC (IE & Mozilla).
As I said in my previous mails, I have problems compiling JRex with
MinGW, so I have not tested this way of doing with JRex, but maybe it
can work.
--------------------------------------------------------------------------------------------------------------------
try {
this.robot = new Robot();
} catch (AWTException awte) {
awte.printStackTrace();
}
JPanel toShot = webBrowserPanel.getWebBrowserCanvasPanel();
Rectangle rect = new Rectangle(toShot.getLocationOnScreen(),
toShot.getSize());
BufferedImage image = robot.createScreenCapture(rect);
try {
ImageIO.write(image, "png", new File("C:\\Documents and
Settings\\Jean-Philippe\\Bureau\\shot.png"));
} catch (IOException ioe) {
ioe.printStackTrace();
}
--------------------------------------------------------------------------------------------------------------------
If you want the complete canvas, you will have to scroll the page and
recompose the image (I will integrate this functionnality later).
The new Gecko engine (not the one actualy used in JRex) owns a complete
canvas API, it can generate a screenshot alone without the robot class.
In this case, JRex would have to be ported.
++jpl
Robert Campbell wrote:
> I looked in the archives, and there were two other posts about doing
> this since 2004, never any answers. So I'll try again.. what I'm
> trying to do is capture the rendered page to an image file. I don't
> actually have to display any UI at all.. I need to simply pass in a
> URL and output an image file. Does anyone have any idea how to go
> about doing this?
>
> It appears that maybe I could attached a windowCreated > onStateChange
> event that creates a Graphics object and passes it to paint() but I'm
> not sure how to put this all together. Is there any existing code for
> doing this?
>
> Thank you.
>
>------------------------------------------------------------------------
>
>_______________________________________________
>JRex mailing list
>[email protected]
>http://mozdev.org/mailman/listinfo/jrex
>
>
_______________________________________________
JRex mailing list
[email protected]
http://mozdev.org/mailman/listinfo/jrex