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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use crate::chan::{Ch16, Ch32, Ch8, Channel, Linear, Premultiplied};
use crate::el::{Pix1, PixRgba, Pixel};
use crate::ColorModel;
use std::ops::Range;
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Matte {}
impl ColorModel for Matte {
const CIRCULAR: Range<usize> = 0..0;
const LINEAR: Range<usize> = 0..0;
const ALPHA: usize = 0;
fn into_rgba<P>(p: P) -> PixRgba<P>
where
P: Pixel<Model = Self>,
{
let max = P::Chan::MAX;
PixRgba::<P>::new::<P::Chan>(max, max, max, p.alpha())
}
fn from_rgba<P>(rgba: PixRgba<P>) -> P
where
P: Pixel<Model = Self>,
{
let chan = rgba.channels();
P::from_channels(&[chan[3]])
}
}
pub type Matte8 = Pix1<Ch8, Matte, Premultiplied, Linear>;
pub type Matte16 = Pix1<Ch16, Matte, Premultiplied, Linear>;
pub type Matte32 = Pix1<Ch32, Matte, Premultiplied, Linear>;