Mercurial > hg > orthanc
annotate UnitTestsSources/ImageTests.cpp @ 3366:7a4d586caf2d
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 13 May 2019 16:04:45 +0200 |
parents | 6fd38327e777 |
children | 94f4a18a79cc |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3060
4e43e67f8ecf
preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
6 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
10 * License, or (at your option) any later version. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
11 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
13 * program give permission to link the code of its release with the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
22 * in the program, then also delete it here. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
23 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
27 * General Public License for more details. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
28 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
31 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
32 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
33 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
827
diff
changeset
|
34 #include "PrecompiledHeadersUnitTests.h" |
368 | 35 #include "gtest/gtest.h" |
36 | |
1612
96582230ddcb
Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
37 #include "../Core/Images/Font.h" |
96582230ddcb
Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
38 #include "../Core/Images/Image.h" |
96582230ddcb
Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
39 #include "../Core/Images/ImageProcessing.h" |
96582230ddcb
Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
40 #include "../Core/Images/JpegReader.h" |
96582230ddcb
Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
41 #include "../Core/Images/JpegWriter.h" |
96582230ddcb
Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
42 #include "../Core/Images/PngReader.h" |
96582230ddcb
Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
43 #include "../Core/Images/PngWriter.h" |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
44 #include "../Core/Images/PamReader.h" |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
45 #include "../Core/Images/PamWriter.h" |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2707
diff
changeset
|
46 #include "../Core/SystemToolbox.h" |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
47 #include "../Core/Toolbox.h" |
2142 | 48 #include "../Core/TemporaryFile.h" |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2707
diff
changeset
|
49 #include "../OrthancServer/OrthancConfiguration.h" // For the FontRegistry |
1610
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
50 |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
51 #include <stdint.h> |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
52 |
368 | 53 |
54 TEST(PngWriter, ColorPattern) | |
55 { | |
56 Orthanc::PngWriter w; | |
1654
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
57 unsigned int width = 17; |
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
58 unsigned int height = 61; |
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
59 unsigned int pitch = width * 3; |
368 | 60 |
61 std::vector<uint8_t> image(height * pitch); | |
1654
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
62 for (unsigned int y = 0; y < height; y++) |
368 | 63 { |
64 uint8_t *p = &image[0] + y * pitch; | |
1654
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
65 for (unsigned int x = 0; x < width; x++, p += 3) |
368 | 66 { |
67 p[0] = (y % 3 == 0) ? 255 : 0; | |
68 p[1] = (y % 3 == 1) ? 255 : 0; | |
69 p[2] = (y % 3 == 2) ? 255 : 0; | |
70 } | |
71 } | |
72 | |
1916 | 73 Orthanc::ImageAccessor accessor; |
74 accessor.AssignReadOnly(Orthanc::PixelFormat_RGB24, width, height, pitch, &image[0]); | |
75 | |
76 w.WriteToFile("UnitTestsResults/ColorPattern.png", accessor); | |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
77 |
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
78 std::string f, md5; |
2140 | 79 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/ColorPattern.png"); |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
80 Orthanc::Toolbox::ComputeMD5(md5, f); |
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
81 ASSERT_EQ("604e785f53c99cae6ea4584870b2c41d", md5); |
368 | 82 } |
83 | |
84 TEST(PngWriter, Gray8Pattern) | |
85 { | |
86 Orthanc::PngWriter w; | |
87 int width = 17; | |
88 int height = 256; | |
89 int pitch = width; | |
90 | |
91 std::vector<uint8_t> image(height * pitch); | |
92 for (int y = 0; y < height; y++) | |
93 { | |
94 uint8_t *p = &image[0] + y * pitch; | |
95 for (int x = 0; x < width; x++, p++) | |
96 { | |
97 *p = y; | |
98 } | |
99 } | |
100 | |
1916 | 101 Orthanc::ImageAccessor accessor; |
102 accessor.AssignReadOnly(Orthanc::PixelFormat_Grayscale8, width, height, pitch, &image[0]); | |
103 | |
104 w.WriteToFile("UnitTestsResults/Gray8Pattern.png", accessor); | |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
105 |
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
106 std::string f, md5; |
2140 | 107 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray8Pattern.png"); |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
108 Orthanc::Toolbox::ComputeMD5(md5, f); |
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
109 ASSERT_EQ("5a9b98bea3d0a6d983980cc38bfbcdb3", md5); |
368 | 110 } |
111 | |
112 TEST(PngWriter, Gray16Pattern) | |
113 { | |
114 Orthanc::PngWriter w; | |
115 int width = 256; | |
116 int height = 256; | |
369
4632a044746e
simplification of the code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
117 int pitch = width * 2 + 16; |
368 | 118 |
119 std::vector<uint8_t> image(height * pitch); | |
369
4632a044746e
simplification of the code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
120 |
368 | 121 int v = 0; |
122 for (int y = 0; y < height; y++) | |
123 { | |
124 uint16_t *p = reinterpret_cast<uint16_t*>(&image[0] + y * pitch); | |
125 for (int x = 0; x < width; x++, p++, v++) | |
126 { | |
127 *p = v; | |
128 } | |
129 } | |
130 | |
1916 | 131 Orthanc::ImageAccessor accessor; |
132 accessor.AssignReadOnly(Orthanc::PixelFormat_Grayscale16, width, height, pitch, &image[0]); | |
133 w.WriteToFile("UnitTestsResults/Gray16Pattern.png", accessor); | |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
134 |
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
135 std::string f, md5; |
2140 | 136 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray16Pattern.png"); |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
137 Orthanc::Toolbox::ComputeMD5(md5, f); |
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
138 ASSERT_EQ("0785866a08bf0a02d2eeff87f658571c", md5); |
368 | 139 } |
455 | 140 |
141 TEST(PngWriter, EndToEnd) | |
142 { | |
143 Orthanc::PngWriter w; | |
1492 | 144 unsigned int width = 256; |
145 unsigned int height = 256; | |
146 unsigned int pitch = width * 2 + 16; | |
455 | 147 |
148 std::vector<uint8_t> image(height * pitch); | |
149 | |
150 int v = 0; | |
1492 | 151 for (unsigned int y = 0; y < height; y++) |
455 | 152 { |
153 uint16_t *p = reinterpret_cast<uint16_t*>(&image[0] + y * pitch); | |
1492 | 154 for (unsigned int x = 0; x < width; x++, p++, v++) |
455 | 155 { |
156 *p = v; | |
157 } | |
158 } | |
159 | |
1916 | 160 Orthanc::ImageAccessor accessor; |
161 accessor.AssignReadOnly(Orthanc::PixelFormat_Grayscale16, width, height, pitch, &image[0]); | |
162 | |
455 | 163 std::string s; |
1916 | 164 w.WriteToMemory(s, accessor); |
455 | 165 |
709 | 166 { |
167 Orthanc::PngReader r; | |
168 r.ReadFromMemory(s); | |
455 | 169 |
710 | 170 ASSERT_EQ(r.GetFormat(), Orthanc::PixelFormat_Grayscale16); |
709 | 171 ASSERT_EQ(r.GetWidth(), width); |
172 ASSERT_EQ(r.GetHeight(), height); | |
455 | 173 |
709 | 174 v = 0; |
1492 | 175 for (unsigned int y = 0; y < height; y++) |
709 | 176 { |
797
37adac56017a
ImageAccessor abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
177 const uint16_t *p = reinterpret_cast<const uint16_t*>((const uint8_t*) r.GetConstBuffer() + y * r.GetPitch()); |
37adac56017a
ImageAccessor abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
178 ASSERT_EQ(p, r.GetConstRow(y)); |
1492 | 179 for (unsigned int x = 0; x < width; x++, p++, v++) |
709 | 180 { |
181 ASSERT_EQ(*p, v); | |
182 } | |
183 } | |
184 } | |
185 | |
455 | 186 { |
2140 | 187 Orthanc::TemporaryFile tmp; |
3181
6fd38327e777
Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
188 tmp.Write(s); |
709 | 189 |
190 Orthanc::PngReader r2; | |
191 r2.ReadFromFile(tmp.GetPath()); | |
192 | |
710 | 193 ASSERT_EQ(r2.GetFormat(), Orthanc::PixelFormat_Grayscale16); |
709 | 194 ASSERT_EQ(r2.GetWidth(), width); |
195 ASSERT_EQ(r2.GetHeight(), height); | |
710 | 196 |
197 v = 0; | |
1492 | 198 for (unsigned int y = 0; y < height; y++) |
455 | 199 { |
797
37adac56017a
ImageAccessor abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
200 const uint16_t *p = reinterpret_cast<const uint16_t*>((const uint8_t*) r2.GetConstBuffer() + y * r2.GetPitch()); |
37adac56017a
ImageAccessor abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
201 ASSERT_EQ(p, r2.GetConstRow(y)); |
1492 | 202 for (unsigned int x = 0; x < width; x++, p++, v++) |
709 | 203 { |
204 ASSERT_EQ(*p, v); | |
205 } | |
455 | 206 } |
207 } | |
208 } | |
1602 | 209 |
210 | |
211 | |
212 | |
213 TEST(JpegWriter, Basic) | |
214 { | |
1604 | 215 std::string s; |
216 | |
1602 | 217 { |
2107 | 218 Orthanc::Image img(Orthanc::PixelFormat_Grayscale8, 16, 16, false); |
1604 | 219 for (unsigned int y = 0, value = 0; y < img.GetHeight(); y++) |
1602 | 220 { |
1608
adc6a5704cdb
OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1604
diff
changeset
|
221 uint8_t* p = reinterpret_cast<uint8_t*>(img.GetRow(y)); |
1604 | 222 for (unsigned int x = 0; x < img.GetWidth(); x++, p++) |
223 { | |
224 *p = value++; | |
225 } | |
226 } | |
227 | |
228 Orthanc::JpegWriter w; | |
1608
adc6a5704cdb
OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1604
diff
changeset
|
229 w.WriteToFile("UnitTestsResults/hello.jpg", img); |
1604 | 230 |
1608
adc6a5704cdb
OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1604
diff
changeset
|
231 w.WriteToMemory(s, img); |
2140 | 232 Orthanc::SystemToolbox::WriteFile(s, "UnitTestsResults/hello2.jpg"); |
1604 | 233 |
234 std::string t; | |
2140 | 235 Orthanc::SystemToolbox::ReadFile(t, "UnitTestsResults/hello.jpg"); |
1604 | 236 ASSERT_EQ(s.size(), t.size()); |
237 ASSERT_EQ(0, memcmp(s.c_str(), t.c_str(), s.size())); | |
238 } | |
239 | |
240 { | |
241 Orthanc::JpegReader r1, r2; | |
242 r1.ReadFromFile("UnitTestsResults/hello.jpg"); | |
1970 | 243 ASSERT_EQ(16u, r1.GetWidth()); |
244 ASSERT_EQ(16u, r1.GetHeight()); | |
1604 | 245 |
246 r2.ReadFromMemory(s); | |
1970 | 247 ASSERT_EQ(16u, r2.GetWidth()); |
248 ASSERT_EQ(16u, r2.GetHeight()); | |
1604 | 249 |
250 for (unsigned int y = 0; y < r1.GetHeight(); y++) | |
251 { | |
252 const uint8_t* p1 = reinterpret_cast<const uint8_t*>(r1.GetConstRow(y)); | |
253 const uint8_t* p2 = reinterpret_cast<const uint8_t*>(r2.GetConstRow(y)); | |
254 for (unsigned int x = 0; x < r1.GetWidth(); x++) | |
255 { | |
256 ASSERT_EQ(*p1, *p2); | |
257 } | |
1602 | 258 } |
259 } | |
260 } | |
1610
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
261 |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
262 |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
263 TEST(Font, Basic) |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
264 { |
2107 | 265 Orthanc::Image s(Orthanc::PixelFormat_RGB24, 640, 480, false); |
1610
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
266 memset(s.GetBuffer(), 0, s.GetPitch() * s.GetHeight()); |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
267 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2707
diff
changeset
|
268 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2707
diff
changeset
|
269 Orthanc::OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2707
diff
changeset
|
270 ASSERT_GE(1u, lock.GetConfiguration().GetFontRegistry().GetSize()); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2707
diff
changeset
|
271 lock.GetConfiguration().GetFontRegistry().GetFont(0).Draw |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2707
diff
changeset
|
272 (s, "Hello world É\n\rComment ça va ?\nq", 50, 60, 255, 0, 0); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2707
diff
changeset
|
273 } |
1610
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
274 |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
275 Orthanc::PngWriter w; |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
276 w.WriteToFile("UnitTestsResults/font.png", s); |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
277 } |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
278 |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
279 TEST(PamWriter, ColorPattern) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
280 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
281 Orthanc::PamWriter w; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
282 unsigned int width = 17; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
283 unsigned int height = 61; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
284 unsigned int pitch = width * 3; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
285 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
286 std::vector<uint8_t> image(height * pitch); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
287 for (unsigned int y = 0; y < height; y++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
288 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
289 uint8_t *p = &image[0] + y * pitch; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
290 for (unsigned int x = 0; x < width; x++, p += 3) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
291 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
292 p[0] = (y % 3 == 0) ? 255 : 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
293 p[1] = (y % 3 == 1) ? 255 : 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
294 p[2] = (y % 3 == 2) ? 255 : 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
295 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
296 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
297 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
298 Orthanc::ImageAccessor accessor; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
299 accessor.AssignReadOnly(Orthanc::PixelFormat_RGB24, width, height, pitch, &image[0]); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
300 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
301 w.WriteToFile("UnitTestsResults/ColorPattern.pam", accessor); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
302 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
303 std::string f, md5; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
304 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/ColorPattern.pam"); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
305 Orthanc::Toolbox::ComputeMD5(md5, f); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
306 ASSERT_EQ("81a3441754e88969ebbe53e69891e841", md5); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
307 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
308 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
309 TEST(PamWriter, Gray8Pattern) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
310 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
311 Orthanc::PamWriter w; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
312 int width = 17; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
313 int height = 256; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
314 int pitch = width; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
315 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
316 std::vector<uint8_t> image(height * pitch); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
317 for (int y = 0; y < height; y++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
318 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
319 uint8_t *p = &image[0] + y * pitch; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
320 for (int x = 0; x < width; x++, p++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
321 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
322 *p = y; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
323 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
324 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
325 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
326 Orthanc::ImageAccessor accessor; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
327 accessor.AssignReadOnly(Orthanc::PixelFormat_Grayscale8, width, height, pitch, &image[0]); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
328 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
329 w.WriteToFile("UnitTestsResults/Gray8Pattern.pam", accessor); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
330 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
331 std::string f, md5; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
332 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray8Pattern.pam"); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
333 Orthanc::Toolbox::ComputeMD5(md5, f); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
334 ASSERT_EQ("7873c408d26a9d11dd1c1de5e69cc0a3", md5); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
335 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
336 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
337 TEST(PamWriter, Gray16Pattern) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
338 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
339 Orthanc::PamWriter w; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
340 int width = 256; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
341 int height = 256; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
342 int pitch = width * 2 + 16; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
343 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
344 std::vector<uint8_t> image(height * pitch); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
345 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
346 int v = 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
347 for (int y = 0; y < height; y++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
348 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
349 uint16_t *p = reinterpret_cast<uint16_t*>(&image[0] + y * pitch); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
350 for (int x = 0; x < width; x++, p++, v++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
351 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
352 *p = v; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
353 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
354 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
355 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
356 Orthanc::ImageAccessor accessor; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
357 accessor.AssignReadOnly(Orthanc::PixelFormat_Grayscale16, width, height, pitch, &image[0]); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
358 w.WriteToFile("UnitTestsResults/Gray16Pattern.pam", accessor); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
359 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
360 std::string f, md5; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
361 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray16Pattern.pam"); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
362 Orthanc::Toolbox::ComputeMD5(md5, f); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
363 ASSERT_EQ("b268772bf28f3b2b8520ff21c5e3dcb6", md5); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
364 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
365 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
366 TEST(PamWriter, EndToEnd) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
367 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
368 Orthanc::PamWriter w; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
369 unsigned int width = 256; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
370 unsigned int height = 256; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
371 unsigned int pitch = width * 2 + 16; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
372 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
373 std::vector<uint8_t> image(height * pitch); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
374 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
375 int v = 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
376 for (unsigned int y = 0; y < height; y++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
377 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
378 uint16_t *p = reinterpret_cast<uint16_t*>(&image[0] + y * pitch); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
379 for (unsigned int x = 0; x < width; x++, p++, v++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
380 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
381 *p = v; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
382 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
383 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
384 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
385 Orthanc::ImageAccessor accessor; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
386 accessor.AssignReadOnly(Orthanc::PixelFormat_Grayscale16, width, height, pitch, &image[0]); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
387 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
388 std::string s; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
389 w.WriteToMemory(s, accessor); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
390 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
391 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
392 Orthanc::PamReader r; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
393 r.ReadFromMemory(s); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
394 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
395 ASSERT_EQ(r.GetFormat(), Orthanc::PixelFormat_Grayscale16); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
396 ASSERT_EQ(r.GetWidth(), width); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
397 ASSERT_EQ(r.GetHeight(), height); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
398 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
399 v = 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
400 for (unsigned int y = 0; y < height; y++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
401 { |
2707 | 402 const uint16_t *p = reinterpret_cast<const uint16_t*> |
403 ((const uint8_t*) r.GetConstBuffer() + y * r.GetPitch()); | |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
404 ASSERT_EQ(p, r.GetConstRow(y)); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
405 for (unsigned int x = 0; x < width; x++, p++, v++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
406 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
407 ASSERT_EQ(v, *p); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
408 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
409 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
410 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
411 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
412 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
413 Orthanc::TemporaryFile tmp; |
3181
6fd38327e777
Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
414 tmp.Write(s); |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
415 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
416 Orthanc::PamReader r2; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
417 r2.ReadFromFile(tmp.GetPath()); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
418 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
419 ASSERT_EQ(r2.GetFormat(), Orthanc::PixelFormat_Grayscale16); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
420 ASSERT_EQ(r2.GetWidth(), width); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
421 ASSERT_EQ(r2.GetHeight(), height); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
422 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
423 v = 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
424 for (unsigned int y = 0; y < height; y++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
425 { |
2707 | 426 const uint16_t *p = reinterpret_cast<const uint16_t*> |
427 ((const uint8_t*) r2.GetConstBuffer() + y * r2.GetPitch()); | |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
428 ASSERT_EQ(p, r2.GetConstRow(y)); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
429 for (unsigned int x = 0; x < width; x++, p++, v++) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
430 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
431 ASSERT_EQ(*p, v); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
432 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
433 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
434 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
435 } |