changeset 643:8d1382acee29

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Oct 2013 17:05:02 +0100
parents 9a85a2ac1005 (diff) a5f291f05bba (current diff)
children eb5a0b21d05e
files
diffstat 3 files changed, 28 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Core/FileFormats/PngWriter.cpp	Tue Oct 29 15:29:30 2013 +0100
+++ b/Core/FileFormats/PngWriter.cpp	Tue Oct 29 17:05:02 2013 +0100
@@ -174,15 +174,18 @@
       {
       case PixelFormat_Grayscale16:
       case PixelFormat_SignedGrayscale16:
-        png_set_rows(pimpl_->png_, pimpl_->info_, &pimpl_->rows_[0]);
-
+      {
+        int transforms = 0;
         if (Toolbox::DetectEndianness() == Endianness_Little)
         {
-          // Must swap the endianness!!
-          png_write_png(pimpl_->png_, pimpl_->info_, PNG_TRANSFORM_SWAP_ENDIAN, NULL);
+          transforms = PNG_TRANSFORM_SWAP_ENDIAN;
         }
 
+        png_set_rows(pimpl_->png_, pimpl_->info_, &pimpl_->rows_[0]);
+        png_write_png(pimpl_->png_, pimpl_->info_, transforms, NULL);
+
         break;
+      }
 
       default:
         png_write_image(pimpl_->png_, &pimpl_->rows_[0]);
--- a/NEWS	Tue Oct 29 15:29:30 2013 +0100
+++ b/NEWS	Tue Oct 29 17:05:02 2013 +0100
@@ -2,6 +2,10 @@
 ===============================
 
 
+* Fix for big-endian architectures (RedHat bug #985748)
+* Refactoring of the CMake options
+
+
 Version 0.7.0 (2013/10/25)
 ==========================
 
--- a/UnitTestsSources/Png.cpp	Tue Oct 29 15:29:30 2013 +0100
+++ b/UnitTestsSources/Png.cpp	Tue Oct 29 17:05:02 2013 +0100
@@ -3,6 +3,8 @@
 #include <stdint.h>
 #include "../Core/FileFormats/PngReader.h"
 #include "../Core/FileFormats/PngWriter.h"
+#include "../Core/Toolbox.h"
+
 
 TEST(PngWriter, ColorPattern)
 {
@@ -24,6 +26,11 @@
   }
 
   w.WriteToFile("ColorPattern.png", width, height, pitch, Orthanc::PixelFormat_RGB24, &image[0]);
+
+  std::string f, md5;
+  Orthanc::Toolbox::ReadFile(f, "ColorPattern.png");
+  Orthanc::Toolbox::ComputeMD5(md5, f);
+  ASSERT_EQ("604e785f53c99cae6ea4584870b2c41d", md5);
 }
 
 TEST(PngWriter, Gray8Pattern)
@@ -44,6 +51,11 @@
   }
 
   w.WriteToFile("Gray8Pattern.png", width, height, pitch, Orthanc::PixelFormat_Grayscale8, &image[0]);
+
+  std::string f, md5;
+  Orthanc::Toolbox::ReadFile(f, "Gray8Pattern.png");
+  Orthanc::Toolbox::ComputeMD5(md5, f);
+  ASSERT_EQ("5a9b98bea3d0a6d983980cc38bfbcdb3", md5);
 }
 
 TEST(PngWriter, Gray16Pattern)
@@ -66,6 +78,11 @@
   }
 
   w.WriteToFile("Gray16Pattern.png", width, height, pitch, Orthanc::PixelFormat_Grayscale16, &image[0]);
+
+  std::string f, md5;
+  Orthanc::Toolbox::ReadFile(f, "Gray16Pattern.png");
+  Orthanc::Toolbox::ComputeMD5(md5, f);
+  ASSERT_EQ("0785866a08bf0a02d2eeff87f658571c", md5);
 }
 
 TEST(PngWriter, EndToEnd)
@@ -105,5 +122,4 @@
       ASSERT_EQ(*p, v);
     }
   }
-
 }