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 super::super::Image;
pub fn map<T, F, U>(map: F, frame: T) -> Map<T, F, U>
where T: Image, F: Fn(T::Pixel) -> U {
Map { map, frame }
}
#[doc(hidden)]
pub struct Map<T, F, U>
where T: Image, F: Fn(T::Pixel) -> U {
map: F,
frame: T
}
impl<T, F, U> Image for Map<T, F, U>
where T: Image, F: Fn(T::Pixel) -> U {
type Pixel = U;
fn width(&self) -> usize { self.frame.width() }
fn height(&self) -> usize { self.frame.height() }
unsafe fn pixel(&self, x: usize, y: usize) -> Self::Pixel {
(self.map)(self.frame.pixel(x, y))
}
}