2 // Copyright 2012 Christian Henning
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
8 #ifndef BOOST_GIL_EXTENSION_IO_RAW_DETAIL_READER_BACKEND_HPP
9 #define BOOST_GIL_EXTENSION_IO_RAW_DETAIL_READER_BACKEND_HPP
11 #include <boost/gil/extension/io/raw/tags.hpp>
13 namespace boost { namespace gil {
15 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
17 #pragma warning(disable:4512) //assignment operator could not be generated
23 template< typename Device >
24 struct reader_backend< Device
30 using format_tag_t = raw_tag;
34 reader_backend( const Device& io_dev
35 , const image_read_settings< raw_tag >& settings
38 , _settings( settings )
40 , _scanline_length( 0 )
44 if( _settings._dim.x == 0 )
46 _settings._dim.x = _info._width;
49 if( _settings._dim.y == 0 )
51 _settings._dim.y = _info._height;
57 _io_dev.get_mem_image_format( &_info._width
59 , &_info._samples_per_pixel
60 , &_info._bits_per_pixel
64 _info._camera_manufacturer = _io_dev.get_camera_manufacturer();
65 _info._camera_model = _io_dev.get_camera_model();
66 _info._raw_images_count = _io_dev.get_raw_count();
67 _info._dng_version = _io_dev.get_dng_version();
68 _info._number_colors = _io_dev.get_colors();
69 //_io_dev.get_filters();
70 _info._colors_description = _io_dev.get_cdesc();
73 _info._raw_width = _io_dev.get_raw_width();
74 _info._raw_height = _io_dev.get_raw_height();
75 _info._visible_width = _io_dev.get_image_width();
76 _info._visible_height = _io_dev.get_image_height();
77 _info._top_margin = _io_dev.get_top_margin();
78 _info._left_margin = _io_dev.get_left_margin();
79 _info._output_width = _io_dev.get_iwidth();
80 _info._output_height = _io_dev.get_iheight();
81 _info._pixel_aspect = _io_dev.get_pixel_aspect();
82 _info._flip = _io_dev.get_flip();
85 _info._iso_speed = _io_dev.get_iso_speed();
86 _info._shutter = _io_dev.get_shutter();
87 _info._aperture = _io_dev.get_aperture();
88 _info._focal_length = _io_dev.get_focal_len();
89 _info._timestamp = _io_dev.get_timestamp();
90 _info._shot_order = static_cast< uint16_t >( _io_dev.get_shot_order() );
91 //_io_dev.get_gpsdata();
92 _info._image_description = _io_dev.get_desc();
93 _info._artist = _io_dev.get_artist();
95 _info._libraw_version = _io_dev.get_version();
100 /// Check if image is large enough.
101 void check_image_size( const point_t& img_dim )
103 if( _settings._dim.x > 0 )
105 if( img_dim.x < _settings._dim.x ) { io_error( "Supplied image is too small" ); }
109 if( img_dim.x < _info._width ) { io_error( "Supplied image is too small" ); }
113 if( _settings._dim.y > 0 )
115 if( img_dim.y < _settings._dim.y ) { io_error( "Supplied image is too small" ); }
119 if( img_dim.y < _info._height ) { io_error( "Supplied image is too small" ); }
127 image_read_settings< raw_tag > _settings;
128 image_read_info< raw_tag > _info;
130 std::size_t _scanline_length;
133 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)