$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
base64.cc
1 // Copyright (C) 2011, 2013 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 
18 
19 #include <cstdio>
20 #include <cstdlib>
21 
22 #include <mln/core/image/image2d.hh>
23 #include <mln/data/compare.hh>
24 
25 #include <mln/io/pbm/load.hh>
26 #include <mln/io/pgm/load.hh>
27 
28 #include <mln/value/int_u.hh>
29 #include <mln/value/int_u8.hh>
30 
31 #include <mln/debug/iota.hh>
32 
33 #include <mln/value/int_u16.hh>
34 
35 #include <scribo/convert/to_base64.hh>
36 #include <scribo/convert/from_base64.hh>
37 
38 #include "tests/data.hh"
39 
40 using namespace mln;
41 
42 int main()
43 {
44 
45  // PBM
46  {
47  image2d<bool> ima;
48  io::pbm::load(ima, SCRIBO_IMG_DIR "/wildly.pbm");
49 
50  util::array<unsigned char> out64;
51  scribo::convert::to_base64(ima, out64);
52 
53  image2d<bool> outbin(ima.domain());
54  scribo::convert::from_base64(out64, outbin);
55 
56  mln_assertion(outbin == ima);
57  }
58 
59  // PGM (8bits)
60  {
62  io::pgm::load(ima, SCRIBO_IMG_DIR "/text_to_group.pgm");
63 
64  util::array<unsigned char> out64;
65  scribo::convert::to_base64(ima, out64);
66 
67  image2d<value::int_u8> outbin(ima.domain());
68  scribo::convert::from_base64(out64, outbin);
69 
70  mln_assertion(outbin == ima);
71  }
72 
73  // PGM (30bits)
74  {
75  image2d<value::int_u<30> > ima(3, 3);
76  debug::iota(ima, 100000);
77 
78  util::array<unsigned char> out64;
79  scribo::convert::to_base64(ima, out64);
80 
81  image2d<value::int_u<30> > outbin(ima.domain());
82  scribo::convert::from_base64(out64, outbin);
83 
84  mln_assertion(outbin == ima);
85  }
86 }