void ImageSourcePng::load( ImageTargetRef target ) { bool success = true; if( setjmp( png_jmpbuf(mPngPtr) ) ) { png_destroy_read_struct( &mPngPtr, &mInfoPtr, (png_infopp)NULL ); mPngPtr = 0; success = false; } else { // get a pointer to the ImageSource function appropriate for handling our data configuration ImageSource::RowFunc func = setupRowFunc( target ); //int number_passes = png_set_interlace_handling( mPngPtr ); shared_ptr<png_byte> row_pointer( new png_byte[png_get_rowbytes( mPngPtr, mInfoPtr )], checked_array_deleter<png_byte>() ); for( int32_t row = 0; row < mHeight; ++row ) { png_read_row( mPngPtr, row_pointer.get(), NULL ); ((*this).*func)( target, row, row_pointer.get() ); } } if( ! success ) throw ImageSourcePngException( "Failure during load." ); }
inline PetscInt col(PetscInt row, PetscInt row_index) { return row_pointer(row)[row_index]; }