[gdal-dev] GDALWarp API and paletted images
Even Rouault
even.rouault at spatialys.com
Tue Jun 9 04:44:19 PDT 2015
Thomas,
>
> I'm using the GDALWarp api from C++ to reproject and cut various input
> images. In general this works very well for my purposes, except that for
> paletted images I have to use NearestNeighbour resampling,
>
> I would like to use Bilinear or higher order resampling, and wonder if
> there is any way to expand a paletted image to true RGB during the warp
> process, so I can use these resampling methods.
No, you must use an intermediate step before.
>
> Alternatively, is there a way to do this conversion (from code) before the
> warp without having to run through the entire image in memory?
You can use a in-memory VRT dataset to do on-the-fly expansion to RGB.
With the AddComplexSource() method of VRTSourcedRasterBand class:
CPLErr AddComplexSource( GDALRasterBand *poSrcBand,
int nSrcXOff=-1, int nSrcYOff=-1,
int nSrcXSize=-1, int nSrcYSize=-1,
int nDstXOff=-1, int nDstYOff=-1,
int nDstXSize=-1, int nDstYSize=-1,
double dfScaleOff=0.0,
double dfScaleRatio=1.0,
double dfNoDataValue = VRT_NODATA_UNSET,
int nColorTableComponent = 0);
Set nColorTableComponent to 1,2,3 for respectively R,G,B. This is what
gdal_translate will do if you use "gdal_translate -of VRT -expand rgb pct.tif
out.vrt"
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list