| 1 | //! Channel orders for packed Luma types. |
| 2 | |
| 3 | use crate::{cast::ComponentOrder, luma}; |
| 4 | |
| 5 | /// Luma+Alpha color packed in LA order. |
| 6 | /// |
| 7 | /// See [Packed](crate::cast::Packed) for more details. |
| 8 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
| 9 | pub struct La; |
| 10 | |
| 11 | impl<S, T> ComponentOrder<luma::Lumaa<S, T>, [T; 2]> for La { |
| 12 | #[inline] |
| 13 | fn pack(color: luma::Lumaa<S, T>) -> [T; 2] { |
| 14 | color.into() |
| 15 | } |
| 16 | |
| 17 | #[inline] |
| 18 | fn unpack(packed: [T; 2]) -> luma::Lumaa<S, T> { |
| 19 | packed.into() |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | /// Luma+Alpha color packed in AL order. |
| 24 | /// |
| 25 | /// See [Packed](crate::cast::Packed) for more details. |
| 26 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
| 27 | pub struct Al; |
| 28 | |
| 29 | impl<S, T> ComponentOrder<luma::Lumaa<S, T>, [T; 2]> for Al { |
| 30 | #[inline] |
| 31 | fn pack(color: luma::Lumaa<S, T>) -> [T; 2] { |
| 32 | let [luma, alpha]: [T; 2] = color.into(); |
| 33 | [alpha, luma] |
| 34 | } |
| 35 | |
| 36 | #[inline] |
| 37 | fn unpack(packed: [T; 2]) -> luma::Lumaa<S, T> { |
| 38 | let [alpha, luma] = packed; |
| 39 | luma::Lumaa::new(luma, alpha) |
| 40 | } |
| 41 | } |