Mercurial > hg > orthanc
diff OrthancFramework/UnitTestsSources/ImageTests.cpp @ 5368:91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 12 Aug 2023 13:17:17 +0200 |
parents | 0ea402b4d901 |
children | 48b8dae6dc77 |
line wrap: on
line diff
--- a/OrthancFramework/UnitTestsSources/ImageTests.cpp Mon Jul 24 14:55:14 2023 +0200 +++ b/OrthancFramework/UnitTestsSources/ImageTests.cpp Sat Aug 12 13:17:17 2023 +0200 @@ -33,10 +33,11 @@ #include "../Sources/Images/ImageProcessing.h" #include "../Sources/Images/JpegReader.h" #include "../Sources/Images/JpegWriter.h" +#include "../Sources/Images/PamReader.h" +#include "../Sources/Images/PamWriter.h" #include "../Sources/Images/PngReader.h" #include "../Sources/Images/PngWriter.h" -#include "../Sources/Images/PamReader.h" -#include "../Sources/Images/PamWriter.h" +#include "../Sources/OrthancException.h" #include "../Sources/Toolbox.h" #if ORTHANC_SANDBOXED != 1 @@ -96,14 +97,33 @@ uint8_t *p = &image[0] + y * pitch; for (unsigned int x = 0; x < width; x++, p += 8) { - p[0] = (y % 8 == 0) ? 255 : 0; - p[1] = (y % 8 == 1) ? 255 : 0; - p[2] = (y % 8 == 2) ? 255 : 0; - p[3] = (y % 8 == 3) ? 255 : 0; - p[4] = (y % 8 == 4) ? 255 : 0; - p[5] = (y % 8 == 5) ? 255 : 0; - p[6] = (y % 8 == 6) ? 255 : 0; - p[7] = (y % 8 == 7) ? 255 : 0; + switch (Orthanc::Toolbox::DetectEndianness()) + { + case Orthanc::Endianness_Little: + p[0] = (y % 8 == 0) ? 255 : 0; + p[1] = (y % 8 == 1) ? 255 : 0; + p[2] = (y % 8 == 2) ? 255 : 0; + p[3] = (y % 8 == 3) ? 255 : 0; + p[4] = (y % 8 == 4) ? 255 : 0; + p[5] = (y % 8 == 5) ? 255 : 0; + p[6] = (y % 8 == 6) ? 255 : 0; + p[7] = (y % 8 == 7) ? 255 : 0; + break; + + case Orthanc::Endianness_Big: + p[0] = (y % 8 == 1) ? 255 : 0; + p[1] = (y % 8 == 0) ? 255 : 0; + p[2] = (y % 8 == 3) ? 255 : 0; + p[3] = (y % 8 == 2) ? 255 : 0; + p[4] = (y % 8 == 5) ? 255 : 0; + p[5] = (y % 8 == 4) ? 255 : 0; + p[6] = (y % 8 == 7) ? 255 : 0; + p[7] = (y % 8 == 6) ? 255 : 0; + break; + + default: + throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); + } } }