Boost GIL


reader_base.hpp
1 //
2 // Copyright 2007-2008 Christian Henning
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 #ifndef BOOST_GIL_IO_READER_BASE_HPP
9 #define BOOST_GIL_IO_READER_BASE_HPP
10 
11 #include <boost/gil/io/base.hpp>
12 
13 #include <boost/assert.hpp>
14 
15 namespace boost { namespace gil {
16 
25 template< typename FormatTag
26  , typename ConversionPolicy
27  >
29 {
30 public:
31 
36  :_cc_policy()
37  {}
38 
42  reader_base( const ConversionPolicy& cc )
43  :_cc_policy( cc )
44  {}
45 
52  template< typename Image >
53  void init_image( Image& img
54  , const image_read_settings< FormatTag >& settings
55  )
56  {
57  //setup( backend._settings._dim );
58 
59  BOOST_ASSERT(settings._dim.x && settings._dim.y);
60 
61  img.recreate( settings._dim.x
62  , settings._dim.y
63  );
64  }
65 
66  template< typename View >
67  void init_view( const View& view
68  , const image_read_settings< FormatTag >&
69  )
70  {
71  setup( view.dimensions() );
72  }
73 
74 private:
75 
76  void setup( point_t const& /* dim */ )
77  {
78  //check_coordinates( dim );
79 
80  //if( dim == point_t( 0, 0 ))
81  //{
82  // _settings._dim.x = _info._width;
83  // _settings._dim.y = _info._height;
84  //}
85  //else
86  //{
87  // _settings._dim = dim;
88  //}
89  }
90 
91  void check_coordinates( point_t const& /* dim */ )
92  {
93  //using int_t = point_t::value_type;
94 
95  //int_t width = static_cast< int_t >( _info._width );
96  //int_t height = static_cast< int_t >( _info._height );
97 
98  //io_error_if( ( _settings._top_left.x < 0
99  // || _settings._top_left.y < 0
100  // || dim.x < 0
101  // || dim.y < 0
102  // )
103  // , "User provided view has incorrect size." );
104 
105 
106  //io_error_if( ( ( width ) < _settings._top_left.x
107  // && ( width ) <= dim.x
108  // && ( height ) < _settings._top_left.y
109  // && ( height ) <= dim.y )
110  // , "User provided view has incorrect size." );
111 
112  //io_error_if( ( ( _settings._top_left.x + dim.x ) > width
113  // || ( _settings._top_left.y + dim.y ) > height
114  // )
115  // , "User provided view has incorrect size." );
116  }
117 
118 protected:
119 
120  ConversionPolicy _cc_policy;
121 };
122 
123 } // namespace gil
124 } // namespace boost
125 
126 #endif
auto view(image< Pixel, IsPlanar, Alloc > &img) -> typename image< Pixel, IsPlanar, Alloc >::view_t const &
Returns the non-constant-pixel view of an image.
Definition: image.hpp:565
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36
Definition: reader_base.hpp:29
reader_base(const ConversionPolicy &cc)
Definition: reader_base.hpp:42
void init_image(Image &img, const image_read_settings< FormatTag > &settings)
Definition: reader_base.hpp:53
reader_base()
Definition: reader_base.hpp:35