31 #ifndef PNGPP_CONSUMER_HPP_INCLUDED
32 #define PNGPP_CONSUMER_HPP_INCLUDED
121 template<
typename pixel,
123 class info_holder = def_image_info_holder,
124 bool interlacing_supported =
false >
143 template<
typename istream >
146 read(stream, transform_identity());
157 template<
typename istream,
class transformation >
158 void read(istream& stream, transformation
const& transform)
164 #if __BYTE_ORDER == __LITTLE_ENDIAN
165 if (pixel_traits< pixel >::get_bit_depth() == 16)
167 #ifdef PNG_READ_SWAP_SUPPORTED
170 throw error(
"Cannot read 16-bit image:"
171 " recompile with PNG_READ_SWAP_SUPPORTED.");
180 #ifdef PNG_READ_INTERLACING_SUPPORTED
183 throw error(
"Cannot read interlaced image:"
184 " interlace handling disabled.");
196 throw std::logic_error(
"color type and/or bit depth mismatch"
197 " in png::consumer::read()");
202 pixcon* pixel_con =
static_cast< pixcon*
>(
this);
203 if (pass_count > 1 && !interlacing_supported)
205 skip_interlaced_rows(rd, pass_count);
208 read_rows(rd, pass_count, pixel_con);
226 template<
typename istream >
229 typedef std::vector< pixel > row;
230 typedef row_traits< row > row_traits_type;
231 row dummy_row(this->
get_info().get_width());
232 for (
size_t pass = 1; pass < pass_count; ++pass)
234 rd.
read_row(reinterpret_cast< byte* >
235 (row_traits_type::get_data(dummy_row)));
239 template<
typename istream >
240 void read_rows(reader< istream >& rd,
size_t pass_count,
243 for (
size_t pass = 0; pass < pass_count; ++pass)
245 pixel_con->reset(pass);
249 rd.read_row(pixel_con->get_next_row(pos));
257 #endif // PNGPP_CONSUMER_HPP_INCLUDED