[Gdal-dev] C# Bindings
Frank Warmerdam
warmerdam at pobox.com
Sat Nov 4 23:21:35 EST 2006
Simon Perkins wrote:
> So how does this work? i.e. where does the unmanaged buffer that
> GDALRasterIO initially reads into get allocated? In C code somewhere? Or
> is there some way of getting an IntPtr pointing to an allocated buffer
> in C#? And then you copy it into a C# array in some CS code? And then
> switch back to C to free the unmanaged memory? And you can do all this
> without using the unsafe keyword? Guess it'll be easier to visualize it
> when you've written it.
Simon,
Tamas just did "IntPtr buf = bitmapData.Scan0". I assumed Scan0 was
a buffer in the bitmapData object, and that it was previously allocated.
So there is no apparent copying of the buffer, or allocation within
the rasterio. I could be missing lots of stuff though.
>> How about supporting ReadBlock/WriteBlock? Would it be required?
>
> I think this is a pretty low priority.
Calling ReadBlock and WriteBlock is now also discouraged for C
and C++ applications. I don't see any need to binding them in
the swig wrapped languages.
> For convenience, it would be nice to have overloads that assume default
> values for the last three parameters (bufferOffset, pixelSpace and
> lineSpace) for the common case where we're not dealing with packed
> buffers. In these cases, bufferOffset = 0, pixelSpace =
> sizeof(datatype), and lineSpace = bufXSize * pixelSpace.
The default should be all zeros and then values are computed internally.
This should already be documented in the rasterio docs.
By the way, if there is a way of doing pointer arithmetic with the
IntPtr, then I think you should avoid this BufOffset idea. It seems
like a hack to me.
PS. I'm very excited by the progress on the c# bindings! I made a
feeble attempt at this some time ago and failed because I didn't
know enough about c# and swig typemaps.
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