Java Mapscript - converting edu.umn.gis.mapscript.imageObj into a java.awt.image

James Dracup jamesdracup at HOTMAIL.COM
Mon Apr 10 07:45:04 EDT 2006


Hi,

I am working with java/mapscript and am trying to convert an 
edu.umn.gis.mapscript.imageObj into some kind of java image object (ideally 
something that implements java.awt.image.RenderedImage – but anything would 
be a start).  This is so I can manipulate the image, using JAI and java2d, 
and then stream the modified image as a SOAP message response.

At the moment I am saving the image to a temporary file (java code shown 
below), using the imageObj.save() method, and then reloading that image into 
my java object.  This is not a desirable solution for obvious performance 
and scalability reasons – especially as I seem to need to pause after the 
save to avoid the load command giving intermittent errors.

Does anybody have any experience of converting the imageObj into a more 
useful java object?  Has anyone written a java or c method to aid this, or 
found another way round a similar problem?

Regards,
James

---Java code snippet---

imageObj image = mapobj.draw();  //define imageObj

String filename = "/var/www/html/gis/scratch/maptemp.png";
File filefilename = new File(filename);  // set temp file variables

image.save(filename, mapobj);  // save image to disk

Thread.sleep(1000); // pause to ensure has saved - avoids errors

BufferedImage bufimg = ImageIO.read(filefilename);  // load it again



More information about the mapserver-users mailing list