$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
pdf/load.cc
1 // Copyright (C) 2013, 2014 EPITA Research and Development Laboratory (LRDE).
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 // Exercise mln::io::pdf::load.
27 
28 #include <mln/core/image/image2d.hh>
29 #include <mln/data/compare.hh>
30 #include <mln/value/rgb8.hh>
31 #include <mln/io/ppm/load.hh>
32 #include <mln/io/pdf/load.hh>
33 
34 #include "tests/data.hh"
35 
36 
37 int main()
38 {
39  using namespace mln;
40 
41  // FIXME: Disabled (see below).
42 #if 0
43  image2d<value::rgb8> page0, page1, page2, page3;
44 
45  io::ppm::load(page0, MLN_TESTS_IMG_DIR "/example-0.ppm");
46  io::ppm::load(page1, MLN_TESTS_IMG_DIR "/example-1.ppm");
47  io::ppm::load(page2, MLN_TESTS_IMG_DIR "/example-2.ppm");
48  io::ppm::load(page3, MLN_TESTS_IMG_DIR "/example-3.ppm");
49 #endif
50 
51  // Loading full PDF.
52  {
54  io::pdf::load(arr, MLN_TESTS_IMG_DIR "/example.pdf", 75);
55 
56  mln_assertion(arr.size() == 4);
57  /* FIXME: Disabled, as various versions/installations of poppler
58  produce slightly different images (namely, version 0.18.4 on
59  Debian GNU/Linux 7.5 and version 0.24.5 from the MacPorts). This
60  might be caused by different font configurations, too. */
61 #if 0
62  mln_assertion(arr[0] == page0);
63  mln_assertion(arr[1] == page1);
64  mln_assertion(arr[2] == page2);
65  mln_assertion(arr[3] == page3);
66 #endif
67  }
68 
69  // Loading a page range.
70  {
72  io::pdf::load(arr, MLN_TESTS_IMG_DIR "/example.pdf", 1, 2, 75);
73 
74  mln_assertion(arr.size() == 2);
75  // FIXME: Disabled (see above).
76 #if 0
77  mln_assertion(arr[0] == page1);
78  mln_assertion(arr[1] == page2);
79 #endif
80  }
81 
82  // Loading specific pages.
83  {
84  util::array<int> pages;
85  pages.append(1);
86  pages.append(3);
88  io::pdf::load(arr, MLN_TESTS_IMG_DIR "/example.pdf", pages, 75);
89 
90  mln_assertion(arr.size() == 2);
91  // FIXME: Disabled (see above).
92 #if 0
93  mln_assertion(arr[0] == page1);
94  mln_assertion(arr[1] == page3);
95 #endif
96  }
97 
98  // Loading a specific page.
99  {
101  io::pdf::load(ima, MLN_TESTS_IMG_DIR "/example.pdf", 3, 75);
102 
103  mln_assertion(ima.is_valid());
104  // FIXME: Disabled (see above).
105 #if 0
106  mln_assertion(ima == page3);
107 #endif
108  }
109 
110 }