[Gdal-dev] VRTFuncSource
Stefan Klug
Klug.Stefan at gmx.de
Sun Aug 14 08:14:26 EDT 2005
Hi everybody,
I'm fairly new to gdal and am currently stuck with the following problem:
My App needs to extract small parts of a geotiff and write them down as
a JPEG
With an RGB Tiff my approach would be the following:
- create a VRTDataset with three bands
- plug in the three Rasterbands of my geotiff as VRTSimpleSource
- create a copy of the VRTDataset using the JPEG driver
would that be the best way to go?
with indexed geotiffs I thought I could create three inbetween buffers
(red/green/blue) and put them into the VRTDataset using a VRTFuncSource.
But when creating a copy of the VRTDataset using the JPEG driver I get
the following error
VRTFuncSource::RasterIO() - Irregular request
because of nPixelSpace set to 3
Stepping through the code I realized that the JPEG driver requests 3
interleaved bytes per Pixel. There seems to be no possibility to use the
VRTFuncSource when writing color JPEGs as there is no GDALDataType with
3 bytes in size, which would prevent the error?!
Wouldn't it make more sense to pass nPixelSpace to the VRTFuncSource
callback, letting the user handle it?
There is another issue with the speed of the taken approach. When
writing JPEGs like described above, the JPEG driver creates a buffer for
one scanline, passes it to the first band to write the read channel,
then passes buffer+1 to the second band and then buffer+2 to the third
band. All bands writing to the same buffer and propably reading from one
(interleaved) source. Wouldn't it be much more efficient to introduce a
RGB Band which would allow a direct copy of interleaved data?
Or did I completely misunderstand the philosophy behind gdal?
Is the only working solution to write a JPEG from a indexed tiff to
convert the Tiff to a temporarily RGB Tiff, and then writing the JPEG?
Would be great if someone could give me some insight.
Thanks a lot
Stefan Klug
More information about the Gdal-dev
mailing list