Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/ImageTests.cpp @ 5853:4d932683049d get-scu tip
very first implementation of C-Get SCU
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 29 Oct 2024 17:25:49 +0100 |
parents | f7adfb22e20e |
children |
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 |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5368
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
8 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
10 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
11 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
12 * the License, or (at your option) any later version. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
13 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
14 * 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
|
15 * 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
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
17 * Lesser General Public License for more details. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
18 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
19 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
20 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
21 * <http://www.gnu.org/licenses/>. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
22 **/ |
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 |
4046
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
25 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
26 // Must be the first to be sure to use the Orthanc framework shared library |
4046
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
27 # include <OrthancFramework.h> |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
28 #endif |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
29 |
4062 | 30 #include <gtest/gtest.h> |
368 | 31 |
4046
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
32 #include "../Sources/Images/Font.h" |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
33 #include "../Sources/Images/Image.h" |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
34 #include "../Sources/Images/ImageProcessing.h" |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
35 #include "../Sources/Images/JpegReader.h" |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
36 #include "../Sources/Images/JpegWriter.h" |
5368
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
37 #include "../Sources/Images/PamReader.h" |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
38 #include "../Sources/Images/PamWriter.h" |
4046
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
39 #include "../Sources/Images/PngReader.h" |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
40 #include "../Sources/Images/PngWriter.h" |
5368
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
41 #include "../Sources/OrthancException.h" |
4046
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
42 #include "../Sources/Toolbox.h" |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
43 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
44 #if ORTHANC_SANDBOXED != 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
45 # include "../Sources/SystemToolbox.h" |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
46 # include "../Sources/TemporaryFile.h" |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
47 #endif |
1610
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
48 |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
49 #include <stdint.h> |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
50 |
368 | 51 |
52 TEST(PngWriter, ColorPattern) | |
53 { | |
54 Orthanc::PngWriter w; | |
1654
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
55 unsigned int width = 17; |
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
56 unsigned int height = 61; |
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
57 unsigned int pitch = width * 3; |
368 | 58 |
59 std::vector<uint8_t> image(height * pitch); | |
1654
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
60 for (unsigned int y = 0; y < height; y++) |
368 | 61 { |
62 uint8_t *p = &image[0] + y * pitch; | |
1654
3727a09e7b53
fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1612
diff
changeset
|
63 for (unsigned int x = 0; x < width; x++, p += 3) |
368 | 64 { |
65 p[0] = (y % 3 == 0) ? 255 : 0; | |
66 p[1] = (y % 3 == 1) ? 255 : 0; | |
67 p[2] = (y % 3 == 2) ? 255 : 0; | |
68 } | |
69 } | |
70 | |
1916 | 71 Orthanc::ImageAccessor accessor; |
72 accessor.AssignReadOnly(Orthanc::PixelFormat_RGB24, width, height, pitch, &image[0]); | |
73 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
74 std::string f; |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
75 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
76 #if ORTHANC_SANDBOXED == 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
77 Orthanc::IImageWriter::WriteToMemory(w, f, accessor); |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
78 #else |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
79 Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/ColorPattern.png", accessor); |
2140 | 80 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/ColorPattern.png"); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
81 #endif |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
82 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
83 std::string md5; |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
84 Orthanc::Toolbox::ComputeMD5(md5, f); |
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
85 ASSERT_EQ("604e785f53c99cae6ea4584870b2c41d", md5); |
368 | 86 } |
87 | |
5054
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
88 TEST(PngWriter, Color16Pattern) |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
89 { |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
90 Orthanc::PngWriter w; |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
91 unsigned int width = 17; |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
92 unsigned int height = 61; |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
93 unsigned int pitch = width * 8; |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
94 |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
95 std::vector<uint8_t> image(height * pitch); |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
96 for (unsigned int y = 0; y < height; y++) |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
97 { |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
98 uint8_t *p = &image[0] + y * pitch; |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
99 for (unsigned int x = 0; x < width; x++, p += 8) |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
100 { |
5368
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
101 switch (Orthanc::Toolbox::DetectEndianness()) |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
102 { |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
103 case Orthanc::Endianness_Little: |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
104 p[0] = (y % 8 == 0) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
105 p[1] = (y % 8 == 1) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
106 p[2] = (y % 8 == 2) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
107 p[3] = (y % 8 == 3) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
108 p[4] = (y % 8 == 4) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
109 p[5] = (y % 8 == 5) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
110 p[6] = (y % 8 == 6) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
111 p[7] = (y % 8 == 7) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
112 break; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
113 |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
114 case Orthanc::Endianness_Big: |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
115 p[0] = (y % 8 == 1) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
116 p[1] = (y % 8 == 0) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
117 p[2] = (y % 8 == 3) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
118 p[3] = (y % 8 == 2) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
119 p[4] = (y % 8 == 5) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
120 p[5] = (y % 8 == 4) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
121 p[6] = (y % 8 == 7) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
122 p[7] = (y % 8 == 6) ? 255 : 0; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
123 break; |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
124 |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
125 default: |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
126 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
91b3154bd4e1
Fix unit test PngWriter.Color16Pattern on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
127 } |
5054
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
128 } |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
129 } |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
130 |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
131 Orthanc::ImageAccessor accessor; |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
132 accessor.AssignReadOnly(Orthanc::PixelFormat_RGBA64, width, height, pitch, &image[0]); |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
133 |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
134 std::string f; |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
135 |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
136 #if ORTHANC_SANDBOXED == 1 |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
137 Orthanc::IImageWriter::WriteToMemory(w, f, accessor); |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
138 #else |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
139 Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Color16Pattern.png", accessor); |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
140 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Color16Pattern.png"); |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
141 #endif |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
142 |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
143 std::string md5; |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
144 Orthanc::Toolbox::ComputeMD5(md5, f); |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
145 ASSERT_EQ("1cca552b6bd152b6fdab35c4a9f02c2a", md5); |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
146 } |
255b02c68908
Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
147 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
148 |
368 | 149 TEST(PngWriter, Gray8Pattern) |
150 { | |
151 Orthanc::PngWriter w; | |
152 int width = 17; | |
153 int height = 256; | |
154 int pitch = width; | |
155 | |
156 std::vector<uint8_t> image(height * pitch); | |
157 for (int y = 0; y < height; y++) | |
158 { | |
159 uint8_t *p = &image[0] + y * pitch; | |
160 for (int x = 0; x < width; x++, p++) | |
161 { | |
162 *p = y; | |
163 } | |
164 } | |
165 | |
1916 | 166 Orthanc::ImageAccessor accessor; |
167 accessor.AssignReadOnly(Orthanc::PixelFormat_Grayscale8, width, height, pitch, &image[0]); | |
168 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
169 std::string f; |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
170 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
171 #if ORTHANC_SANDBOXED == 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
172 Orthanc::IImageWriter::WriteToMemory(w, f, accessor); |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
173 #else |
4311
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
174 Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Gray8Pattern.png", accessor); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
175 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray8Pattern.png"); |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
176 #endif |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
177 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
178 std::string md5; |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
179 Orthanc::Toolbox::ComputeMD5(md5, f); |
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
180 ASSERT_EQ("5a9b98bea3d0a6d983980cc38bfbcdb3", md5); |
368 | 181 } |
182 | |
183 TEST(PngWriter, Gray16Pattern) | |
184 { | |
185 Orthanc::PngWriter w; | |
186 int width = 256; | |
187 int height = 256; | |
369
4632a044746e
simplification of the code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
188 int pitch = width * 2 + 16; |
368 | 189 |
190 std::vector<uint8_t> image(height * pitch); | |
369
4632a044746e
simplification of the code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
191 |
368 | 192 int v = 0; |
193 for (int y = 0; y < height; y++) | |
194 { | |
195 uint16_t *p = reinterpret_cast<uint16_t*>(&image[0] + y * pitch); | |
196 for (int x = 0; x < width; x++, p++, v++) | |
197 { | |
198 *p = v; | |
199 } | |
200 } | |
201 | |
1916 | 202 Orthanc::ImageAccessor accessor; |
203 accessor.AssignReadOnly(Orthanc::PixelFormat_Grayscale16, width, height, pitch, &image[0]); | |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
204 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
205 std::string f; |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
206 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
207 #if ORTHANC_SANDBOXED == 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
208 Orthanc::IImageWriter::WriteToMemory(w, f, accessor); |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
209 #else |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
210 Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Gray16Pattern.png", accessor); |
2140 | 211 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray16Pattern.png"); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
212 #endif |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
213 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
214 std::string md5; |
639
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
215 Orthanc::Toolbox::ComputeMD5(md5, f); |
51892be15618
fix for big endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
632
diff
changeset
|
216 ASSERT_EQ("0785866a08bf0a02d2eeff87f658571c", md5); |
368 | 217 } |
455 | 218 |
219 TEST(PngWriter, EndToEnd) | |
220 { | |
221 Orthanc::PngWriter w; | |
1492 | 222 unsigned int width = 256; |
223 unsigned int height = 256; | |
224 unsigned int pitch = width * 2 + 16; | |
455 | 225 |
226 std::vector<uint8_t> image(height * pitch); | |
227 | |
228 int v = 0; | |
1492 | 229 for (unsigned int y = 0; y < height; y++) |
455 | 230 { |
231 uint16_t *p = reinterpret_cast<uint16_t*>(&image[0] + y * pitch); | |
1492 | 232 for (unsigned int x = 0; x < width; x++, p++, v++) |
455 | 233 { |
234 *p = v; | |
235 } | |
236 } | |
237 | |
1916 | 238 Orthanc::ImageAccessor accessor; |
239 accessor.AssignReadOnly(Orthanc::PixelFormat_Grayscale16, width, height, pitch, &image[0]); | |
240 | |
455 | 241 std::string s; |
4311
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
242 Orthanc::IImageWriter::WriteToMemory(w, s, accessor); |
455 | 243 |
709 | 244 { |
245 Orthanc::PngReader r; | |
246 r.ReadFromMemory(s); | |
455 | 247 |
710 | 248 ASSERT_EQ(r.GetFormat(), Orthanc::PixelFormat_Grayscale16); |
709 | 249 ASSERT_EQ(r.GetWidth(), width); |
250 ASSERT_EQ(r.GetHeight(), height); | |
455 | 251 |
709 | 252 v = 0; |
1492 | 253 for (unsigned int y = 0; y < height; y++) |
709 | 254 { |
797
37adac56017a
ImageAccessor abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
255 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
|
256 ASSERT_EQ(p, r.GetConstRow(y)); |
1492 | 257 for (unsigned int x = 0; x < width; x++, p++, v++) |
709 | 258 { |
259 ASSERT_EQ(*p, v); | |
260 } | |
261 } | |
262 } | |
263 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
264 #if ORTHANC_SANDBOXED != 1 |
455 | 265 { |
2140 | 266 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
|
267 tmp.Write(s); |
709 | 268 |
269 Orthanc::PngReader r2; | |
270 r2.ReadFromFile(tmp.GetPath()); | |
271 | |
710 | 272 ASSERT_EQ(r2.GetFormat(), Orthanc::PixelFormat_Grayscale16); |
709 | 273 ASSERT_EQ(r2.GetWidth(), width); |
274 ASSERT_EQ(r2.GetHeight(), height); | |
710 | 275 |
276 v = 0; | |
1492 | 277 for (unsigned int y = 0; y < height; y++) |
455 | 278 { |
797
37adac56017a
ImageAccessor abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
279 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
|
280 ASSERT_EQ(p, r2.GetConstRow(y)); |
1492 | 281 for (unsigned int x = 0; x < width; x++, p++, v++) |
709 | 282 { |
283 ASSERT_EQ(*p, v); | |
284 } | |
455 | 285 } |
286 } | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
287 #endif |
455 | 288 } |
1602 | 289 |
290 | |
291 | |
292 | |
293 TEST(JpegWriter, Basic) | |
294 { | |
1604 | 295 std::string s; |
296 | |
1602 | 297 { |
2107 | 298 Orthanc::Image img(Orthanc::PixelFormat_Grayscale8, 16, 16, false); |
1604 | 299 for (unsigned int y = 0, value = 0; y < img.GetHeight(); y++) |
1602 | 300 { |
1608
adc6a5704cdb
OrthancPluginConvertPixelFormat
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1604
diff
changeset
|
301 uint8_t* p = reinterpret_cast<uint8_t*>(img.GetRow(y)); |
1604 | 302 for (unsigned int x = 0; x < img.GetWidth(); x++, p++) |
303 { | |
304 *p = value++; | |
305 } | |
306 } | |
307 | |
308 Orthanc::JpegWriter w; | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
309 Orthanc::IImageWriter::WriteToMemory(w, s, img); |
1604 | 310 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
311 #if ORTHANC_SANDBOXED != 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
312 Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/hello.jpg", img); |
2140 | 313 Orthanc::SystemToolbox::WriteFile(s, "UnitTestsResults/hello2.jpg"); |
1604 | 314 |
315 std::string t; | |
2140 | 316 Orthanc::SystemToolbox::ReadFile(t, "UnitTestsResults/hello.jpg"); |
1604 | 317 ASSERT_EQ(s.size(), t.size()); |
318 ASSERT_EQ(0, memcmp(s.c_str(), t.c_str(), s.size())); | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
319 #endif |
1604 | 320 } |
321 | |
322 { | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
323 Orthanc::JpegReader r1; |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
324 r1.ReadFromMemory(s); |
1970 | 325 ASSERT_EQ(16u, r1.GetWidth()); |
326 ASSERT_EQ(16u, r1.GetHeight()); | |
1604 | 327 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
328 #if ORTHANC_SANDBOXED != 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
329 Orthanc::JpegReader r2; |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
330 r2.ReadFromFile("UnitTestsResults/hello.jpg"); |
1970 | 331 ASSERT_EQ(16u, r2.GetWidth()); |
332 ASSERT_EQ(16u, r2.GetHeight()); | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
333 #endif |
1604 | 334 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
335 unsigned int value = 0; |
1604 | 336 for (unsigned int y = 0; y < r1.GetHeight(); y++) |
337 { | |
338 const uint8_t* p1 = reinterpret_cast<const uint8_t*>(r1.GetConstRow(y)); | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
339 #if ORTHANC_SANDBOXED != 1 |
1604 | 340 const uint8_t* p2 = reinterpret_cast<const uint8_t*>(r2.GetConstRow(y)); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
341 #endif |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
342 for (unsigned int x = 0; x < r1.GetWidth(); x++, value++) |
1604 | 343 { |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
344 ASSERT_TRUE(*p1 == value || |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
345 *p1 == value - 1 || |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
346 *p1 == value + 1); // Be tolerant to differences of +-1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
347 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
348 #if ORTHANC_SANDBOXED != 1 |
1604 | 349 ASSERT_EQ(*p1, *p2); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
350 p2++; |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
351 #endif |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
352 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
353 p1++; |
1604 | 354 } |
1602 | 355 } |
356 } | |
357 } | |
1610
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
358 |
2dff2bdffdb8
font support within Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1608
diff
changeset
|
359 |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
360 TEST(PamWriter, ColorPattern) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
361 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
362 Orthanc::PamWriter w; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
363 unsigned int width = 17; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
364 unsigned int height = 61; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
365 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
|
366 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
367 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
|
368 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
|
369 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
370 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
|
371 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
|
372 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
373 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
|
374 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
|
375 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
|
376 } |
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 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
379 Orthanc::ImageAccessor accessor; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
380 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
|
381 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
382 std::string f; |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
383 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
384 #if ORTHANC_SANDBOXED == 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
385 Orthanc::IImageWriter::WriteToMemory(w, f, accessor); |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
386 #else |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
387 Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/ColorPattern.pam", accessor); |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
388 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/ColorPattern.pam"); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
389 #endif |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
390 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
391 std::string md5; |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
392 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
|
393 ASSERT_EQ("81a3441754e88969ebbe53e69891e841", md5); |
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 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
396 TEST(PamWriter, Gray8Pattern) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
397 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
398 Orthanc::PamWriter w; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
399 int width = 17; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
400 int height = 256; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
401 int pitch = width; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
402 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
403 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
|
404 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
|
405 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
406 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
|
407 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
|
408 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
409 *p = y; |
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::ImageAccessor accessor; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
414 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
|
415 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
416 std::string f; |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
417 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
418 #if ORTHANC_SANDBOXED == 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
419 Orthanc::IImageWriter::WriteToMemory(w, f, accessor); |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
420 #else |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
421 Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Gray8Pattern.pam", accessor); |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
422 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray8Pattern.pam"); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
423 #endif |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
424 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
425 std::string md5; |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
426 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
|
427 ASSERT_EQ("7873c408d26a9d11dd1c1de5e69cc0a3", md5); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
428 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
429 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
430 TEST(PamWriter, Gray16Pattern) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
431 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
432 Orthanc::PamWriter w; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
433 int width = 256; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
434 int height = 256; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
435 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
|
436 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
437 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
|
438 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
439 int v = 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
440 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
|
441 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
442 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
|
443 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
|
444 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
445 *p = v; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
446 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
447 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
448 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
449 Orthanc::ImageAccessor accessor; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
450 accessor.AssignReadOnly(Orthanc::PixelFormat_Grayscale16, width, height, pitch, &image[0]); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
451 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
452 std::string f; |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
453 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
454 #if ORTHANC_SANDBOXED == 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
455 Orthanc::IImageWriter::WriteToMemory(w, f, accessor); |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
456 #else |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
457 Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Gray16Pattern.pam", accessor); |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
458 Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray16Pattern.pam"); |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
459 #endif |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
460 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
461 std::string md5; |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
462 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
|
463 ASSERT_EQ("b268772bf28f3b2b8520ff21c5e3dcb6", md5); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
464 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
465 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
466 TEST(PamWriter, EndToEnd) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
467 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
468 Orthanc::PamWriter w; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
469 unsigned int width = 256; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
470 unsigned int height = 256; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
471 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
|
472 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
473 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
|
474 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
475 int v = 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
476 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
|
477 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
478 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
|
479 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
|
480 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
481 *p = v; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
482 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
483 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
484 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
485 Orthanc::ImageAccessor accessor; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
486 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
|
487 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
488 std::string s; |
4311
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4211
diff
changeset
|
489 Orthanc::IImageWriter::WriteToMemory(w, s, accessor); |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
490 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
491 { |
4211
afad57ac30ef
enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
492 Orthanc::PamReader r(true); |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
493 r.ReadFromMemory(s); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
494 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
495 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
|
496 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
|
497 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
|
498 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
499 v = 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
500 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
|
501 { |
2707 | 502 const uint16_t *p = reinterpret_cast<const uint16_t*> |
503 ((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
|
504 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
|
505 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
|
506 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
507 ASSERT_EQ(v, *p); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
508 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
509 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
510 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
511 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
512 { |
3834
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
513 // true means "enforce alignment by using a temporary buffer" |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
514 Orthanc::PamReader r(true); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
515 r.ReadFromMemory(s); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
516 |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
517 ASSERT_EQ(r.GetFormat(), Orthanc::PixelFormat_Grayscale16); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
518 ASSERT_EQ(r.GetWidth(), width); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
519 ASSERT_EQ(r.GetHeight(), height); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
520 |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
521 v = 0; |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
522 for (unsigned int y = 0; y < height; y++) |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
523 { |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
524 const uint16_t* p = reinterpret_cast<const uint16_t*> |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
525 ((const uint8_t*)r.GetConstBuffer() + y * r.GetPitch()); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
526 ASSERT_EQ(p, r.GetConstRow(y)); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
527 for (unsigned int x = 0; x < width; x++, p++, v++) |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
528 { |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
529 ASSERT_EQ(v, *p); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
530 } |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
531 } |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
532 } |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
533 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
534 #if ORTHANC_SANDBOXED != 1 |
3834
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
535 { |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
536 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
|
537 tmp.Write(s); |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
538 |
4211
afad57ac30ef
enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
539 Orthanc::PamReader r2(true); |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
540 r2.ReadFromFile(tmp.GetPath()); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
541 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
542 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
|
543 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
|
544 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
|
545 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
546 v = 0; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
547 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
|
548 { |
2707 | 549 const uint16_t *p = reinterpret_cast<const uint16_t*> |
550 ((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
|
551 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
|
552 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
|
553 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
554 ASSERT_EQ(*p, v); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
555 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
556 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
557 } |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
558 #endif |
3834
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
559 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
560 #if ORTHANC_SANDBOXED != 1 |
3834
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
561 { |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
562 Orthanc::TemporaryFile tmp; |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
563 tmp.Write(s); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
564 |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
565 // true means "enforce alignment by using a temporary buffer" |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
566 Orthanc::PamReader r2(true); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
567 r2.ReadFromFile(tmp.GetPath()); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
568 |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
569 ASSERT_EQ(r2.GetFormat(), Orthanc::PixelFormat_Grayscale16); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
570 ASSERT_EQ(r2.GetWidth(), width); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
571 ASSERT_EQ(r2.GetHeight(), height); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
572 |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
573 v = 0; |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
574 for (unsigned int y = 0; y < height; y++) |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
575 { |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
576 const uint16_t* p = reinterpret_cast<const uint16_t*> |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
577 ((const uint8_t*)r2.GetConstBuffer() + y * r2.GetPitch()); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
578 ASSERT_EQ(p, r2.GetConstRow(y)); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
579 for (unsigned int x = 0; x < width; x++, p++, v++) |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
580 { |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
581 ASSERT_EQ(*p, v); |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
582 } |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
583 } |
219de90c1f43
Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents:
3640
diff
changeset
|
584 } |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4311
diff
changeset
|
585 #endif |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2447
diff
changeset
|
586 } |
4642
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
587 |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
588 |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
589 TEST(PngWriter, Gray16Then8) |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
590 { |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
591 Orthanc::Image image16(Orthanc::PixelFormat_Grayscale16, 32, 32, false); |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
592 Orthanc::Image image8(Orthanc::PixelFormat_Grayscale8, 32, 32, false); |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
593 |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
594 memset(image16.GetBuffer(), 0, image16.GetHeight() * image16.GetPitch()); |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
595 memset(image8.GetBuffer(), 0, image8.GetHeight() * image8.GetPitch()); |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
596 |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
597 { |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
598 Orthanc::PamWriter w; |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
599 std::string s; |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
600 Orthanc::IImageWriter::WriteToMemory(w, s, image16); |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
601 Orthanc::IImageWriter::WriteToMemory(w, s, image8); // No problem here |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
602 } |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
603 |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
604 { |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
605 Orthanc::PamWriter w; |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
606 std::string s; |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
607 Orthanc::IImageWriter::WriteToMemory(w, s, image8); |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
608 Orthanc::IImageWriter::WriteToMemory(w, s, image16); // No problem here |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
609 } |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
610 |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
611 { |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
612 Orthanc::PngWriter w; |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
613 std::string s; |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
614 Orthanc::IImageWriter::WriteToMemory(w, s, image8); |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
615 Orthanc::IImageWriter::WriteToMemory(w, s, image16); // No problem here |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
616 } |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
617 |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
618 { |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
619 // The following call leads to "Invalid read of size 1" in Orthanc <= 1.9.2 |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
620 Orthanc::PngWriter w; |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
621 std::string s; |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
622 Orthanc::IImageWriter::WriteToMemory(w, s, image16); |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
623 Orthanc::IImageWriter::WriteToMemory(w, s, image8); // Problem here |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
624 } |
69bbb4bd35cb
PngWriter recreates a new libpng context for each encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
625 } |