1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use rayon::prelude::*;
use super::super::Image;
pub fn iter<'a, T: Image>(frame: &'a T)
-> impl Iterator<Item = (usize, usize, T::Pixel)> + ExactSizeIterator
{
let (w, h) = (frame.width(), frame.height());
(0..w * h).map(move |i| unsafe {
let (x, y) = (i % w, i / w);
(x, y, frame.pixel(i % w, i / w))
})
}
pub fn par_iter<'a, T>(frame: &'a T)
-> impl ParallelIterator<Item = (usize, usize, T::Pixel)>
where
T: Image + Sync,
T::Pixel: Send,
{
let (w, h) = (frame.width(), frame.height());
(0..w * h).into_par_iter().map(move |i| unsafe {
let (x, y) = (i % w, i / w);
(x, y, frame.pixel(i % w, i / w))
})
}