[Gdal-dev] geotiff 2 png with c++

Frank Warmerdam warmerdam at pobox.com
Sun Aug 5 13:11:57 EDT 2007


Lijian Shi wrote:
> Hi, all,
> 
>  
> 
> I want to convert data with geotiff format into png format and I know i 
> can do it with gdal_translate. Now I want to write a c++ code to do this 
> job because I need do some change on the raw data from geotiff file 
> before I write into png file.  The code is as followed but there seems 
> to be some wrong with it. Anyone could help me to figure out the 
> mistake? Thanks in advance!

Lijian,

I'm afraid I can't follow the code you supply.

1) you close dstDS (by deleting it) but then still try to write to it.

2) You don't seem load load data into srcData anywhere.

In any event, the process you want to do (geotiff to png with processing
in between) is tricky because the PNG driver only supports CreateCopy(),
not Create().  That means you can't use RasterIO() to write to PNG - you
have to have a pre-prepared input image to give as input to CreateCopy().

Depending on file size, you could use an intermediate MEM format dataset.

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




More information about the Gdal-dev mailing list