[Gdal-dev] color table problems
Mario Beauchamp
starged at videotron.ca
Wed Jan 19 18:08:10 EST 2005
Hi all,
I'm trying to assign a ColorTable to a VRT in OpenEV using vrtutils.VRTDatasetConstructor(). The
AddSimpleBand method needs "ColorInterp" and "colortable" so to get it from the source file, I have:
def getColorTable(f):
band = gdal.Open(f).GetRasterBand(1)
gci = band.GetRasterColorInterpretation()
if gci == gdal.GCI_PaletteIndex:
ci = 'Palette'
ct = band.GetRasterColorTable()
else:
ci = 'Undefined'
ct = None
return ci,ct
But this makes Python crash.
Even this simple script give strange results:
## test.py
## Usage: test.py file
import gdal
import sys
band = gdal.Open(sys.argv[1]).GetRasterBand(1)
ci = band.GetRasterColorInterpretation()
ct = band.GetRasterColorTable().GetCount()
print ci,ct
sys.exit(0)
I tried with many png and gif files and I get values like 8091364 and 8090496 on DOS and 8057040 or
7952048 on MSYS for ci. ct is always 0.
Even tried it on Linux and I get seg faults.
I suspect it's a Python prob as gdalinfo reports all infos correctly on all files tested.
BTW, why the whole color table has to be in the VRT? Couldn't there be a way to say: "get that from
the source band"?
Thanks.
--
Mario B.
Landsat images (demo):
http://pages.infinit.net/starged/landsat/home.htm
More information about the Gdal-dev
mailing list