From: JoeK <joe...@ya...> - 2012-01-27 20:10:27
|
Hi all, I am trying to generate a GeoTiff image using GeoTools 2.7.1 The original image is a BufferedImage with RGB and Alpha channel. (I can write the original image to a png file and it shows the transparent pixels.) (I used "Eye of GNOME" to view the tiff file.) In the resulting tiff file, the transparent pixels are not transparent but in blue color. Here is the code I have: // setup Envelope2D bbox = new Envelope2D(crs("EPSG:4326"), west, south, width, height); GridCoverageFactory factory = new GridCoverageFactory(); // "img" is a java.awt.image.BufferedImage with RGB and Alpha channel GridCoverage2D coverage = factory.create("tiff", img, bbox); final File output = new File("out.tif"); GeoTiffWriter gtwriter = new GeoTiffWriter(output); // sets transparency metadata gtwriter.setMetadataValue(Integer.toString(BaselineTIFFTagSet.TAG_BITS_PER_SAMPLE), "8"); gtwriter.setMetadataValue(Integer.toString(BaselineTIFFTagSet.TAG_SAMPLES_PER_PIXEL), "4"); gtwriter.setMetadataValue(Integer.toString(BaselineTIFFTagSet.TAG_PLANAR_CONFIGURATION), Integer.toString(BaselineTIFFTagSet.PLANAR_CONFIGURATION_CHUNKY)); gtwriter.setMetadataValue(Integer.toString(BaselineTIFFTagSet.TAG_PHOTOMETRIC_INTERPRETATION), Integer.toString(BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_RGB)); gtwriter.setMetadataValue(Integer.toString(BaselineTIFFTagSet.TAG_EXTRA_SAMPLES), Integer.toString(BaselineTIFFTagSet.EXTRA_SAMPLES_ASSOCIATED_ALPHA)); gtwriter.write(coverage, null); gtwriter.dispose(); coverage.dispose(true); Anyone knows if I missed a metadata for the GeoTiffWriter? Or if I set something wrong in the metadata value? Any advice is appreciated. Thanks in advance. - Joe -- View this message in context: http://osgeo-org.1560.n6.nabble.com/Help-with-generating-a-GeoTiff-image-with-transparent-pixels-tp4344175p4344175.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |