Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-16 09:15:13

0001 //
0002 // Copyright 2007-2008 Christian Henning
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 #ifndef BOOST_GIL_IO_READER_BASE_HPP
0009 #define BOOST_GIL_IO_READER_BASE_HPP
0010 
0011 #include <boost/gil/io/base.hpp>
0012 
0013 #include <boost/assert.hpp>
0014 
0015 namespace boost { namespace gil {
0016 
0017 /// Reader Base Class
0018 ///
0019 /// It provides some basic functionality which is shared for all readers.
0020 /// For instance, it recreates images when necessary. It checks whether
0021 /// user supplied coordinates are valid.
0022 ///
0023 /// @tparam FormatTag        A format tag, like jpeg_tag.
0024 /// @tparam ConversionPolicy Conversion policy, see coversion_policies.hpp.
0025 template< typename FormatTag
0026         , typename ConversionPolicy
0027         >
0028 struct reader_base
0029 {
0030 public:
0031 
0032     ///
0033     /// Default Constructor
0034     ///
0035     reader_base()
0036     :_cc_policy()
0037     {}
0038 
0039     ///
0040     /// Constructor
0041     ///
0042     reader_base( const ConversionPolicy& cc )
0043     :_cc_policy( cc )
0044     {}
0045 
0046     /// Initializes an image. But also does some check ups.
0047     ///
0048     /// @tparam Image Image which implements boost::gil's ImageConcept.
0049     ///
0050     /// @param img  The image.
0051     /// @param info The image read info.
0052     template< typename Image >
0053     void init_image( Image&                                  img
0054                    , const image_read_settings< FormatTag >& settings
0055                    )
0056     {
0057         //setup( backend._settings._dim );
0058 
0059         BOOST_ASSERT(settings._dim.x && settings._dim.y);
0060 
0061         img.recreate( settings._dim.x
0062                     , settings._dim.y
0063                     );
0064     }
0065 
0066     template< typename View >
0067     void init_view( const View&                             view
0068                   , const image_read_settings< FormatTag >&
0069                   )
0070     {
0071         setup( view.dimensions() );
0072     }
0073 
0074 private:
0075 
0076     void setup( point_t const& /* dim */ )
0077     {
0078         //check_coordinates( dim );
0079 
0080         //if( dim == point_t( 0, 0 ))
0081         //{
0082         //    _settings._dim.x = _info._width;
0083         //    _settings._dim.y = _info._height;
0084         //}
0085         //else
0086         //{
0087         //    _settings._dim = dim;
0088         //}
0089     }
0090 
0091     void check_coordinates( point_t const& /* dim */ )
0092     {
0093        //using int_t = point_t::value_type;
0094 
0095        //int_t width  = static_cast< int_t >( _info._width  );
0096        //int_t height = static_cast< int_t >( _info._height );
0097 
0098        //io_error_if( (  _settings._top_left.x < 0
0099        //             || _settings._top_left.y < 0
0100        //             || dim.x < 0
0101        //             || dim.y < 0
0102        //             )
0103        //          , "User provided view has incorrect size." );
0104 
0105 
0106        //io_error_if( (  ( width  ) <  _settings._top_left.x
0107        //             && ( width  ) <= dim.x
0108        //             && ( height ) <  _settings._top_left.y
0109        //             && ( height ) <= dim.y  )
0110        //          , "User provided view has incorrect size."       );
0111 
0112        //io_error_if( (  ( _settings._top_left.x + dim.x ) > width
0113        //             || ( _settings._top_left.y + dim.y ) > height
0114        //            )
0115        //          , "User provided view has incorrect size." );
0116     }
0117 
0118 protected:
0119 
0120     ConversionPolicy _cc_policy;
0121 };
0122 
0123 } // namespace gil
0124 } // namespace boost
0125 
0126 #endif