40 template<
class Convert>
41 void claw::graphic::jpeg::reader::read_data
42 ( jpeg_decompress_struct& cinfo,
const Convert& pixel_convert )
44 const unsigned int pixel_size = cinfo.output_components;
45 JSAMPLE* buffer =
new JSAMPLE[cinfo.output_width * pixel_size];
48 jpeg_error_mgr* jerr_saved = cinfo.err;
50 cinfo.err = jpeg_std_error(&jerr.pub);
53 if ( setjmp(jerr.setjmp_buffer) )
59 while (cinfo.output_scanline < cinfo.output_height)
61 jpeg_read_scanlines(&cinfo, &buffer, 1);
65 for (
unsigned int i=0; i!=pixel_size*m_image.
width();
66 i+=pixel_size, ++pixel )
67 *pixel = pixel_convert( &buffer[i] );
71 cinfo.err = jerr_saved;