• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

dump.cc

00001 // Copyright (C) 2009, 2010 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #include <mln/core/image/image2d.hh>
00027 #include <mln/io/dump/load.hh>
00028 #include <mln/io/dump/save.hh>
00029 
00030 #include <mln/data/compare.hh>
00031 
00032 #include <mln/value/int_u8.hh>
00033 #include <mln/value/rgb8.hh>
00034 
00035 #include "tests/data.hh"
00036 
00037 #include <mln/debug/println.hh>
00038 
00039 int main()
00040 {
00041   using namespace mln;
00042 
00043   // FIXME: Factor.
00044 
00046   {
00047     bool data[4] = { 0, 1,
00048                      1, 0 };
00049     image2d<bool> pic = make::image2d(data);
00050 
00051     io::dump::save(pic, "dump-bool.dump");
00052 
00053     image2d<bool> pic2;
00054     io::dump::load(pic2, "dump-bool.dump");
00055 
00056     mln_assertion(pic.domain() == pic2.domain());
00057     mln_assertion(pic == pic2);
00058   }
00059 
00061   {
00062     value::int_u8 data[4] = { 5, 1,
00063                               1, 9 };
00064     image2d<value::int_u8> pic = make::image2d(data);
00065     io::dump::save(pic, "dump-int_u8.dump");
00066     image2d<value::int_u8> pic2;
00067     io::dump::load(pic2, "dump-int_u8.dump");
00068 
00069     mln_assertion(pic.domain() == pic2.domain());
00070     mln_assertion(pic == pic2);
00071   }
00072 
00074   {
00075     unsigned data[4] = { 5, 1,
00076                          1, 9 };
00077     image2d<unsigned> pic = make::image2d(data);
00078     io::dump::save(pic, "dump-unsigned.dump");
00079     image2d<unsigned> pic2;
00080     io::dump::load(pic2, "dump-unsigned.dump");
00081 
00082     mln_assertion(pic.domain() == pic2.domain());
00083     mln_assertion(pic == pic2);
00084   }
00085 
00087   {
00088     float data[4] = { 5, 1,
00089                          1, 9 };
00090     image2d<float> pic = make::image2d(data);
00091     io::dump::save(pic, "dump-float.dump");
00092     image2d<float> pic2;
00093     io::dump::load(pic2, "dump-float.dump");
00094 
00095     mln_assertion(pic.domain() == pic2.domain());
00096     mln_assertion(pic == pic2);
00097   }
00098 
00099 
00101   {
00102     using value::rgb8;
00103     value::rgb8 data[4] = { rgb8(2,4,5),     rgb8(1,23,255),
00104                             rgb8(64,41,150), rgb8(23,53,49) };
00105     image2d<value::rgb8> pic = make::image2d(data);
00106     io::dump::save(pic, "dump-rgb8.dump");
00107 
00108     image2d<value::rgb8> pic2;
00109     io::dump::load(pic2, "dump-rgb8.dump");
00110 
00111     mln_assertion(pic.domain() == pic2.domain());
00112     mln_assertion(pic == pic2);
00113   }
00114 
00115 }

Generated on Tue Oct 4 2011 15:23:42 for Milena (Olena) by  doxygen 1.7.1