Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #2777
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!novia!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail |
|---|---|
| From | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
| Subject | Re: jpanel export as pbm |
| Message-ID | <7b52d0e6b89a3@uwe> (permalink) |
| X-Comment-To | comp.lang.java.gui |
| Newsgroups | comp.lang.java.gui |
| In-Reply-To | <473dc83a$0$24398$5fc3050@news.tiscali.nl> |
| References | <473dc83a$0$24398$5fc3050@news.tiscali.nl> |
| Content-Type | text/plain; charset=IBM437 |
| Content-Transfer-Encoding | 8bit |
| X-Gateway | time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] |
| Lines | 72 |
| Date | Wed, 27 Apr 2011 15:41:05 GMT |
| NNTP-Posting-Host | 96.60.20.240 |
| X-Complaints-To | news@tds.net |
| X-Trace | newsreading01.news.tds.net 1303918865 96.60.20.240 (Wed, 27 Apr 2011 10:41:05 CDT) |
| NNTP-Posting-Date | Wed, 27 Apr 2011 10:41:05 CDT |
| Organization | TDS.net |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.gui:2777 |
Show key headers only | View raw
To: comp.lang.java.gui
Bruintje Beer wrote:
..
>I have a question.
Do you? I don't see it. A question would usually be followed by
a question mark '?'. The question marks denotes a question. It
also helps the reader to quickly identify the question in usenet posts.
I encourage the use of one (approrpriately applied) question mark in
each post.
>...I have a JPanel with some custom drawings on it like
>rectangles, circles etc. Now I want
>to export The Jpanel as a PBM file.
Why PBM? I had to google to find that was some sort
of monochrome (ick) image format.
Why not save as PNG?
>...I have no idea how to do this.
>
>Maybe someone can point me to some url where I can read how to do it.
Here are two methods from the WebStartFrame I am developing.
They might get you started..
public static BufferedImage getScreenShot(
Component component) {
BufferedImage image = new BufferedImage(
component.getWidth(),
component.getHeight(),
BufferedImage.TYPE_INT_RGB
);
// call the Component's paint method, using
// the Graphics object of the image.
component.paint( image.getGraphics() );
return image;
}
public void saveScreenShot(BufferedImage image) {
getLogger().log(Level.FINEST, "Default saveScreenShot");
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// write the image as a PNG
ImageIO.write(
image,
"png",
baos);
byte[] bytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
saveFileDialog(null, null, bais, null);
} catch(Exception e) {
handleError(e);
}
}
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200711/1
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Find similar | Unroll thread
jpanel export as pbm file "Bruintje Beer" <bruintje.beer@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000 Re: jpanel export as pbm "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000
csiph-web