[Gdal-dev] Transparent PNG with color table (palette)
Ludwig M Brinckmann
ludwigbrinckmann at gmail.com
Mon May 28 16:17:09 EDT 2007
That now works, thanks.
For the benefit of others this poorly coded Python example shows the way to
use the MEM dataset with GCPs and ColorTable with transparencies to then
create both a paletted GTiff (no transparencies supported, so the
transparent green appear in the tiff, but the GCPs are there), and a PNG
(with transparencies, but without GCPs):
rows = 10
cols = 10
data = numpy.ones((rows,cols), numpy.uint8)
data[4:7,...] = 0
driver = gdal.GetDriverByName('MEM')
image = driver.Create('dummy', rows, cols, 1, gdalconst.GDT_Byte)
gcps = 
colorTable = gdal.ColorTable()
greentransparent = (0, 255, 0, 0)
blue = (0,0, 255,255)
b = image.GetRasterBand(1)
tiffdriver = gdal.GetDriverByName('GTiff')
pngdriver = gdal.GetDriverByName('PNG')
Frank, while I was building from svn trunk, I stumbled over a number of C++
comments in C files/ headers
port/cpl_port.h line 209
alg/gdal_crs.c line 402
frmts/nitf/nitfile.c line 533/535
frmts/mgrs.c line 400
port/cps_multiproc.h line 35++
Thanks for your very quick help.
On 28/05/07, Ludwig M Brinckmann <ludwigbrinckmann at gmail.com> wrote:
> Thanks, you are a star.
> I will see if that works for me and report back.
> On 28/05/07, Frank Warmerdam < warmerdam at pobox.com> wrote:
> > Ludwig M Brinckmann wrote:
> > > Maybe this was a bit premature.
> > >
> > > Unfortunately, the MEM dataset does not support the SetGCPs method,
> > even
> > > though the documentation says it 'should' .
> > > (" Memory datasets should support for most kinds of auxilary
> > information
> > > including metadata, coordinate systems, georeferencing, GCPs, color
> > > interpretation, nodata, color tables and all pixel data types.")
> > Ludwig,
> > I see your analysis is correct - the MEM driver actually lacked GCP
> > support
> > despite the docs. I have added this in trunk, if that is convenient for
> > you.
> > Best regards,
> > --
> > ---------------------------------------+--------------------------------------
> > I set the clouds in motion - turn up | Frank Warmerdam,
> > warmerdam at pobox.com
> > light and sound - activate the windows | http://pobox.com/~warmerdam<http://pobox.com/%7Ewarmerdam>
> > and watch the world go round - Rush | President OSGeo,
> > http://osgeo.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gdal-dev