Dear J2D enthusiastics... I'm a newbe here and yesterday downloaded the latest version of Java 1.4.1_01 to use the static class methods ImageIO.read() and ImageIO.write() to first read an image and give it out as a differently formatted file again:
File f = new File("pic1.jpg");
BufferedImage bi = ImageIO.read(f);
File outfile = new File("pic2.png");
ImageIO.write(bi, "png", outfile);
That works out properly as expected.
Now the problem arises:
I tried to get some simplified approach to mathematical funtion plots by using the
Plotlib Toolkit from Bernhard Bablok (www.bablokb.de). It really works fine to plot
something like the normal distribution or other funtions into a window on the screen.
I then modified the FktTest.java-file a little bit to enable it to give a .jpg or
.png-file from the displayed image.
BUT:
the following code fragment only gives a pic of the right size -but it only contains
uniform grey pixels and nothing from that I can see on the screen.....
frame1.getContentPane().add(t); // original code by Bernhard Bablok, adds contents
frame1.pack(); // original code by Bernhard Bablok
BufferedImage im2 = (BufferedImage)frame1.createImage(500,500); // my code
File outfile2 = new File("C:\\Java2D\\plotfile_CC25.png"); // my code
ImageIO.write(im2, "png", outfile2); // my code: only gray pixel file generated!
frame1.show(); // original code by Bernhard Bablok: works properly
My questions: how can I create a .png or .jpg file from a JFrame oder other complex
graphical "containers"? Is there a simple method to serialize the topically displayed
window(s) and then convert the stream into a BuffereredImage and then to feed it into
ImageIO.write()?
I also append the GraphTest.java file; it is the test file I really used.
nice Xmas and thank you in advance .... Sven Mielordt
****************
sender:
Sven Mielordt
Gro�beerenstra�e 81
D 10963 Berlin
Germany
Tel +49 30 2511999
[EMAIL PROTECTED]
*****************
______________________________________________________________________________
PREMIERE exklusiv bei WEB.DE: 3 Monate gratis + d-box-1 ab 1 Euro
Online solange der Vorrat reicht! http://premiere.web.de/?mc=999937&lp=2
GraphTest.java
Description: Binary data
