Hi Oliver,
Thanks for the question. It's prompted me to look at the JMapPane code
and see how to make it easier to save an image. In GeoTools 2.6.0 you
can get the map pane's cached image with mapPane.getBaseImage() but
the image is configured for saving easily to JPG.
I'll make some changes to the code and put together a new example.
Meanwhile, here is a method that should work...
Rectangle paintArea = mapPane.getVisibleRect();
BufferedImage image = new BufferedImage(
paintArea.width, paintArea.height,
BufferedImage.TYPE_INT_RGB);
Graphics2D gr = image.createGraphics();
gr.setComposite(AlphaComposite.Src);
gr.setPaint(Color.WHITE);
gr.fill(paintArea);
mapPane.getRenderer().paint(gr,
mapPane.getVisibleRect(), mapPane.getDisplayArea(),
mapPane.getWorldToScreenTransform());
File fileToSave = ...
try {
ImageIO.write(image, "jpeg", fileToSave);
} catch (IOException ex) {
// bummer...
} finally {
gr.dispose();
}
Hope that helps.
Michael
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users