transparent images using visad?

I am trying to use visad in a web app (Java servlets) to produce transparent png responses. I build the DisplayImplJ2D in OFFSCREEN mode. I serialize to png using the javax.imageio.ImageIO routines. For now, the only data is a UnionSet of points, representing a 'route'.

I cannot get the call to DisplayImplJ2D.getImage to produce a 'transparent' image. I have replaced all calls in VisADCanvas2D which build BufferedImage of type TYPE_INT_RGB with TYPE_INT_ARGB. Maybe this could be an options in future releases (??)

When I get the BufferedImage back from the call to DisplayImplJ2D.getImage(true), it claims to have given me an ARGB type of BufferedImage (using getType()) but when I view it I get a filled in background color.

If I replace the visad code in my servlet with this, I get a nice transparent image (via the ImageIO calls):

BufferedImage br = new BufferedImage( 500, 500, BufferedImage.TYPE_INT_ARGB );
                Graphics2D g = br.createGraphics();
                g.setBackground( new Color( 0, 0, 0, 0 ) );
                g.setColor( Color.RED );
                g.clearRect( 0, 0, 500, 500 );
                g.drawLine( 100, 100, 200, 200 );


So some Visad code must be doing some other operation(s) to 'ruin' the transparency of the composed BufferedImage ?? I have looked in VisADCanvasJ2D somewhat but nothing is jumping out at me.

I confess I am no expert in graphics nor graphics files.

BTW: The underlying approach here is to use Visad as a 'data/map server' which will produce one 'layer' of data in each image, e.g. a basemap or a route or some other plot. I am then using a web browser/Javascript's z ordering to compose the whole 'picture'. I have an app where the UI must be a browser, so i cannot go with a jnlp solution. If all goes well, I will write up the architecture and post here. As you can imagine, I am stuck w/out transparent images.

Any help gratefully appreciated

Stuart

==============================================================================
To unsubscribe visad, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================


  • 2006 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: