Mercurial > hg > orthanc
comparison UnitTestsSources/Png.cpp @ 709:6c90ce085261
zlib tests
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 13 Feb 2014 15:06:38 +0100 |
parents | 51892be15618 |
children | c87a1d529e13 |
comparison
equal
deleted
inserted
replaced
708:38e2883e096f | 709:6c90ce085261 |
---|---|
2 | 2 |
3 #include <stdint.h> | 3 #include <stdint.h> |
4 #include "../Core/FileFormats/PngReader.h" | 4 #include "../Core/FileFormats/PngReader.h" |
5 #include "../Core/FileFormats/PngWriter.h" | 5 #include "../Core/FileFormats/PngWriter.h" |
6 #include "../Core/Toolbox.h" | 6 #include "../Core/Toolbox.h" |
7 #include "../Core/Uuid.h" | |
7 | 8 |
8 | 9 |
9 TEST(PngWriter, ColorPattern) | 10 TEST(PngWriter, ColorPattern) |
10 { | 11 { |
11 Orthanc::PngWriter w; | 12 Orthanc::PngWriter w; |
105 } | 106 } |
106 | 107 |
107 std::string s; | 108 std::string s; |
108 w.WriteToMemory(s, width, height, pitch, Orthanc::PixelFormat_Grayscale16, &image[0]); | 109 w.WriteToMemory(s, width, height, pitch, Orthanc::PixelFormat_Grayscale16, &image[0]); |
109 | 110 |
110 Orthanc::PngReader r; | 111 { |
111 r.ReadFromMemory(s); | 112 Orthanc::PngReader r; |
113 r.ReadFromMemory(s); | |
112 | 114 |
113 ASSERT_EQ(r.GetWidth(), width); | 115 ASSERT_EQ(r.GetWidth(), width); |
114 ASSERT_EQ(r.GetHeight(), height); | 116 ASSERT_EQ(r.GetHeight(), height); |
115 | 117 |
116 v = 0; | 118 v = 0; |
117 for (int y = 0; y < height; y++) | 119 for (int y = 0; y < height; y++) |
120 { | |
121 uint16_t *p = reinterpret_cast<uint16_t*>((uint8_t*) r.GetBuffer() + y * r.GetPitch()); | |
122 for (int x = 0; x < width; x++, p++, v++) | |
123 { | |
124 ASSERT_EQ(*p, v); | |
125 } | |
126 } | |
127 } | |
128 | |
118 { | 129 { |
119 uint16_t *p = reinterpret_cast<uint16_t*>((uint8_t*) r.GetBuffer() + y * r.GetPitch()); | 130 Toolbox::TemporaryFile tmp; |
120 for (int x = 0; x < width; x++, p++, v++) | 131 Toolbox::WriteFile(s, tmp.GetPath()); |
132 | |
133 Orthanc::PngReader r2; | |
134 r2.ReadFromFile(tmp.GetPath()); | |
135 | |
136 ASSERT_EQ(r2.GetWidth(), width); | |
137 ASSERT_EQ(r2.GetHeight(), height); | |
138 for (int y = 0; y < height; y++) | |
121 { | 139 { |
122 ASSERT_EQ(*p, v); | 140 uint16_t *p = reinterpret_cast<uint16_t*>((uint8_t*) r2.GetBuffer() + y * r2.GetPitch()); |
141 for (int x = 0; x < width; x++, p++, v++) | |
142 { | |
143 ASSERT_EQ(*p, v); | |
144 } | |
123 } | 145 } |
124 } | 146 } |
125 } | 147 } |