Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / test / extension / io / png_read_test.cpp
1 //
2 // Copyright 2013 Christian Henning
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 //#define BOOST_TEST_MODULE png_read_test_module
9 #define BOOST_GIL_IO_ADD_FS_PATH_SUPPORT
10 #define BOOST_GIL_IO_ENABLE_GRAY_ALPHA
11 #define BOOST_FILESYSTEM_VERSION 3
12
13 #include <boost/gil/extension/io/png.hpp>
14
15 #include <boost/test/unit_test.hpp>
16
17 #include <cstdint>
18 #include <iostream>
19
20 #include "paths.hpp"
21 #include "scanline_read_test.hpp"
22 #include "unit_test_utility.hpp"
23
24 using namespace std;
25 using namespace boost;
26 using namespace gil;
27 using namespace boost::gil::detail;
28 namespace fs = boost::filesystem;
29
30 using tag_t = png_tag;
31
32 BOOST_AUTO_TEST_SUITE( gil_io_png_tests )
33
34 using gray_alpha8_pixel_t = pixel<uint8_t, gray_alpha_layout_t>;
35 using gray_alpha8_image_t= image<gray_alpha8_pixel_t, false>;
36
37 using gray_alpha16_pixel_t = pixel<uint16_t, gray_alpha_layout_t>;
38 using gray_alpha16_image_t = image<gray_alpha16_pixel_t, false>;
39
40 template< typename Image >
41 void test_file( string filename )
42 {
43     Image src, dst;
44
45     image_read_settings< png_tag > settings;
46     settings._read_file_gamma        = true;
47     settings._read_transparency_data = true;
48
49
50     using backend_t = get_reader_backend<std::string const, tag_t>::type;
51
52     backend_t backend = read_image_info( png_in + filename
53                                         , settings
54                                         );
55
56     read_image( png_in + filename
57               , src
58               , settings
59               );
60
61
62 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
63     image_write_info< png_tag > write_info;
64     write_info._file_gamma = backend._info._file_gamma;
65
66     write_view( png_out + filename
67               , view( src )
68               , write_info
69               );
70
71     read_image( png_out + filename
72               , dst
73               , settings
74               );
75
76
77     BOOST_CHECK( equal_pixels( const_view( src )
78                              , const_view( dst )
79                              )
80                );
81 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
82 }
83
84 template< typename Image >
85 void test_png_scanline_reader( string filename )
86 {
87     test_scanline_reader<Image, png_tag>( string( png_in + filename ).c_str() );
88 }
89
90 BOOST_AUTO_TEST_CASE( read_header_test )
91 {
92     using backend_t = get_reader_backend<std::string const, tag_t>::type;
93
94     backend_t backend = read_image_info( png_filename
95                                        , tag_t()
96                                        );
97
98     BOOST_CHECK_EQUAL( backend._info._width , 1000u );
99     BOOST_CHECK_EQUAL( backend._info._height,  600u );
100
101     BOOST_CHECK_EQUAL( backend._info._num_channels, 4                   );
102     BOOST_CHECK_EQUAL( backend._info._bit_depth   , 8                   );
103     BOOST_CHECK_EQUAL( backend._info._color_type  , PNG_COLOR_TYPE_RGBA );
104
105     BOOST_CHECK_EQUAL( backend._info._interlace_method  , PNG_INTERLACE_NONE        );
106     BOOST_CHECK_EQUAL( backend._info._compression_method, PNG_COMPRESSION_TYPE_BASE );
107     BOOST_CHECK_EQUAL( backend._info._filter_method     , PNG_FILTER_TYPE_BASE      );
108
109
110     BOOST_CHECK_EQUAL( backend._info._file_gamma, 1 );
111 }
112
113 #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
114
115 BOOST_AUTO_TEST_CASE( read_pixel_per_meter )
116 {
117     image_read_settings< png_tag > settings;
118     settings.set_read_members_true();
119
120     using backend_t = get_reader_backend<std::string const, tag_t>::type;
121
122     backend_t backend = read_image_info( png_base_in + "EddDawson/36dpi.png"
123                                       , settings
124                                       );
125
126     BOOST_CHECK_EQUAL( backend._info._pixels_per_meter, png_uint_32( 1417 ));
127 }
128
129 BOOST_AUTO_TEST_CASE(read_with_trns_chunk_color_type_0)
130 {
131     // PNG 1.2: For color type 0 (grayscale), the tRNS chunk contains a single gray level value,
132     // stored in the format:
133     //
134     // Gray:  2 bytes, range 0 .. (2^bitdepth)-1
135     {
136         auto const png_path = png_in + "tbbn0g04.png";
137         image_read_settings<png_tag> settings;
138         settings.set_read_members_true();
139         auto backend = read_image_info(png_path, settings);
140         BOOST_CHECK_EQUAL(backend._info._width, 32u);
141         BOOST_CHECK_EQUAL(backend._info._height, 32u);
142         BOOST_CHECK_EQUAL(backend._info._bit_depth, 4);
143         BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
144         BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_GRAY);
145
146         gray_alpha8_image_t img;
147         read_image(png_path, img, settings);
148         BOOST_CHECK_EQUAL(backend._info._width, 32u);
149         BOOST_CHECK_EQUAL(backend._info._height, 32u);
150         BOOST_TEST(const_view(img).front() == gray_alpha8c_pixel_t(255, 0));
151         BOOST_TEST(const_view(img)[78] == gray_alpha8c_pixel_t(221, 255));
152         BOOST_TEST(const_view(img)[79] == gray_alpha8c_pixel_t(204, 255));
153         BOOST_TEST(const_view(img)[975] == gray_alpha8c_pixel_t(238, 255));
154         BOOST_TEST(const_view(img)[976] == gray_alpha8c_pixel_t(221, 255));
155         BOOST_TEST(const_view(img).back() == gray_alpha8c_pixel_t(255, 0));
156     }
157     {
158         auto const png_path = png_in + "tbwn0g16.png";
159         image_read_settings<png_tag> settings;
160         settings.set_read_members_true();
161         auto backend = read_image_info(png_path, settings);
162         BOOST_CHECK_EQUAL(backend._info._width, 32u);
163         BOOST_CHECK_EQUAL(backend._info._height, 32u);
164         BOOST_CHECK_EQUAL(backend._info._bit_depth, 16);
165         BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
166         BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_GRAY);
167
168         gray_alpha16_image_t img;
169         read_image(png_path, img, settings);
170         BOOST_CHECK_EQUAL(backend._info._width, 32u);
171         BOOST_CHECK_EQUAL(backend._info._height, 32u);
172         BOOST_TEST(const_view(img).front() == gray_alpha16c_pixel_t(65535, 0));
173         BOOST_TEST(const_view(img)[78] == gray_alpha16c_pixel_t(58339, 65535));
174         BOOST_TEST(const_view(img)[79] == gray_alpha16c_pixel_t(51657, 65535));
175         BOOST_TEST(const_view(img)[975] == gray_alpha16c_pixel_t(62965, 65535));
176         BOOST_TEST(const_view(img)[976] == gray_alpha16c_pixel_t(58339, 65535));
177         BOOST_TEST(const_view(img).back() == gray_alpha16c_pixel_t(65535, 0));
178     }
179 }
180
181 BOOST_AUTO_TEST_CASE(read_with_trns_chunk_color_type_2)
182 {
183     // PNG 1.2: For color type 2 (truecolor), the tRNS chunk contains a single RGB color value,
184     // stored in the format:
185     // 
186     // Red:   2 bytes, range 0 .. (2^bitdepth)-1
187     // Green: 2 bytes, range 0 .. (2^bitdepth)-1
188     // Blue:  2 bytes, range 0 .. (2^bitdepth)-1
189     {
190         auto const png_path = png_in + "tbbn2c16.png";
191         image_read_settings<png_tag> settings;
192         settings.set_read_members_true();
193         auto backend = read_image_info(png_path, settings);
194         BOOST_CHECK_EQUAL(backend._info._width, 32u);
195         BOOST_CHECK_EQUAL(backend._info._height, 32u);
196         BOOST_CHECK_EQUAL(backend._info._bit_depth, 16);
197         BOOST_CHECK_EQUAL(backend._info._num_channels, 3u);
198         BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_RGB);
199
200         rgba16_image_t img;
201         read_image(png_path, img, settings);
202         BOOST_CHECK_EQUAL(backend._info._width, 32u);
203         BOOST_CHECK_EQUAL(backend._info._height, 32u);
204         BOOST_TEST(const_view(img).front() == rgba16c_pixel_t(65535, 65535, 65535, 0));
205         BOOST_TEST(const_view(img)[78] == rgba16c_pixel_t(58339, 58339, 58339, 65535));
206         BOOST_TEST(const_view(img)[79] == rgba16c_pixel_t(51657, 51657, 51657, 65535));
207         BOOST_TEST(const_view(img)[975] == rgba16c_pixel_t(62965, 62965, 62965, 65535));
208         BOOST_TEST(const_view(img)[976] == rgba16c_pixel_t(58339, 58339, 58339, 65535));
209         BOOST_TEST(const_view(img).back() == rgba16c_pixel_t(65535, 65535, 65535, 0));
210     }
211     {
212         auto const png_path = png_in + "tbgn2c16.png";
213         image_read_settings<png_tag> settings;
214         settings.set_read_members_true();
215         auto backend = read_image_info(png_path, settings);
216         BOOST_CHECK_EQUAL(backend._info._width, 32u);
217         BOOST_CHECK_EQUAL(backend._info._height, 32u);
218         BOOST_CHECK_EQUAL(backend._info._bit_depth, 16);
219         BOOST_CHECK_EQUAL(backend._info._num_channels, 3u);
220         BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_RGB);
221
222         rgba16_image_t img;
223         read_image(png_path, img, settings);
224         BOOST_CHECK_EQUAL(backend._info._width, 32u);
225         BOOST_CHECK_EQUAL(backend._info._height, 32u);
226         BOOST_TEST(const_view(img).front() == rgba16c_pixel_t(65535, 65535, 65535, 0));
227         BOOST_TEST(const_view(img)[78] == rgba16c_pixel_t(58339, 58339, 58339, 65535));
228         BOOST_TEST(const_view(img)[79] == rgba16c_pixel_t(51657, 51657, 51657, 65535));
229         BOOST_TEST(const_view(img)[975] == rgba16c_pixel_t(62965, 62965, 62965, 65535));
230         BOOST_TEST(const_view(img)[976] == rgba16c_pixel_t(58339, 58339, 58339, 65535));
231         BOOST_TEST(const_view(img).back() == rgba16c_pixel_t(65535, 65535, 65535, 0));
232     }
233     {
234         auto const png_path = png_in + "tbrn2c08.png";
235         image_read_settings<png_tag> settings;
236         settings.set_read_members_true();
237         auto backend = read_image_info(png_path, settings);
238         BOOST_CHECK_EQUAL(backend._info._width, 32u);
239         BOOST_CHECK_EQUAL(backend._info._height, 32u);
240         BOOST_CHECK_EQUAL(backend._info._bit_depth, 8);
241         BOOST_CHECK_EQUAL(backend._info._num_channels, 3u);
242         BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_RGB);
243
244         rgba8_image_t img;
245         read_image(png_path, img, settings);
246         BOOST_CHECK_EQUAL(backend._info._width, 32u);
247         BOOST_CHECK_EQUAL(backend._info._height, 32u);
248         BOOST_TEST(const_view(img).front() == rgba8c_pixel_t(255, 255, 255, 0));
249         BOOST_TEST(const_view(img)[78] == rgba8c_pixel_t(227, 227, 227, 255));
250         BOOST_TEST(const_view(img)[79] == rgba8c_pixel_t(201, 201, 201, 255));
251         BOOST_TEST(const_view(img)[975] == rgba8c_pixel_t(245, 245, 245, 255));
252         BOOST_TEST(const_view(img)[976] == rgba8c_pixel_t(227, 227, 227, 255));
253         BOOST_TEST(const_view(img).back() == rgba8c_pixel_t(255, 255, 255, 0));
254     }
255 }
256
257 BOOST_AUTO_TEST_CASE(read_with_trns_chunk_color_type_3)
258 {
259     // PNG 1.2: For color type 3 (indexed color), the tRNS chunk contains a series of one-byte
260     // alpha values, corresponding to entries in the PLTE chunk:
261     // 
262     // Alpha for palette index 0:  1 byte
263     // Alpha for palette index 1:  1 byte
264     // ...etc...
265     {
266         auto const png_path = png_in + "tbbn3p08.png";
267         image_read_settings<png_tag> settings;
268         settings.set_read_members_true();
269         auto backend = read_image_info(png_path, settings);
270         BOOST_CHECK_EQUAL(backend._info._width, 32u);
271         BOOST_CHECK_EQUAL(backend._info._height, 32u);
272         BOOST_CHECK_EQUAL(backend._info._bit_depth, 8);
273         BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
274         BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_PALETTE);
275
276         rgba8_image_t img;
277         read_image(png_path, img, settings);
278         BOOST_CHECK_EQUAL(backend._info._width, 32u);
279         BOOST_CHECK_EQUAL(backend._info._height, 32u);
280         BOOST_TEST(const_view(img).front() == rgba8c_pixel_t(255, 255, 255, 0));
281         BOOST_TEST(const_view(img)[78] == rgba8c_pixel_t(227, 227, 227, 255));
282         BOOST_TEST(const_view(img)[79] == rgba8c_pixel_t(201, 201, 201, 255));
283         BOOST_TEST(const_view(img)[975] == rgba8c_pixel_t(246, 246, 246, 255));
284         BOOST_TEST(const_view(img)[976] == rgba8c_pixel_t(227, 227, 227, 255));
285         BOOST_TEST(const_view(img).back() == rgba8c_pixel_t(255, 255, 255, 0));
286     }
287     {
288         auto const png_path = png_in + "tbgn3p08.png";
289         image_read_settings<png_tag> settings;
290         settings.set_read_members_true();
291         auto backend = read_image_info(png_path, settings);
292         BOOST_CHECK_EQUAL(backend._info._width, 32u);
293         BOOST_CHECK_EQUAL(backend._info._height, 32u);
294         BOOST_CHECK_EQUAL(backend._info._bit_depth, 8);
295         BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
296         BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_PALETTE);
297
298         rgba8_image_t img;
299         read_image(png_path, img, settings);
300         BOOST_CHECK_EQUAL(backend._info._width, 32u);
301         BOOST_CHECK_EQUAL(backend._info._height, 32u);
302         BOOST_TEST(const_view(img).front() == rgba8c_pixel_t(255, 255, 255, 0));
303         BOOST_TEST(const_view(img)[78] == rgba8c_pixel_t(227, 227, 227, 255));
304         BOOST_TEST(const_view(img)[79] == rgba8c_pixel_t(201, 201, 201, 255));
305         BOOST_TEST(const_view(img)[975] == rgba8c_pixel_t(246, 246, 246, 255));
306         BOOST_TEST(const_view(img)[976] == rgba8c_pixel_t(227, 227, 227, 255));
307         BOOST_TEST(const_view(img).back() == rgba8c_pixel_t(255, 255, 255, 0));
308     }
309     {
310         auto const png_path = png_in + "tp1n3p08.png";
311         image_read_settings<png_tag> settings;
312         settings.set_read_members_true();
313         auto backend = read_image_info(png_path, settings);
314         BOOST_CHECK_EQUAL(backend._info._width, 32u);
315         BOOST_CHECK_EQUAL(backend._info._height, 32u);
316         BOOST_CHECK_EQUAL(backend._info._bit_depth, 8);
317         BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
318         BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_PALETTE);
319
320         rgba8_image_t img;
321         read_image(png_path, img, settings);
322         BOOST_CHECK_EQUAL(backend._info._width, 32u);
323         BOOST_CHECK_EQUAL(backend._info._height, 32u);
324         BOOST_TEST(const_view(img).front() == rgba8c_pixel_t(255, 255, 255, 0));
325         BOOST_TEST(const_view(img)[78] == rgba8c_pixel_t(227, 227, 227, 255));
326         BOOST_TEST(const_view(img)[79] == rgba8c_pixel_t(201, 201, 201, 255));
327         BOOST_TEST(const_view(img)[975] == rgba8c_pixel_t(246, 246, 246, 255));
328         BOOST_TEST(const_view(img)[976] == rgba8c_pixel_t(227, 227, 227, 255));
329         BOOST_TEST(const_view(img).back() == rgba8c_pixel_t(255, 255, 255, 0));
330     }
331     {
332         auto const png_path = png_in + "tm3n3p02.png";
333         image_read_settings<png_tag> settings;
334         settings.set_read_members_true();
335         auto backend = read_image_info(png_path, settings);
336         BOOST_CHECK_EQUAL(backend._info._width, 32u);
337         BOOST_CHECK_EQUAL(backend._info._height, 32u);
338         BOOST_CHECK_EQUAL(backend._info._bit_depth, 2);
339         BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
340         BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_PALETTE);
341
342         rgba8_image_t img;
343         read_image(png_path, img, settings);
344         BOOST_CHECK_EQUAL(backend._info._width, 32u);
345         BOOST_CHECK_EQUAL(backend._info._height, 32u);
346         BOOST_TEST(const_view(img).front() == rgba8c_pixel_t(0, 0, 255, 0));
347         BOOST_TEST(const_view(img)[16] == rgba8c_pixel_t(0, 0, 255, 85));
348         BOOST_TEST(const_view(img)[511] == rgba8c_pixel_t(0, 0, 255, 85));
349         BOOST_TEST(const_view(img)[1007] == rgba8c_pixel_t(0, 0, 255, 170));
350         BOOST_TEST(const_view(img).back() == rgba8c_pixel_t(0, 0, 255, 255));
351     }
352 }
353
354 #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
355
356 #ifdef BOOST_GIL_IO_USE_PNG_TEST_SUITE_IMAGES
357
358 BOOST_AUTO_TEST_CASE( BASIc_format_test )
359 {
360     // Basic format test files (non-interlaced)
361
362     // BASN0g01    -   black & white
363     test_file< gray1_image_t >( "BASN0G01.PNG" );
364     test_png_scanline_reader< gray1_image_t >( "BASN0G01.PNG" );
365
366     // BASN0g02    -   2 bit (4 level) grayscale
367     test_file< gray2_image_t >( "BASN0G02.PNG" );
368     test_png_scanline_reader< gray2_image_t >( "BASN0G02.PNG" );
369
370     // BASN0g04    -   4 bit (16 level) grayscale
371     test_file< gray4_image_t >( "BASN0G04.PNG" );
372     test_png_scanline_reader< gray4_image_t >( "BASN0G04.PNG" );
373
374     // BASN0g08    -   8 bit (256 level) grayscale
375     test_file< gray8_image_t >( "BASN0G08.PNG" );
376     test_png_scanline_reader< gray8_image_t >( "BASN0G08.PNG" );
377
378     // BASN0g16    -   16 bit (64k level) grayscale
379     test_file< gray16_image_t >( "BASN0G16.PNG" );
380     test_png_scanline_reader< gray16_image_t >( "BASN0G16.PNG" );
381
382     // BASN2c08    -   3x8 bits rgb color
383     test_file< rgb8_image_t >( "BASN2C08.PNG" );
384     test_png_scanline_reader< rgb8_image_t >( "BASN2C08.PNG" );
385
386     // BASN2c16    -   3x16 bits rgb color
387     test_file< rgb16_image_t >( "BASN2C16.PNG" );
388     test_png_scanline_reader< rgb16_image_t >( "BASN2C16.PNG" );
389
390     // BASN3p01    -   1 bit (2 color) paletted
391     test_file< rgb8_image_t >( "BASN3P01.PNG" );
392     test_png_scanline_reader< rgb8_image_t >( "BASN3P01.PNG" );
393
394     // BASN3p02    -   2 bit (4 color) paletted
395     test_file< rgb8_image_t >( "BASN3P02.PNG" );
396     test_png_scanline_reader< rgb8_image_t >( "BASN3P02.PNG" );
397
398     // BASN3p04    -   4 bit (16 color) paletted
399     test_file< rgb8_image_t >( "BASN3P04.PNG" );
400     test_png_scanline_reader< rgb8_image_t >( "BASN3P04.PNG" );
401
402     // BASN3p08    -   8 bit (256 color) paletted
403     test_file< rgb8_image_t >( "BASN3P08.PNG" );
404     test_png_scanline_reader< rgb8_image_t >( "BASN3P08.PNG" );
405
406     // BASN4a08    -   8 bit grayscale + 8 bit alpha-channel
407     test_file< gray_alpha8_image_t >( "BASN4A08.PNG" );
408     test_png_scanline_reader< gray_alpha8_image_t >( "BASN4A08.PNG" );
409
410     // BASN4a16    -   16 bit grayscale + 16 bit alpha-channel
411     test_file< gray_alpha16_image_t >( "BASN4A16.PNG" );
412     test_png_scanline_reader< gray_alpha16_image_t >( "BASN4A16.PNG" );
413
414     // BASN6a08    -   3x8 bits rgb color + 8 bit alpha-channel
415     test_file< rgba8_image_t >( "BASN6A08.PNG" );
416     test_png_scanline_reader< rgba8_image_t >( "BASN6A08.PNG" );
417
418     // BASN6a16    -   3x16 bits rgb color + 16 bit alpha-channel
419     test_file< rgba16_image_t >( "BASN6A16.PNG" );
420     test_png_scanline_reader< rgba16_image_t >( "BASN6A16.PNG" );
421 }
422
423 BOOST_AUTO_TEST_CASE( BASIc_format_interlaced_test )
424 {
425     // Basic format test files (Adam-7 interlaced)
426
427     // BASI0g01    -   black & white
428     test_file< gray1_image_t >( "BASI0G01.PNG" );
429
430     // BASI0g02    -   2 bit (4 level) grayscale
431     test_file< gray2_image_t >( "BASI0G02.PNG" );
432
433     // BASI0g04    -   4 bit (16 level) grayscale
434     test_file< gray4_image_t >( "BASI0G04.PNG" );
435
436     // BASI0g08    -   8 bit (256 level) grayscale
437     test_file< gray8_image_t >( "BASI0G08.PNG" );
438
439     // BASI0g16    -   16 bit (64k level) grayscale
440     test_file< gray16_image_t >( "BASI0G16.PNG" );
441
442     // BASI2c08    -   3x8 bits rgb color
443     test_file< rgb8_image_t >( "BASI2C08.PNG" );
444
445     // BASI2c16    -   3x16 bits rgb color
446     test_file< rgb16_image_t >( "BASI2C16.PNG" );
447
448     // BASI3p01    -   1 bit (2 color) paletted
449     test_file< rgb8_image_t >( "BASI3P01.PNG" );
450
451     // BASI3p02    -   2 bit (4 color) paletted
452     test_file< rgb8_image_t >( "BASI3P02.PNG" );
453
454     // BASI3p04    -   4 bit (16 color) paletted
455     test_file< rgb8_image_t >( "BASI3P04.PNG" );
456
457     // BASI3p08    -   8 bit (256 color) paletted
458     test_file< rgb8_image_t >( "BASI3P08.PNG" );
459
460     // BASI4a08    -   8 bit grayscale + 8 bit alpha-channel
461     test_file< gray_alpha8_image_t >( "BASI4A08.PNG" );
462
463     // BASI4a16    -   16 bit grayscale + 16 bit alpha-channel
464     test_file< gray_alpha16_image_t >( "BASI4A16.PNG" );
465
466     // BASI6a08    -   3x8 bits rgb color + 8 bit alpha-channel
467     test_file< rgba8_image_t >( "BASI6A08.PNG" );
468
469     // BASI6a16    -   3x16 bits rgb color + 16 bit alpha-channel
470     test_file< rgba16_image_t >( "BASI6A16.PNG" );
471 }
472
473 BOOST_AUTO_TEST_CASE( odd_sizes_test )
474 {
475     // S01I3P01 - 1x1 paletted file, interlaced
476     test_file< rgb8_image_t >( "S01I3P01.PNG" );
477
478     // S01N3P01 - 1x1 paletted file, no interlacing
479     test_file< rgb8_image_t >( "S01N3P01.PNG" );
480     test_png_scanline_reader< rgb8_image_t >( "S01N3P01.PNG" );
481
482     // S02I3P01 - 2x2 paletted file, interlaced
483     test_file< rgb8_image_t >( "S02I3P01.PNG" );
484
485     // S02N3P01 - 2x2 paletted file, no interlacing
486     test_file< rgb8_image_t >( "S02N3P01.PNG" );
487     test_png_scanline_reader< rgb8_image_t >( "S02N3P01.PNG" );
488
489     // S03I3P01 - 3x3 paletted file, interlaced
490     test_file< rgb8_image_t >( "S03I3P01.PNG" );
491
492     // S03N3P01 - 3x3 paletted file, no interlacing
493     test_file< rgb8_image_t >( "S03N3P01.PNG" );
494     test_png_scanline_reader< rgb8_image_t >( "S03N3P01.PNG" );
495
496     // S04I3P01 - 4x4 paletted file, interlaced
497     test_file< rgb8_image_t >( "S04I3P01.PNG" );
498
499     // S04N3P01 - 4x4 paletted file, no interlacing
500     test_file< rgb8_image_t >( "S04N3P01.PNG" );
501     test_png_scanline_reader< rgb8_image_t >( "S04N3P01.PNG" );
502
503     // S05I3P02 - 5x5 paletted file, interlaced
504     test_file< rgb8_image_t >( "S05I3P02.PNG" );
505
506     // S05N3P02 - 5x5 paletted file, no interlacing
507     test_file< rgb8_image_t >( "S05N3P02.PNG" );
508     test_png_scanline_reader< rgb8_image_t >( "S05N3P02.PNG" );
509
510     // S06I3P02 - 6x6 paletted file, interlaced
511     test_file< rgb8_image_t >( "S06I3P02.PNG" );
512
513     // S06N3P02 - 6x6 paletted file, no interlacing
514     test_file< rgb8_image_t >( "S06N3P02.PNG" );
515     test_png_scanline_reader< rgb8_image_t >( "S06N3P02.PNG" );
516
517     // S07I3P02 - 7x7 paletted file, interlaced
518     test_file< rgb8_image_t >( "S07I3P02.PNG" );
519
520     // S07N3P02 - 7x7 paletted file, no interlacing
521     test_file< rgb8_image_t >( "S07N3P02.PNG" );
522     test_png_scanline_reader< rgb8_image_t >( "S07N3P02.PNG" );
523
524     // S08I3P02 - 8x8 paletted file, interlaced
525     test_file< rgb8_image_t >( "S08I3P02.PNG" );
526
527     // S08N3P02 - 8x8 paletted file, no interlacing
528     test_file< rgb8_image_t >( "S08N3P02.PNG" );
529     test_png_scanline_reader< rgb8_image_t >( "S08N3P02.PNG" );
530
531     // S09I3P02 - 9x9 paletted file, interlaced
532     test_file< rgb8_image_t >( "S09I3P02.PNG" );
533
534     // S09N3P02 - 9x9 paletted file, no interlacing
535     test_file< rgb8_image_t >( "S09N3P02.PNG" );
536     test_png_scanline_reader< rgb8_image_t >( "S09N3P02.PNG" );
537
538     // S32I3P04 - 32x32 paletted file, interlaced
539     test_file< rgb8_image_t >( "S32I3P04.PNG" );
540
541     // S32N3P04 - 32x32 paletted file, no interlacing
542     test_file< rgb8_image_t >( "S32N3P04.PNG" );
543     test_png_scanline_reader< rgb8_image_t >( "S32N3P04.PNG" );
544
545     // S33I3P04 - 33x33 paletted file, interlaced
546     test_file< rgb8_image_t >( "S33I3P04.PNG" );
547
548     // S33N3P04 - 33x33 paletted file, no interlacing
549     test_file< rgb8_image_t >( "S33N3P04.PNG" );
550     test_png_scanline_reader< rgb8_image_t >( "S33N3P04.PNG" );
551
552     // S34I3P04 - 34x34 paletted file, interlaced
553     test_file< rgb8_image_t >( "S34I3P04.PNG" );
554
555     // S34N3P04 - 34x34 paletted file, no interlacing
556     test_file< rgb8_image_t >( "S34N3P04.PNG" );
557     test_png_scanline_reader< rgb8_image_t >( "S34N3P04.PNG" );
558
559     // S35I3P04 - 35x35 paletted file, interlaced
560     test_file< rgb8_image_t >( "S35I3P04.PNG" );
561
562     // S35N3P04 - 35x35 paletted file, no interlacing
563     test_file< rgb8_image_t >( "S35N3P04.PNG" );
564     test_png_scanline_reader< rgb8_image_t >( "S35N3P04.PNG" );
565
566     // S36I3P04 - 36x36 paletted file, interlaced
567     test_file< rgb8_image_t >( "S36I3P04.PNG" );
568
569     // S36N3P04 - 36x36 paletted file, no interlacing
570     test_file< rgb8_image_t >( "S36N3P04.PNG" );
571     test_png_scanline_reader< rgb8_image_t >( "S36N3P04.PNG" );
572
573     // S37I3P04 - 37x37 paletted file, interlaced
574     test_file< rgb8_image_t >( "S37I3P04.PNG" );
575
576     // S37N3P04 - 37x37 paletted file, no interlacing
577     test_file< rgb8_image_t >( "S37N3P04.PNG" );
578     test_png_scanline_reader< rgb8_image_t >( "S37N3P04.PNG" );
579
580     // S38I3P04 - 38x38 paletted file, interlaced
581     test_file< rgb8_image_t >( "S38I3P04.PNG" );
582
583     // S38N3P04 - 38x38 paletted file, no interlacing
584     test_file< rgb8_image_t >( "S38N3P04.PNG" );
585     test_png_scanline_reader< rgb8_image_t >( "S38N3P04.PNG" );
586
587     // S39I3P04 - 39x39 paletted file, interlaced
588     test_file< rgb8_image_t >( "S39I3P04.PNG" );
589
590     // S39N3P04 - 39x39 paletted file, no interlacing
591     test_file< rgb8_image_t >( "S39N3P04.PNG" );
592     test_png_scanline_reader< rgb8_image_t >( "S39N3P04.PNG" );
593
594     // S40I3P04 - 40x40 paletted file, interlaced
595     test_file< rgb8_image_t >( "S40I3P04.PNG" );
596
597     // S40N3P04 - 40x40 paletted file, no interlacing
598     test_file< rgb8_image_t >( "S40N3P04.PNG" );
599     test_png_scanline_reader< rgb8_image_t >( "S40N3P04.PNG" );
600 }
601
602 BOOST_AUTO_TEST_CASE( background_test )
603 {
604     // BGAI4A08 - 8 bit grayscale, alpha, no background chunk, interlaced
605     test_file< gray_alpha8_image_t >( "BGAI4A08.PNG" );
606
607     // BGAI4A16 - 16 bit grayscale, alpha, no background chunk, interlaced
608     test_file< gray_alpha16_image_t >( "BGAI4A16.PNG" );
609
610     // BGAN6A08 - 3x8 bits rgb color, alpha, no background chunk
611     test_file< rgba8_image_t >( "BGAN6A08.PNG" );
612
613     // BGAN6A16 - 3x16 bits rgb color, alpha, no background chunk
614     test_file< rgba16_image_t >( "BGAN6A16.PNG" );
615
616     // BGBN4A08 - 8 bit grayscale, alpha, black background chunk
617     test_file< gray_alpha8_image_t >( "BGBN4A08.PNG" );
618
619     // BGGN4A16 - 16 bit grayscale, alpha, gray background chunk
620     test_file< gray_alpha16_image_t >( "BGGN4A16.PNG" );
621
622     // BGWN6A08 - 3x8 bits rgb color, alpha, white background chunk
623     test_file< rgba8_image_t >( "BGWN6A08.PNG" );
624
625     // BGYN6A16 - 3x16 bits rgb color, alpha, yellow background chunk
626     test_file< rgba16_image_t >( "BGYN6A16.PNG" );
627 }
628
629 BOOST_AUTO_TEST_CASE( transparency_test )
630 {
631     // TBBN1G04 - transparent, black background chunk
632     // file missing
633     //test_file< gray_alpha8_image_t >( "TBBN1G04.PNG" );
634
635     // TBBN2C16 - transparent, blue background chunk
636     test_file< rgba16_image_t >( "TBBN2C16.PNG" );
637
638     // TBBN3P08 - transparent, black background chunk
639     test_file< rgba8_image_t >( "TBBN3P08.PNG" );
640
641     // TBGN2C16 - transparent, green background chunk
642     test_file< rgba16_image_t >( "TBGN2C16.PNG" );
643
644     // TBGN3P08 - transparent, light-gray background chunk
645     test_file< rgba8_image_t >( "TBGN3P08.PNG" );
646
647     // TBRN2C08 - transparent, red background chunk
648     test_file< rgba8_image_t >( "TBRN2C08.PNG" );
649
650     // TBWN1G16 - transparent, white background chunk
651     test_file< gray_alpha16_image_t >( "TBWN0G16.PNG" );
652
653     // TBWN3P08 - transparent, white background chunk
654     test_file< rgba8_image_t >( "TBWN3P08.PNG" );
655
656     // TBYN3P08 - transparent, yellow background chunk
657     test_file< rgba8_image_t >( "TBYN3P08.PNG" );
658
659     // TP0N1G08 - not transparent for reference (logo on gray)
660     test_file< gray8_image_t >( "TP0N0G08.PNG" );
661
662     // TP0N2C08 - not transparent for reference (logo on gray)
663     test_file< rgb8_image_t >( "TP0N2C08.PNG" );
664
665     // TP0N3P08 - not transparent for reference (logo on gray)
666     test_file< rgb8_image_t >( "TP0N3P08.PNG" );
667
668     // TP1N3P08 - transparent, but no background chunk
669     test_file< rgba8_image_t >( "TP1N3P08.PNG" );
670 }
671
672 BOOST_AUTO_TEST_CASE( gamma_test )
673 {
674     // G03N0G16 - grayscale, file-gamma = 0.35
675     test_file< gray16_image_t >( "G03N0G16.PNG" );
676
677     // G03N2C08 - color, file-gamma = 0.35
678     test_file< rgb8_image_t >( "G03N2C08.PNG" );
679
680     // G03N3P04 - paletted, file-gamma = 0.35
681     test_file< rgb8_image_t >( "G03N3P04.PNG" );
682
683     // G04N0G16 - grayscale, file-gamma = 0.45
684     test_file< gray16_image_t >( "G04N0G16.PNG" );
685
686     // G04N2C08 - color, file-gamma = 0.45
687     test_file< rgb8_image_t >( "G04N2C08.PNG" );
688
689     // G04N3P04 - paletted, file-gamma = 0.45
690     test_file< rgb8_image_t >( "G04N3P04.PNG" );
691
692     // G05N0G16 - grayscale, file-gamma = 0.55
693     test_file< gray16_image_t >( "G05N0G16.PNG" );
694
695     // G05N2C08 - color, file-gamma = 0.55
696     test_file< rgb8_image_t >( "G05N2C08.PNG" );
697
698     // G05N3P04 - paletted, file-gamma = 0.55
699     test_file< rgb8_image_t >( "G05N3P04.PNG" );
700
701     // G07N0G16 - grayscale, file-gamma = 0.70
702     test_file< gray16_image_t >( "G07N0G16.PNG" );
703
704     // G07N2C08 - color, file-gamma = 0.70
705     test_file< rgb8_image_t >( "G07N2C08.PNG" );
706
707     // G07N3P04 - paletted, file-gamma = 0.70
708     test_file< rgb8_image_t >( "G07N3P04.PNG" );
709
710     // G10N0G16 - grayscale, file-gamma = 1.00
711     test_file< gray16_image_t >( "G10N0G16.PNG" );
712
713     // G10N2C08 - color, file-gamma = 1.00
714     test_file< rgb8_image_t >( "G10N2C08.PNG" );
715
716     // G10N3P04 - paletted, file-gamma = 1.00
717     test_file< rgb8_image_t >( "G10N3P04.PNG" );
718
719     // G25N0G16 - grayscale, file-gamma = 2.50
720     test_file< gray16_image_t >( "G25N0G16.PNG" );
721
722     // G25N2C08 - color, file-gamma = 2.50
723     test_file< rgb8_image_t >( "G25N2C08.PNG" );
724
725     // G25N3P04 - paletted, file-gamma = 2.50
726     test_file< rgb8_image_t >( "G25N3P04.PNG" );
727 }
728
729 #endif // BOOST_GIL_IO_USE_PNG_TEST_SUITE_IMAGES
730
731 BOOST_AUTO_TEST_SUITE_END()