[gdal-dev] Can GDAL open binary buffer contents as input for MEM format?

Roger André randre at gmail.com
Sat Jan 16 18:34:23 EST 2010


Hi Frank,

Ok, that makes sense.  So for this to work, I will have to know (somehow)
what type of image mapserver is sending, and then instantiate a MEM dataset
with the correct parameters.  Problem with that is that I can't think of a
good way to read what those parameters are out of the binary string.  It's
no problem when I know exactly what data is coming in, as is the case for my
very specific need, but it means that swapping in GDAL for PIL as a general
solution might not be possible.

I'll play around with the examples you've sent, and will investigate whether
there are ways to read the string and determine what data type it is.

One last question. How does a utility like gdal_translate figure out what
the input data type is?

Thanks again,

Roger
--


On Sat, Jan 16, 2010 at 2:34 PM, Frank Warmerdam <warmerdam at pobox.com>wrote:

> Roger André wrote:
>
>> Hi Frank,
>>
>> Thanks for the example.  How can I specify alpha in that, for one of the
>> quantized 8-bit PNG's (with alpha) that MapServer produces?
>>
>
> Roger,
>
> In a way this is simplier.  It is just a one band GDT_Byte file, so more
> like the first example I gave.  The palette can be handled separately,
> and assigned to the MEM dataset a bit like:
>
>    gdaltest.test_ct_data = [ (255,0,0), (0,255,0), (0,0,255),
> (255,255,255,0)]
>
>    gdaltest.test_ct = gdal.ColorTable()
>    for i in range(len(gdaltest.test_ct_data)):
>        gdaltest.test_ct.SetColorEntry( i, gdaltest.test_ct_data[i] )
>    mem_ds.GetRasterBand(1).SetColorTable( gdaltest.test_ct )
>
> 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<http://pobox.com/%7Ewarmerdam>
> and watch the world go round - Rush    | Geospatial Programmer for Rent
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100116/ef8075ef/attachment-0001.html


More information about the gdal-dev mailing list