[gdal-dev] C# Bindings warp image using gcp
Edi.Karadumi
edikaradumi at gmail.com
Wed Aug 10 09:40:33 EDT 2011
Hello im trying to warp an image using 4 or more gcp points. I have already
done it in c++, but my project is in c# so im trying to convert it. I got
the following example from the GDAL warp API tutorial and adjusted it for my
needs. I have done most of the other parts but i cant convert the following
part
// Establish reprojection transformer.
psWarpOptions->pTransformerArg =
GDALCreateGenImgProjTransformer( hSrcDS,
GDALGetProjectionRef(hSrcDS),
hDstDS,
GDALGetProjectionRef(hDstDS),
TRUE, 0.0, 1 );
psWarpOptions->pfnTransformer = GDALGenImgProjTransform;
I cant find GDALCreateGenImgProjTransformer to create the transformer. How
can i adapt it i C#?
Best Regards
Edi Karadumi
This is the official Example
#include "gdalwarper.h"
int main()
{
GDALDatasetH hSrcDS, hDstDS;
// Open input and output files.
GDALAllRegister();
hSrcDS = GDALOpen( "in.tif", GA_ReadOnly );
hDstDS = GDALOpen( "out.tif", GA_Update );
// Setup warp options.
GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();
psWarpOptions->hSrcDS = hSrcDS;
psWarpOptions->hDstDS = hDstDS;
psWarpOptions->nBandCount = 1;
psWarpOptions->panSrcBands =
(int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount );
psWarpOptions->panSrcBands[0] = 1;
psWarpOptions->panDstBands =
(int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount );
psWarpOptions->panDstBands[0] = 1;
psWarpOptions->pfnProgress = GDALTermProgress;
// Establish reprojection transformer.
psWarpOptions->pTransformerArg =
GDALCreateGenImgProjTransformer( hSrcDS,
GDALGetProjectionRef(hSrcDS),
hDstDS,
GDALGetProjectionRef(hDstDS),
FALSE, 0.0, 1 );
psWarpOptions->pfnTransformer = GDALGenImgProjTransform;
// Initialize and execute the warp operation.
GDALWarpOperation oOperation;
oOperation.Initialize( psWarpOptions );
oOperation.ChunkAndWarpImage( 0, 0,
GDALGetRasterXSize( hDstDS ),
GDALGetRasterYSize( hDstDS ) );
GDALDestroyGenImgProjTransformer( psWarpOptions->pTransformerArg );
GDALDestroyWarpOptions( psWarpOptions );
GDALClose( hDstDS );
GDALClose( hSrcDS );
return 0;
}
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/C-Bindings-warp-image-using-gcp-tp6672396p6672396.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
More information about the gdal-dev
mailing list