Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
magick/load.cc
1 // Copyright (C) 2009, 2010 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 #include <mln/io/magick/load.hh>
27 
28 #include <mln/io/pbm/load.hh>
29 #include <mln/io/pgm/load.hh>
30 #include <mln/io/ppm/load.hh>
31 
32 #include <mln/data/compare.hh>
33 
34 #include <mln/core/image/image2d.hh>
35 
36 #include <mln/value/rgb8.hh>
37 
38 #include "tests/data.hh"
39 
40 
41 int main(int /* argc */, char* argv[])
42 {
43  using namespace mln;
44 
45  /* From http://www.graphicsmagick.org/Magick++/Image.html:
46 
47  The InitializeMagick() function MUST be invoked before
48  constructing any Magick++ objects. This used to be optional,
49  but now it is absolutely required. This function initalizes
50  semaphores and configuration information necessary for the
51  software to work correctly. Failing to invoke
52  InitializeMagick() is likely to lead to a program crash or
53  thrown assertion. If the program resides in the same directory
54  as the GraphicsMagick files, then argv[0] may be passed as an
55  argument so that GraphicsMagick knows where its files reside,
56  otherwise NULL may be passed and GraphicsMagick will try to use
57  other means (if necessary). */
58  Magick::InitializeMagick(*argv);
59 
60  // Compare Milena's built-in PBM loaded and Magick++'s support for PBM.
61  {
62  typedef image2d<bool> I;
63  I mln_lena;
64  io::pbm::load(mln_lena, MLN_IMG_DIR "/tiny.pbm");
65  I magick_lena;
66  io::magick::load(magick_lena, MLN_IMG_DIR "/tiny.pbm");
67  mln_assertion(mln_lena == magick_lena);
68  }
69 
70  // Compare Milena's built-in PGM loaded and Magick++'s support for PGM.
71  {
72  typedef image2d<value::int_u8> I;
73  I mln_lena;
74  io::pgm::load(mln_lena, MLN_IMG_DIR "/tiny.pgm");
75  I magick_lena;
76  io::magick::load(magick_lena, MLN_IMG_DIR "/tiny.pgm");
77  mln_assertion(mln_lena == magick_lena);
78  }
79 
80  // Compare Milena's built-in PPM loaded and Magick++'s support for PPM.
81  {
82  typedef image2d<value::rgb8> I;
83  I mln_lena;
84  io::ppm::load(mln_lena, MLN_IMG_DIR "/tiny.ppm");
85  I magick_lena;
86  io::magick::load(magick_lena, MLN_IMG_DIR "/tiny.ppm");
87  mln_assertion(mln_lena == magick_lena);
88  }
89 
90 
91  // Check Magick++'s support for PNG.
92  {
93  typedef image2d<value::rgb8> I;
94  I lena_ppm;
95  io::ppm::load(lena_ppm, MLN_IMG_DIR "/tiny.ppm");
96  I lena_png;
97  io::magick::load(lena_png, MLN_TESTS_IMG_DIR "/tiny.png");
98  mln_assertion(lena_ppm == lena_png);
99  }
100 }