[opengtl-commits] [359] reverse byte order only on little endian system

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 359
Author:   cyrille
Date:     2008-09-03 23:04:17 +0200 (Wed, 03 Sep 2008)

Log Message:
-----------
reverse byte order only on little endian system

Modified Paths:
--------------
    trunk/OpenGTL/Extensions/PngDC/PngDC.cpp


Modified: trunk/OpenGTL/Extensions/PngDC/PngDC.cpp
===================================================================
--- trunk/OpenGTL/Extensions/PngDC/PngDC.cpp	2008-09-03 21:03:48 UTC (rev 358)
+++ trunk/OpenGTL/Extensions/PngDC/PngDC.cpp	2008-09-03 21:04:17 UTC (rev 359)
@@ -21,6 +21,8 @@
 
 #include <png.h>
 
+#include <config-endian.h>
+
 #include <GTLCore/Macros_p.h>
 #include <GTLImageIO/ImageDCRegistry.h>
 #include <GTLCore/Image.h>
@@ -106,6 +108,10 @@
       fclose(fp);
       TELL_ERROR( "Unsupported bit depth: " + GTLCore::String::number( bit_depth ) );
   }
+#ifndef WORDS_BIGENDIAN
+  if (bit_depth > 8)
+    png_set_swap(png_ptr);
+#endif
   GTL_ASSERT( channelType );
   int channelsCount = 0;
   switch( color_type )
@@ -204,6 +210,12 @@
       fclose(fp);
       TELL_ERROR( "Unsupported bit depth: " + GTLCore::String::number( bit_depth ) );
   }
+  
+#ifndef WORDS_BIGENDIAN
+  if (bit_depth > 8)
+    png_set_swap(png_ptr);
+#endif
+  
   // Guess the color type
   int color_type;
   switch( _image->pixelDescription().channels() )
@@ -231,8 +243,6 @@
   png_init_io(png_ptr, fp );
   png_write_info(png_ptr, info_ptr);
   
-  if (bit_depth > 8)
-    png_set_swap(png_ptr);
   
   int pixel_size = (_image->pixelDescription().bitsSize() / 8);
   png_bytep row_pointer = new png_byte[ pixel_size * _region.width()  ];


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/