runtime: add ARGB8 pixel format
This commit is contained in:
parent
9c895caa51
commit
5feac91af2
|
@ -26,6 +26,11 @@ pub struct RGBA8;
|
||||||
/// Every BGR with alpha pixel is represented with 32 bits.
|
/// Every BGR with alpha pixel is represented with 32 bits.
|
||||||
pub struct BGRA8;
|
pub struct BGRA8;
|
||||||
|
|
||||||
|
/// A8R8G8B8 pixel format.
|
||||||
|
///
|
||||||
|
/// Every BGR with alpha pixel is represented with 32 bits.
|
||||||
|
pub struct ARGB8;
|
||||||
|
|
||||||
/// Represents an image pixel format to convert images into.
|
/// Represents an image pixel format to convert images into.
|
||||||
pub trait PixelFormat {
|
pub trait PixelFormat {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -45,6 +50,16 @@ impl PixelFormat for BGRA8 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PixelFormat for ARGB8 {
|
||||||
|
fn convert(pixels: &mut Vec<u8>) {
|
||||||
|
assert!(pixels.len() % 4 == 0);
|
||||||
|
for [r, _g, b, a] in ArrayChunksMut::new(pixels) {
|
||||||
|
std::mem::swap(r, a); // abgr
|
||||||
|
std::mem::swap(b, r); // argb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The direction of UV coordinates to load the image for.
|
/// The direction of UV coordinates to load the image for.
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum UVDirection {
|
pub enum UVDirection {
|
||||||
|
|
Loading…
Reference in a new issue