Boost logo

Boost-Commit :

From: hljin_at_[hidden]
Date: 2007-08-15 18:21:06


Author: hljin
Date: 2007-08-15 18:21:06 EDT (Wed, 15 Aug 2007)
New Revision: 38705
URL: http://svn.boost.org/trac/boost/changeset/38705

Log:
GIL: fixed a endian-ness related bug in PNG IO routines
Text files modified:
   trunk/boost/gil/extension/io/png_io_private.hpp | 6 +++++-
   1 files changed, 5 insertions(+), 1 deletions(-)

Modified: trunk/boost/gil/extension/io/png_io_private.hpp
==============================================================================
--- trunk/boost/gil/extension/io/png_io_private.hpp (original)
+++ trunk/boost/gil/extension/io/png_io_private.hpp 2007-08-15 18:21:06 EDT (Wed, 15 Aug 2007)
@@ -16,7 +16,7 @@
 /// \brief Internal support for reading and writing PNG files
 /// \author Hailin Jin and Lubomir Bourdev \n
 /// Adobe Systems Incorporated
-/// \date 2005-2007 \n Last updated September 24, 2006
+/// \date 2005-2007 \n Last updated August 14, 2007
 
 #include <algorithm>
 #include <vector>
@@ -162,6 +162,8 @@
         png_init_io(_png_ptr, get());
         png_set_sig_bytes(_png_ptr,PNG_BYTES_TO_CHECK);
         png_read_info(_png_ptr, _info_ptr);
+ if (little_endian() && png_get_bit_depth(_png_ptr,_info_ptr)>8)
+ png_set_swap(_png_ptr);
     }
 public:
     png_reader(FILE* file ) : file_mgr(file) { init(); }
@@ -337,6 +339,8 @@
                      PNG_INTERLACE_NONE,
                      PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT);
         png_write_info(_png_ptr,_info_ptr);
+ if (little_endian() && png_get_bit_depth(_png_ptr,_info_ptr)>8)
+ png_set_swap(_png_ptr);
         std::vector<pixel<typename channel_type<View>::type,
                           layout<typename color_space_type<View>::type> > > row(view.width());
         for(int y=0;y<view.height();++y) {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk