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
30
31
use super::super::Image;
pub fn scale<T>(
width: usize,
height: usize,
frame: T
) -> Scale<T> {
Scale { width, height, frame }
}
#[doc(hidden)]
pub struct Scale<T> {
width: usize,
height: usize,
frame: T
}
impl<T: Image> Image for Scale<T> {
type Pixel = T::Pixel;
fn width(&self) -> usize { self.width }
fn height(&self) -> usize { self.height }
unsafe fn pixel(&self, x: usize, y: usize) -> Self::Pixel {
self.frame.pixel(
x * self.frame.width() / self.width,
y * self.frame.height() / self.height
)
}
}