Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
dump.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/core/image/image2d.hh>
27 #include <mln/io/dump/load.hh>
28 #include <mln/io/dump/save.hh>
29 
30 #include <mln/data/compare.hh>
31 
32 #include <mln/value/int_u8.hh>
33 #include <mln/value/rgb8.hh>
34 
35 #include "tests/data.hh"
36 
37 #include <mln/debug/println.hh>
38 
39 int main()
40 {
41  using namespace mln;
42 
43  // FIXME: Factor.
44 
46  {
47  bool data[4] = { 0, 1,
48  1, 0 };
49  image2d<bool> pic = make::image2d(data);
50 
51  io::dump::save(pic, "dump-bool.dump");
52 
53  image2d<bool> pic2;
54  io::dump::load(pic2, "dump-bool.dump");
55 
56  mln_assertion(pic.domain() == pic2.domain());
57  mln_assertion(pic == pic2);
58  }
59 
61  {
62  value::int_u8 data[4] = { 5, 1,
63  1, 9 };
65  io::dump::save(pic, "dump-int_u8.dump");
67  io::dump::load(pic2, "dump-int_u8.dump");
68 
69  mln_assertion(pic.domain() == pic2.domain());
70  mln_assertion(pic == pic2);
71  }
72 
74  {
75  unsigned data[4] = { 5, 1,
76  1, 9 };
77  image2d<unsigned> pic = make::image2d(data);
78  io::dump::save(pic, "dump-unsigned.dump");
79  image2d<unsigned> pic2;
80  io::dump::load(pic2, "dump-unsigned.dump");
81 
82  mln_assertion(pic.domain() == pic2.domain());
83  mln_assertion(pic == pic2);
84  }
85 
87  {
88  float data[4] = { 5, 1,
89  1, 9 };
90  image2d<float> pic = make::image2d(data);
91  io::dump::save(pic, "dump-float.dump");
92  image2d<float> pic2;
93  io::dump::load(pic2, "dump-float.dump");
94 
95  mln_assertion(pic.domain() == pic2.domain());
96  mln_assertion(pic == pic2);
97  }
98 
99 
101  {
102  using value::rgb8;
103  value::rgb8 data[4] = { rgb8(2,4,5), rgb8(1,23,255),
104  rgb8(64,41,150), rgb8(23,53,49) };
106  io::dump::save(pic, "dump-rgb8.dump");
107 
109  io::dump::load(pic2, "dump-rgb8.dump");
110 
111  mln_assertion(pic.domain() == pic2.domain());
112  mln_assertion(pic == pic2);
113  }
114 
115 }