# HG changeset patch # User Sebastien Jodogne # Date 1383062702 -3600 # Node ID 8d1382acee29e86dee49e585da6c47f73b0c191a # Parent 9a85a2ac1005ff2eba3acc571d96354feda12a6d# Parent a5f291f05bba28e3af8a5f9f645c05df39b8d253 merge diff -r a5f291f05bba -r 8d1382acee29 Core/FileFormats/PngWriter.cpp --- 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]); diff -r a5f291f05bba -r 8d1382acee29 NEWS --- 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) ========================== diff -r a5f291f05bba -r 8d1382acee29 UnitTestsSources/Png.cpp --- 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 #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); } } - }