[Gdal-dev] gdalwarp and RGBA generation

Frank Warmerdam warmerdam at pobox.com
Thu Oct 7 12:55:24 EDT 2004


Chris,

I have implmented very preliminary support for generating output images
with an alpha band.  Use the -dstalpha option to gdalwarp to indicate that
it should add an alpha band to the output.

I also found that the JP2KAK driver was not writing RGBA images with the
proper band color interpretation.  So I made a change in there to fix that.

Make sure you do a clean build.  The GDALWarpOptions structure has changed,
and this sort of change is not properly recognised by the Makefiles.

With this change I was able to reproject an RGB image to an output RGBA
file with an alpha band as shown below.  This also took care of setting
alpha values for pre-existing "nodata" areas marked as zero.

   gdalwarp -dstalpha -srcnodata 0 landsat_rgb.tif l2.tif \
        -t_srs '+proj=utm +zone=21 +datum=WGS84'

The alpha support work isn't really complete, but I will need to return to
it in the future.  Currently "source alpha" isn't handled.  Also, I don't
think that destination alpha values are properly used when blending.

Finally, this works fine for RGB images, but using -dstalpha with
greyscale images isn't likely going to be to useful yet.  The output file
will be generated properly with the exception that I don't think the
alpha band will be properly marked as alpha in the .tif. Also, the jp2kak
driver doesn't yet support generating greyscale (or paletted) images with
alpha bands.  On top of all that, I don't think mapserver supports greyscale
images with alpha bands unless you specifically control things with a
PROCESSING "BAND=1,1,1,2" type directive.  In the meantime you could
just convert greyscale images to RGB before warping if that is acceptable
to 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
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list