sorry for the delay on this. I have used VisAD in conjunction with servlets
but priorities changed inthe project, and I let the servlets be for a while.
The point is, I was generating images from a display - not a VisAD display,
but a JPanel which included a display and a few other panels - and it worked
sort of all right. I then tried to scale the whole thing down to a simple
(understandable) servlet and cannot reproduce what I did on other computer.
The relevant piece of code is this:
ServletOutputStream servOutStream = response.getOutputStream();
// set the content type so the browser will be able to interpret
response.setContentType( JPG_CONTENT_TYPE );
// this is the image
// but won't work...
//BufferedImage bufImage = (BufferedImage)display.getImage(true);
// then I tried this, copied from other code
java.awt.Component gp = (java.awt.Component) display.getComponent();
// check the sizes -> don't match!
Image image = (Image) gp.createImage(300,300);//gp.getWidth ()
Graphics g = image.getGraphics();
// do some painting to test -> it works!
BufferedImage bufImage = (BufferedImage)image;
// make a jpg out of it
JPEGEncodeParam jepar = JPEGCodec.getDefaultJPEGEncodeParam(bufImage);
jepar.setQuality( 1.0f, true);
JPEGImageEncoder jpege = JPEGCodec.createJPEGEncoder(servOutStream) ;
// and send it to the browser
Unfortunately display.getImage(true); doesn't work. Creating the image by
use of pure force doesn't work here, either. I cannot tell what's the
matter, but have heard in Java 1.4 there isn't such a problem (of having to
create off-line frame and etc...).
Sorry, this isn't much help... I got an example servlet ready to send, but
the most important part - creating the display - won't work.
Util.captureImage() only works when the display is visible.