From: Stefan <krueger@wi...> - 2007-07-28 13:54:52
I am fighting around with transparency in classification raster images.
The one way:
(GDAL 220.127.116.11, released 2007/01/02, The srcnodata is right)
> gdalwarp -srcnodata 0 -dstnodata 0 ../landuse.img landuse.tif
When i import that GeoTiff, they have an IndexedColorModel and classes/values
1 to 12 have correct colors,. Other values don't exist and don't have colors.
All good, but no transparency on the sides!
The second way:
>GDAL 18.104.22.168, released 2007/01/02>gdalwarp -dstalpha -srcnodata 0 -dstnodata
0 ../landuse.img landuse2.tif
When i import that GeoTiff, i don't have an IndexedColorModel, but just a
ColorModel (?). Alpha and transparency are enabled (at least the methods of
the planar Image say so..)
This is roughly how to am testing this...
> // I use GeoTiffReader,
> GeoTiffReader reader = new GeoTiffReader(file,hints);
> GridCoverage2D gc = (GridCoverage2D)reader.read(null);
> Object o = prop.get("tile_cache_key");
> PlanarImage pi = (PlanarImage) o;
> pi = ImageUtilities.componentColorModel2IndexColorModel4GIF(pi);
> ColorModel colorModel = pi.getColorModel();
> log.debug("cm= "+colorModel);
> log.debug("hasAlpha = "+icm.hasAlpha());
BUT the colors for values 1 to 12 are gone! I get a black and white image,
which is very dark, as only values 1 to 12 exist, and it look like 0 to 255
are streched from black to white. :-(
But transparency seems to work outside the are of values...
So the first way i have the colors i need, the second way i get the
transparency. Any hints for me?
I would love to hear, that i could use the first import method, where i get
the right colors in an IndexedColorModel, and just designate one value as
transparent... So a kind of simple transparency like GIF uses... is that
possible for a MapLayer or a Gricoverage2D ???
Stefan from Bonn,