[Gdal-dev] Fix for PNG byte order problems under x86
Robert Osfield
robert at openscenegraph.com
Thu Jan 29 09:19:22 EST 2004
Hi,
When working with a 16bit PNG file under x86 I found a problem with the
endianess, looking into this issue revealled that PNG is stored as the
network byte order/MSB, whereas x86 is LSB. The libpng library has a
png_set_swap() method for forcing a swap, but you have to call it explitily
to enable it to correct the endianess for you.
In the file frmts/png/pngdataset.cpp I added:
#if CPL_LSB
// png are stored as MSB/big endian, so we'll need to swap bytes if on a
// LSB/little endian machine.
if (poDS->nBitDepth>8)
png_set_swap(poDS->hPNG);
#endif
File attached.
Regards,
Robert.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pngdataset.cpp
Type: text/x-c++src
Size: 36969 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20040129/ef3bfcf4/pngdataset.bin
More information about the Gdal-dev
mailing list