Skip to content

Commit

Permalink
Implement array to ARGB
Browse files Browse the repository at this point in the history
Fixes #54
  • Loading branch information
kornelski committed Feb 7, 2023
1 parent 1d35905 commit 9d4870b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/internal/convert/array.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "argb")]
use crate::alt::{ARGB};
use crate::alt::{BGR, BGRA};
use crate::{RGB, RGBA};

Expand Down Expand Up @@ -38,6 +40,27 @@ impl<T> Into<[T; 4]> for RGBA<T> {
}
}

#[cfg(feature = "argb")]
impl<T: Copy> From<[T; 4]> for ARGB<T> {
#[inline(always)]
fn from(other: [T; 4]) -> Self {
Self {
a: other[0],
r: other[1],
g: other[2],
b: other[3],
}
}
}

#[cfg(feature = "argb")]
impl<T> Into<[T; 4]> for ARGB<T> {
#[inline(always)]
fn into(self) -> [T; 4] {
[self.a, self.r, self.g, self.b]
}
}

impl<T: Copy> From<[T; 3]> for BGR<T> {
#[inline(always)]
fn from(other: [T; 3]) -> Self {
Expand Down

0 comments on commit 9d4870b

Please sign in to comment.