[Gdal-dev] CreateCopy into buffer

Ivan Mjartan ivan.mjartan at geovap.cz
Tue Nov 29 09:24:54 EST 2005


Hi list,

I am writing function in C++ witch on input get large raster and return small sub window of the input raster in BitMap (*.BMP file). The sub window is never larger then 1000*1000px.

 

The code looks like:

 

hDriver = GetGDALDriverManager()->GetDriverByName("BMP");

 

hDataset = GDALOpenShared( pszSrcFilename, GA_ReadOnly );

       

poVDS = new VRTDataset(xsize, ysize);

 

nBandCount = GDALGetRasterCount( hDataset );

    

 

for( i = 0; i < nBandCount; i++ )

{

    VRTSourcedRasterBand   *poVRTBand;

    GDALRasterBand  *poSrcBand;

    GDALDataType    eBandType;

             

    poSrcBand = ((GDALDataset *)hDataset)->GetRasterBand(i+1);

    eBandType = poSrcBand->GetRasterDataType();

       

    poVDS->AddBand( eBandType, NULL );

    poVRTBand = (VRTSourcedRasterBand *) poVDS->GetRasterBand( i+1 );

             

    poVRTBand->AddSimpleSource( poSrcBand,x, y, xsize, ysize,0, 0, xsize, ysize );

 

    poVRTBand->CopyCommonInfoFrom( poSrcBand );

}

       

 

hOutDS = GDALCreateCopy( hDriver,"c:\\CsharpTest\\temp\\cut.bmp", (GDALDatasetH) poVDS,FALSE, NULL, NULL, NULL );

 

 

Than I am calling this function from C# .Net application and I need result (in example case cut.bmp) in byte array. 

 

It is possible use CreateCopy with out disk writing operation and return result in byte array?

 

 

 thanks ivan 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20051129/715b3f80/attachment.html


More information about the Gdal-dev mailing list