fn advance_pen(mut self, offset: usize) -> Canvas {
//Canvas { pen: self.pen + offset, img: self.img }
self.pen += offset;
+ self.pen %= self.img.width() as usize * self.img.height() as usize;
self
}
}
let mut counter = 0;
for sp in ToRgbIter::new(data) {
- let mut dp = pixels.next().ok_or(ImageError::dimension_error())?;
+ let mut dp = match pixels.next() {
+ Some(pixel) => pixel,
+ None => {
+ pixels = canvas.img.pixels_mut().skip(0);
+ pixels.next().ok_or(ImageError::dimension_error())?
+ }
+ };
println!("{:?}", sp);
dp.0 = sp.0;
counter += 1;