Mercurial > hg > orthanc
comparison OrthancFramework/UnitTestsSources/ImageTests.cpp @ 5054:255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 08 Jul 2022 15:26:52 +0200 |
parents | 43e613a7756b |
children | 0ea402b4d901 |
comparison
equal
deleted
inserted
replaced
5053:1e435be86887 | 5054:255b02c68908 |
---|---|
81 std::string md5; | 81 std::string md5; |
82 Orthanc::Toolbox::ComputeMD5(md5, f); | 82 Orthanc::Toolbox::ComputeMD5(md5, f); |
83 ASSERT_EQ("604e785f53c99cae6ea4584870b2c41d", md5); | 83 ASSERT_EQ("604e785f53c99cae6ea4584870b2c41d", md5); |
84 } | 84 } |
85 | 85 |
86 TEST(PngWriter, Color16Pattern) | |
87 { | |
88 Orthanc::PngWriter w; | |
89 unsigned int width = 17; | |
90 unsigned int height = 61; | |
91 unsigned int pitch = width * 8; | |
92 | |
93 std::vector<uint8_t> image(height * pitch); | |
94 for (unsigned int y = 0; y < height; y++) | |
95 { | |
96 uint8_t *p = &image[0] + y * pitch; | |
97 for (unsigned int x = 0; x < width; x++, p += 8) | |
98 { | |
99 p[0] = (y % 8 == 0) ? 255 : 0; | |
100 p[1] = (y % 8 == 1) ? 255 : 0; | |
101 p[2] = (y % 8 == 2) ? 255 : 0; | |
102 p[3] = (y % 8 == 3) ? 255 : 0; | |
103 p[4] = (y % 8 == 4) ? 255 : 0; | |
104 p[5] = (y % 8 == 5) ? 255 : 0; | |
105 p[6] = (y % 8 == 6) ? 255 : 0; | |
106 p[7] = (y % 8 == 7) ? 255 : 0; | |
107 } | |
108 } | |
109 | |
110 Orthanc::ImageAccessor accessor; | |
111 accessor.AssignReadOnly(Orthanc::PixelFormat_RGBA64, width, height, pitch, &image[0]); | |
112 | |
113 std::string f; | |
114 | |
115 #if ORTHANC_SANDBOXED == 1 | |
116 Orthanc::IImageWriter::WriteToMemory(w, f, accessor); | |
117 #else | |
118 Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Color16Pattern.png", accessor); | |
119 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Color16Pattern.png"); | |
120 #endif | |
121 | |
122 std::string md5; | |
123 Orthanc::Toolbox::ComputeMD5(md5, f); | |
124 ASSERT_EQ("1cca552b6bd152b6fdab35c4a9f02c2a", md5); | |
125 } | |
126 | |
86 | 127 |
87 TEST(PngWriter, Gray8Pattern) | 128 TEST(PngWriter, Gray8Pattern) |
88 { | 129 { |
89 Orthanc::PngWriter w; | 130 Orthanc::PngWriter w; |
90 int width = 17; | 131 int width = 17; |