DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RawWriter.ih
1 
30 
31 #include <cstdlib>
32 #include <fstream>
33 #include "DGtal/io/Color.h"
35 
37 // IMPLEMENTATION of inline methods.
39 
40 
41 namespace DGtal {
42 template<typename I,typename C>
43 bool
44 RawWriter<I,C>::exportRaw8(const std::string & filename, const I & aImage,
45  const Functor & aFunctor)
46 {
47  ofstream out;
48  typename I::Domain::Vector ext = aImage.extent();
49  typename I::Domain domain = aImage.domain();
50  typename I::Value val;
51 
52  out.open(filename.c_str(), ios_base::binary);
53 
54  //We scan the domain
55  for(typename I::Domain::ConstIterator it = domain.begin(), itend=domain.end();
56  it!=itend;
57  ++it)
58  {
59  val = aImage( (*it) );
60  out.put( static_cast<unsigned char>(aFunctor (val) ) );
61  }
62 
63  out.close();
64 
66  return true;
67 }
68 
69 }//namespace