On 19/01/13 14:38, Andrea Aime wrote:
> One simple observation about the problem, regardless of what technique
> you use to generate the image, if you are going out with formats like
> PNG or JPEG right before encoding the image will be fully stored in
> memory, because both formats encoders want the entire data buffer
> of the image.
>
> The only format that can do tiled writing is TIFF as far as I know.
thanks for the information. this should be OK, TIFF is fine for me.
> About the approach, another way is to create a JAI operation that
> gets the MapContext as a parameter, and generates tiles on demand
> by having the map context paint only the tile required at the moment.
>
> That, coupled with a TIFF output, should work (no promises).
>
thanks

I experimented with this, and interestingly, rendering works differently
when using a BufferedImage and a TiledImage. for example, a
PointSymbolizer with an SVG graphics is rendered on the BufferedImage,
but not on the TiledImage. please see http://akos.maroy.hu/~akos/ti.tif
for the BufferedImage and http://akos.maroy.hu/~akos/ti.tif for the
RenderedImage output attached. it's also interesting that text does
display the same, and other SVG graphics are actually rendered
(I can send samples as well)

I did some debugging and the actual values in SVGGraphicsFactory.paint()
seem to be the very same (e.g. scale, width, height, x, y, etc.) please
also find the SVG in question attached. the SLD looks like the following:

                    <sld:PointSymbolizer>
                        <sld:Graphic>
                            <sld:ExternalGraphic>
                                <sld:OnlineResource
xlink:href="navaid_designated.svg" xlink:type="simple"/>
                                <sld:Format>image/svg+xml</sld:Format>
                            </sld:ExternalGraphic>
                            <sld:Size>11</sld:Size>
                        </sld:Graphic>
                    </sld:PointSymbolizer>

the code to used for rendering is:

        GTRenderer renderer = new StreamingRenderer();
        renderer.setMapContent(map);

        Map<Object, Object> rendererParams = new HashMap<Object, Object>();
        rendererParams.put(StreamingRenderer.DPI_KEY, new Double(dpi));
        rendererParams.put(StreamingRenderer.SCALE_COMPUTATION_METHOD_KEY,
                           StreamingRenderer.SCALE_ACCURATE);

rendererParams.put(StreamingRenderer.ADVANCED_PROJECTION_HANDLING_KEY,
                           new Boolean(true));
        rendererParams.put(StreamingRenderer.VECTOR_RENDERING_KEY,
                           new Boolean(true));
        renderer.setRendererHints(rendererParams);

        RenderingHints hints2D =
                new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                                   RenderingHints.VALUE_ANTIALIAS_ON);
        hints2D.put(RenderingHints.KEY_TEXT_ANTIALIASING,
                    RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        renderer.setJava2DHints(hints2D);

//...

        SampleModel sampleModel = RasterFactory.createBandedSampleModel(
                DataBuffer.TYPE_BYTE,
                1024, 1024,
                3);
        ColorModel cm = TiledImage.createColorModel(sampleModel);

        // either this
        TiledImage image = new TiledImage(0, 0,
                              imageBounds.width, imageBounds.height,
                              0, 0,
                              sampleModel, cm);

        // or this
        BufferedImage image = new BufferedImage(imageBounds.width,
                                                imageBounds.height,
                                                BufferedImage.TYPE_INT_RGB);

        Graphics2D gr = image.createGraphics();
        gr.setPaint(Color.WHITE);
        gr.fill(imageBounds);

        renderer.paint(gr, imageBounds, mapBounds);

        JAI.create("filestore", image, file, "TIFF", null);


I wonder what is different in the two cases?


Akos


<<attachment: navaid_designated.svg>>

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to