annotate OrthancStone/UnitTestsSources/PixelTestPatternsTests.cpp @ 2049:85ab86f10d01 deep-learning

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 16 Mar 2023 21:28:22 +0100
parents a2955abe4c2e
children 07964689cb0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Stone of Orthanc
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1871
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 *
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
1877
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 * the License, or (at your option) any later version.
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 *
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
1877
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
16 * Lesser General Public License for more details.
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 *
1877
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
19 * License along with this program. If not, see
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
20 * <http://www.gnu.org/licenses/>.
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 **/
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1298
diff changeset
23
1877
a2955abe4c2e skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
24 #include "../Sources/Toolbox/PixelTestPatterns.h"
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1298
diff changeset
25
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1298
diff changeset
26 #include <Images/Image.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1298
diff changeset
27 #include <Images/PngWriter.h>
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29 #include <boost/chrono.hpp>
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30 #include <boost/lexical_cast.hpp>
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1298
diff changeset
32 #include <gtest/gtest.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1298
diff changeset
33 #include <stdint.h>
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 #include <cmath>
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 /* Autogenerated from prout.png */
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 static const unsigned char bin2c_SimpleRedBlueHGradient_png[391] = "\211PNG\15\12\32\12\0\0\0\15IHDR\0\0\0\200\0\0\0\200\10\6\0\0\0\303>a\313\0\0\1MIDATx\234\355\322\1\15\3000\0\303\260~\3741o\7\342X\12\203|o{wgev\26Z\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p\15\200k\0\\\3\340\32\0\327\0\270\6\3005\0\256\1p?\314\262\201\3760\355r\262\0\0\0\0IEND\256B`\202";
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 TEST(PixelTestPatterns, SimpleRedHGradient)
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 {
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1282
diff changeset
41 std::unique_ptr<Orthanc::Image> texture;
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 texture.reset(new Orthanc::Image(
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 Orthanc::PixelFormat_RGBA32,
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 128,
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 128,
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 /*forceMinimalPitch*/false));
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49 Orthanc::ImageAccessor target;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 texture->GetWriteableAccessor(target);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 OrthancStone::PixelTestPatterns::fillWithHGradient(target,255,0,0,0,0,255);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 Orthanc::PngWriter writer;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 #if 0
1629
7fc8a3ff09ee fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
56 Orthanc::IImageWriter::WriteToFile(writer, "SimpleRedBlueHGradient.png", *texture);
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 #else
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 std::string contents;
1629
7fc8a3ff09ee fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
59 Orthanc::IImageWriter::WriteToMemory(writer, contents, *texture);
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 ASSERT_EQ(1u, sizeof(unsigned char));
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 ASSERT_EQ(391u, sizeof(bin2c_SimpleRedBlueHGradient_png));
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 ASSERT_EQ(390u, contents.size());
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 char* resultPngBytes = &(contents[0]);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 int result = memcmp(resultPngBytes, bin2c_SimpleRedBlueHGradient_png, 390);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 ASSERT_EQ(0, result);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 #endif
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 }
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 static const unsigned char bin2c_SimpleRedBlueVGradient_png[400] = "\211PNG\15\12\32\12\0\0\0\15IHDR\0\0\0\200\0\0\0\200\10\6\0\0\0\303>a\313\0\0\1VIDATx\234\355\322A\21\3000\14\300\260t7\376\220\327\301\310\303\22\2?|\356\314\35\262\336o\236\355\6\26\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\14\20g\2008\3\304\31 \316\0q\6\2103@\234\1\342\316\231\357nG\260\347\7\221\255\203\367~A)\36\0\0\0\0IEND\256B`\202";
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 TEST(PixelTestPatterns, SimpleRedBlueVGradient)
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 {
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1282
diff changeset
77 std::unique_ptr<Orthanc::Image> texture;
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 texture.reset(new Orthanc::Image(
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 Orthanc::PixelFormat_RGBA32,
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81 128,
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 128,
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 /*forceMinimalPitch*/false));
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 Orthanc::ImageAccessor target;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 texture->GetWriteableAccessor(target);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 OrthancStone::PixelTestPatterns::fillWithVGradient(target, 255, 0, 0, 0, 0, 255);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 Orthanc::PngWriter writer;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 #if 0
1629
7fc8a3ff09ee fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
92 Orthanc::IImageWriter::WriteToFile(writer, "SimpleRedBlueVGradient.png", *texture);
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 #else
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 std::string contents;
1629
7fc8a3ff09ee fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
95 Orthanc::IImageWriter::WriteToMemory(writer, contents, *texture);
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 ASSERT_EQ(1u, sizeof(unsigned char));
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 ASSERT_EQ(400u, sizeof(bin2c_SimpleRedBlueVGradient_png));
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99 ASSERT_EQ(399u, contents.size());
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 char* resultPngBytes = &(contents[0]);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 int result = memcmp(resultPngBytes, bin2c_SimpleRedBlueVGradient_png, 399);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104 ASSERT_EQ(0, result);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105 #endif
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 }
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
108
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109 /* Autogenerated from MultiGradient.png */
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110 static const unsigned char bin2c_MultiGradient_png[774] = "\211PNG\15\12\32\12\0\0\0\15IHDR\0\0\1\0\0\0\0\200\10\6\0\0\0\344\265\267\12\0\0\2\314IDATx\234\355\325\301\11\3030\24\5\301/\242\376+6(E$ \314\354\30\337\215\364X\2573s\6\266\316\314\226\237\365\271}\5\227\255\331{\273\357s\373\374sY\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\25\0^\13\220\2559\347\354\231Q\337\317\372\303)\276\331Ys\377\26\256.\340\3673|\261}\373\3n{\360?\240>\200\347\351\376i\5\300V\0pz\0t\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0l\5\0W\0lz\0\276!\352\302\35+U\244b\0\0\0\0IEND\256B`\202";
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112 TEST(PixelTestPatterns, MultiGradient)
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113 {
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1282
diff changeset
114 std::unique_ptr<Orthanc::Image> texture;
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
116 const int CELLW = 64;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 const int CELLH = 64;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 const int NHCELLS = 4;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119 const int NVCELLS = 2;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 const int NCELLS = NHCELLS * NVCELLS;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 texture.reset(new Orthanc::Image(
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 Orthanc::PixelFormat_RGBA32,
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124 NHCELLS * CELLW,
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125 NVCELLS * CELLH,
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126 /*forceMinimalPitch*/false));
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
128 // H:R->K, V:G->W, H:B->K
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 // R G B K C M Y W
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131 uint8_t startR[NCELLS] = {255,000,000,000,000,255,255,255};
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 uint8_t startG[NCELLS] = {000,255,000,000,255,000,255,255};
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
133 uint8_t startB[NCELLS] = {000,000,255,000,255,255,000,255};
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 // K W K W W K W K
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136 uint8_t eeendR[NCELLS] = {000,255,000,255,255,000,255,000};
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 uint8_t eeendG[NCELLS] = {000,255,000,255,255,000,255,000 };
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 uint8_t eeendB[NCELLS] = {000,255,000,255,255,000,255,000 };
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
140 for(size_t slot = 0; slot < NCELLS; ++slot)
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141 {
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142 int x0 = (slot % 4) * CELLW;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143 bool vertical = (((slot / NHCELLS) % 2) == 0) ? (slot % 2 == 0) : (slot % 2 == 1);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 int y0 = static_cast<int>(slot / NHCELLS) * CELLH;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145 Orthanc::ImageAccessor target;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 texture->GetRegion(target, x0, y0, CELLW, CELLH);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 if (vertical)
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 OrthancStone::PixelTestPatterns::fillWithVGradient(target, startR[slot], startG[slot], startB[slot], eeendR[slot], eeendG[slot], eeendB[slot]);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149 else
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150 OrthancStone::PixelTestPatterns::fillWithHGradient(target, startR[slot], startG[slot], startB[slot], eeendR[slot], eeendG[slot], eeendB[slot]);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
151 }
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
153 Orthanc::PngWriter writer;
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154 #if 0
1629
7fc8a3ff09ee fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
155 Orthanc::IImageWriter::WriteToFile(writer, "MultiGradient.png", *texture);
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 #else
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
157 std::string contents;
1629
7fc8a3ff09ee fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1587
diff changeset
158 Orthanc::IImageWriter::WriteToMemory(writer, contents, *texture);
1275
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 ASSERT_EQ(1u, sizeof(unsigned char));
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
161 ASSERT_EQ(774u, sizeof(bin2c_MultiGradient_png));
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
162 ASSERT_EQ(773u, contents.size());
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164 char* resultPngBytes = &(contents[0]);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
165
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
166 int result = memcmp(resultPngBytes, bin2c_MultiGradient_png, 773);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
167 ASSERT_EQ(0, result);
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
168 #endif
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169 }
41d19fa749b7 Added PixelTestPattern class to debug invisible slice issues
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
170