Hey Michael,
First of all, thank you for your fast reply and the useful inferomation.
I read through the pages but i still don't really know why i should
create a stlye.
I thought, that i have to style the map if i want to display any
colors in the map, but
my BufferedImage is already colored with an ColorMap.

So i got a BufferedImage colored with a Colormap. Furthermore i got
the CoordinateReferenceSystem and the bbox.
Now i create a GridCoverage2D
GridCoverage2D grid = factory.create("results",
getMapRequest.getfBufferedImage(), bbox2);
where bbox2 is a ReferenceEnvelope.
And with this GridCoverage i would like to create a map.

Do i still have to create a style?
Sorry for all the questions.

Timon



2012/6/18 Michael Bedward <[email protected]>:
> Hello Timon,
>
> I don't use WMS so what follows may or may not be useful.
>
> In general, you can draw a coverage into an image like this:
>
>    void drawCoverage(GridCoverage2D myCoverage,
>            Style myDisplayStyle,
>            ReferencedEnvelope worldEnv,
>            BufferedImage destImage) {
>
>        MapContent map = new MapContent();
>        map.addLayer( new GridCoverageLayer(myCoverage, myDisplayStyle) );
>
>        StreamingRenderer renderer = new StreamingRenderer();
>        renderer.setMapContent(map);
>
>        Graphics2D gr2D = destImage.createGraphics();
>        Rectangle paintArea = new Rectangle(
>                destImage.getMinX(), destImage.getMinY(),
>                destImage.getWidth(), destImage.getHeight());
>
>        renderer.paint(gr2D, paintArea, worldEnv);
>    }
>
> The GeoTools imports for the above are:
>
> import org.geotools.coverage.grid.GridCoverage2D;
> import org.geotools.geometry.jts.ReferencedEnvelope;
> import org.geotools.map.GridCoverageLayer;
> import org.geotools.map.MapContent;
> import org.geotools.renderer.lite.StreamingRenderer;
> import org.geotools.styling.Style;
>
> The tricky bit is creating the appropriate Style object - at least I
> find that tricky. However, there is a nice Geoserver page about raster
> styles (as SLD docs) if you haven't already seen it:
>
> http://docs.geoserver.org/stable/en/user/styling/sld-cookbook/rasters.html
>
> There is also the GeoTools Image tutorial which includes code for
> creating two simple styles programmatically:
>
> http://docs.geotools.org/latest/userguide/tutorial/raster/image.html#displaying-the-map
> (scroll down a little to see the Style code)
>
> Hope that helps.
>
> Michael
>
>
> On 18 June 2012 15:53, Timon Kirschke <[email protected]> wrote:
>> Hey,
>> I am currently trying to extend Geoserver with my own WMS and i just
>> want to ask for a little help.
>> My biggest Problem is, how to create a map from a BufferedImage.
>> So my attemp is to create a GridCoverage2D with an Envelope and the
>> CoordinateReferenceSystem and then
>> somehow render it.
>>
>>
>> Perhaps someone can give me a few advices, because i am really new to 
>> Geootools.
>>
>> Timon
>>
>> PS. Sorry for my really poor english. If there are any questions, I
>> will try to answer them as soon as possible.
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> GeoTools-GT2-Users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to