Re: [OpenMap Users] Writing map to an image

From: Don Dietrick <dietrick_at_bbn.com>
Date: Fri, 24 Aug 2007 12:30:57 -0400

Hi Jay,

I'm not sure how the sleep method is helping you here. The
renderDataForProjection on each layer waits for it to finish
rendering before moving on to the next layer. Also, you might want
to change BufferedImage.TYPE_4BYTE_ABGR to BufferedImage.TYPE_INT_ARGB.

You can use the com.bbn.openmap.image.ImageServer to do this for you,
too. That's also a good place to see how we've gotten this to work.

- Don


On Aug 24, 2007, at 12:19 PM, Jay D. Askren wrote:

> I need to write a map to an image. I do it as follows:
>
>
> Projection proj = ProjectionFactory.makeProjection(LLXYView.class,
>
> centerLat, centerLon, scale, width, height);
>
> _mapBean.setProjection(proj);
>
> BufferedImage currentImage = new BufferedImage(width, height,
> BufferedImage.TYPE_4BYTE_ABGR);
>
> try{
>
> Thread.sleep(200);
>
> }catch (Exception e){
>
> e.printStackTrace();
>
> }
>
> Layer[] layers = _layerHandler.getMapLayers();
>
> for (int i = 0; i < layers.length; i++) {
>
> layers[i].renderDataForProjection(proj,
> currentImage.getGraphics());
>
> }
>
>
>
> I have the Thread.sleep(200) in there because it appears if I donít
> let the thread sleep, open map sometimes does not have enough time
> to render the layers, and the may image come out blank or with only
> some of the layers drawn. The problem is that I donít know how
> long to sleep. It varies depending on how hefty the layers are.
> Is there a way to tell when the layers are done painting? I really
> would like to block until the layer threads are done painting.
> Thanks.
>
>
>
> Jay
>
>
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick_at_bbn.com
BBN Technologies, Cambridge MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Fri Aug 24 2007 - 12:30:34 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:08 EDT