Gabriella Turek a écrit :
> I am reading some georeferenced images (png, jpg) which when rendered I
> would like to have specific colors and transparency. How do I do this?
> Do I use ColorMap or do I use Category as explained in
> http://geotools.codehaus.org/Using+Grid+Coverage

Categories are more useful in the context of indexed image that are 
measurements 
of some quantities (e.g. temperature images). Which kind of images do you have? 
RGB or indexed? Measurements of some quantities or just "photographic"?

> I want for these images to be transparent and a range of a single
> color (typically blue).

I will need to look again how the "ColorMap" operation work (it was a while 
when 
I initially wrote it, and it probably need to be revisited). Simone told me 
that 
the RasterSymbolizer need revision too. In the main time you may try the 
following work around (in this example, are assume that the image are 
temperature data):


Color lowBlue = new Color(0,0, 16);
Color hiBlue  = new Color(0,0,240);
double scale  = 1.0;  // Put a real scale factory here if you know it.
double offset = 0.0;  // Put a real offset value here if you know it.
Category temperature = new Category("Temperature",
         new Color[] {lowBlue, hiBlue}, 1, 256, scale, offset);
GridSampleDimension band = new GridSampleDimension("Temperature",
         new Category[] {Category.NODATA, temperature}, SI.CELSIUS);
/*
  * If we were creating a new GridCoverage2D from floating point values,
  * (e.g. form a matrix) we would use the above GridSampleDimension
  * directly. But since we want to reformat an existing image, the
  * GridSampleDimension is just used as a helper class for creating
  * the IndexColorModel to give to the JAI "Reformat" operation.
  * Note that JAI, FormatDescriptor and ImageLayout are JAI classes.
  */
GridCoverage2D gc = ... // The old grid coverage to reformat.
RenderedImage image = gc.getRenderedImage();
ImageLayout layout = new ImageLayout();
layout.setColorModel(band.getColorModel());
RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
image = FormatDescriptor.create(image, DataBuffer.TYPE_BYTE, hints);
/*
  * Now recreate a new grid coverage with the same properties than the
  * old one except for the image and the associated band.
  */
GridCoverageFactory factory = FactoryFinder.getGridCoverageFactory(null);
gc = factory.create("Temperature at some time", image, gc.getGridGeometry(),
         new GridSampleDimension[] {band}, null, null);


I have not tested the above code, but something along that line should work.

        Martin

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to