[Gdal-dev] Transparent PNG with color table (palette)
Ludwig M Brinckmann
ludwigbrinckmann at gmail.com
Mon May 28 08:54:25 EDT 2007
Many thanks,
that seems to work beautifully.
So far I had been using tiff images as an intermediate container when
creating files for which no Create() method is available, but the in memory
MEM format of course is much superior, no fuss with temp files and no need
to write to disk.
Regards
Ludwig
On 28/05/07, Frank Warmerdam <warmerdam at pobox.com> wrote:
>
> Ludwig M Brinckmann wrote:
> > I need to create paletted PNG files with transparency.
> >
> > I understand that I need to pass in a colour table with the alpha
> > channel set to 0.
> >
> > As I cannot create PNGs directly, I first create a Tiff with the
> > colourtable and then do a CreateCopy.
> >
> > But when I then look at the PNG colour table, the transparency values
> > are gone (all set to 255). This is also true for the intermediate Tiff
> > file -- which is understandable as single band tiffs don't do
> > transparency. I think when creating the tiff the colourtable is adjusted
> > so that it works for the Tiff, but then my transparencies are lost. (If
> > someone thinks this is a bug, I will turn my code into a short example).
> >
> > I tried to alter the colour table after creating the tiff (or the
> > createCopy of the PNG), but this is not supported.
> >
> > What's the best way to do this -- maybe I just need a better
> > intermediate format that does transparencies and can be created (which
> > one?)
>
> Ludwig,
>
> If you image isn't too large, and you are doing programatically (or
> via scripts) you might want to use MEM format as your intermediate format.
> I believe it supports fully featured color tables, and no mess and fuss
> with intermediate file cleanup.
>
> http://www.gdal.org/frmt_mem.html
>
> Note, when creating MEM datasets and not needing to attach to an existing
> array in memory, just use any name for the dataset, such as "tempimage".
>
> 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
> and watch the world go round - Rush | President OSGeo, http://osgeo.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20070528/b247cdea/attachment.html
More information about the Gdal-dev
mailing list