[Qgis-user] Grayscale GeoTiff and transparency using GDAL.

Pietro Panzeri pietro.panzeri at treuropa.com
Mon May 31 01:42:17 PDT 2010


Hi all,

I'm writing a plugin using GDAL C library to allow the user to create a
grayscale GeoTiff with transparency.

I've used the following code to init the raster:

Driver = GDALGetDriverByName("GTiff");

papszOptions = CSLSetNameValue(papszOptions, "COMPRESS", "LZW");

Dataset = GDALCreate(Driver, SrcFilename, XSize, YSize, 2, GDT_Byte,
papszOptions);

Band1 = GDALGetRasterBand(Dataset, 1);
GDALSetRasterColorInterpretation(Band1, GCI_GrayIndex);

Band2 = GDALGetRasterBand(Dataset, 2);
GDALSetRasterColorInterpretation(Band2, GCI_AlphaBand);

...
Init the two bands
...


The result is a correct grayscale image but without transparency.

Can someone point me a way to create a grayscale GeoTiff with a
transparency?

Thank you very much.

Pietro


-- 
Pietro Panzeri

Software Development Manager

Tele-Rilevamento Europa - T.R.E. srl
Via Vittoria Colonna, 7
20149 Milano – Italia
Tel.: +39.02.4343.121 - Fax: +39.02.4343.1230
pietro.panzeri at treuropa.com - www.treuropa.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20100531/c187d68d/attachment.html>


More information about the Qgis-user mailing list