31 #include "../image_info.hpp"
33 #include <pni/core/types.hpp>
34 #include <pni/core/arrays.hpp>
99 const std::vector<size_t> &byte_counts,
100 const std::vector<size_t> &bits_per_channel,
101 const std::vector<pni::core::type_id_t> &channel_types);
129 const ifd &image_dir,
146 template<
typename CTYPE>
147 void read(
size_t c,std::ifstream &stream,CTYPE &data)
152 if(this->_channel_types[c] == type_id_t::UINT8)
153 this->_read_interlace<uint8>(c,stream,data);
154 else if(this->_channel_types[c] == type_id_t::INT8)
155 this->_read_interlace<int8>(c,stream,data);
156 else if(this->_channel_types[c] == type_id_t::UINT16)
157 this->_read_interlace<uint16>(c,stream,data);
158 else if(this->_channel_types[c] == type_id_t::INT16)
159 this->_read_interlace<int16>(c,stream,data);
160 else if(this->_channel_types[c] == type_id_t::UINT32)
161 this->_read_interlace<uint32>(c,stream,data);
162 else if(this->_channel_types[c] == type_id_t::INT32)
163 this->_read_interlace<int32>(c,stream,data);
164 else if(this->_channel_types[c] == type_id_t::UINT64)
165 this->_read_interlace<uint64>(c,stream,data);
166 else if(this->_channel_types[c] == type_id_t::INT64)
167 this->_read_interlace<int64>(c,stream,data);
168 else if(this->_channel_types[c] == type_id_t::FLOAT32)
169 this->_read_interlace<float32>(c,stream,data);
170 else if(this->_channel_types[c] == type_id_t::FLOAT64)
171 this->_read_interlace<float64>(c,stream,data);
173 throw type_error(EXCEPTION_RECORD,
174 "StripReader cannot handle channel type!");
179 friend std::ostream &
operator<<(std::ostream &o,
184 template<
typename IT,
typename CTYPE>
186 std::ifstream &stream,CTYPE &data)
const
188 typedef typename CTYPE::value_type value_type;
200 size_t sample_size =
sizeof(IT);
204 typename CTYPE::iterator piter = data.begin();
205 while(piter != data.end())
216 for(
size_t i=0;i<npixels; ++i)
218 stream.read(reinterpret_cast<char*>(&sample_buffer),sample_size);
219 stream.seekg(pixel_size-sample_size,std::ios::cur);
220 *piter++ = value_type(sample_buffer);
void _read_interlace(size_t c, std::ifstream &stream, CTYPE &data) const
template to read interlace data
Definition: strip_reader.hpp:185
friend std::ostream & operator<<(std::ostream &o, const strip_reader &r)
output operator
Definition: strip_reader.cpp:109
image information type
Definition: image_info.hpp:43
std::vector< size_t > _byte_cnts
array with byte counts for each strip
Definition: strip_reader.hpp:47
std::vector< size_t > _offsets
array with the file offsets of the strips
Definition: strip_reader.hpp:46
static strip_reader create(std::ifstream &stream, const ifd &image_dir, const image_info &info)
create StripReader instance
Definition: strip_reader.cpp:97
void read(size_t c, std::ifstream &stream, CTYPE &data)
template to read image data of various type
Definition: strip_reader.hpp:147
std::string strip(std::string &s, const char *begrem="\n ", const char *endrem=" \n")
strips a string
Definition: strutils.cpp:12
Definition: cbf_reader.hpp:41
std::vector< pni::core::type_id_t > _channel_types
type ids of channel data
Definition: strip_reader.hpp:49
strip_reader & operator=(const strip_reader &r)
copy assignment operator
Definition: strip_reader.cpp:72
strip_reader()
default constructor
Definition: strip_reader.cpp:33
IFD - Image File Directory class.
Definition: ifd.hpp:57
~strip_reader()
destructor
Definition: strip_reader.cpp:67
std::vector< size_t > _bits_per_channel
number of bits per channel
Definition: strip_reader.hpp:48
reader for strip data in a TIFF file
Definition: strip_reader.hpp:43