pub struct ModularImage {
pub channels: Vec<Channel>,
pub bit_depth: u32,
pub is_grayscale: bool,
pub has_alpha: bool,
}Expand description
A modular image consisting of multiple channels.
For RGB images, this typically contains 3 channels. For RGBA, 4 channels (with alpha stored last).
Fields§
§channels: Vec<Channel>The channels in this image.
bit_depth: u32Bit depth of the original image.
is_grayscale: boolWhether the image is originally grayscale.
has_alpha: boolWhether the image has alpha.
Implementations§
Source§impl ModularImage
impl ModularImage
Sourcepub fn from_rgb8(data: &[u8], width: usize, height: usize) -> Result<Self>
pub fn from_rgb8(data: &[u8], width: usize, height: usize) -> Result<Self>
Creates a new modular image from 8-bit RGB data.
Sourcepub fn from_rgba8(data: &[u8], width: usize, height: usize) -> Result<Self>
pub fn from_rgba8(data: &[u8], width: usize, height: usize) -> Result<Self>
Creates a new modular image from 8-bit RGBA data.
Sourcepub fn from_gray8(data: &[u8], width: usize, height: usize) -> Result<Self>
pub fn from_gray8(data: &[u8], width: usize, height: usize) -> Result<Self>
Creates a new modular image from 8-bit grayscale data.
Sourcepub fn from_rgb16(data: &[u8], width: usize, height: usize) -> Result<Self>
pub fn from_rgb16(data: &[u8], width: usize, height: usize) -> Result<Self>
Creates a new modular image from 16-bit RGB data (big-endian).
Sourcepub fn from_rgb16_native(
data: &[u8],
width: usize,
height: usize,
) -> Result<Self>
pub fn from_rgb16_native( data: &[u8], width: usize, height: usize, ) -> Result<Self>
Creates a new modular image from native-endian 16-bit RGB data.
Input is a byte slice interpreted as &[u16] in native endian order
(6 bytes per pixel: R_lo, R_hi, G_lo, G_hi, B_lo, B_hi on little-endian).
Sourcepub fn from_rgba16_native(
data: &[u8],
width: usize,
height: usize,
) -> Result<Self>
pub fn from_rgba16_native( data: &[u8], width: usize, height: usize, ) -> Result<Self>
Creates a new modular image from native-endian 16-bit RGBA data.
Input is 8 bytes per pixel (R, G, B, A as native-endian u16).
Sourcepub fn from_grayalpha8(data: &[u8], width: usize, height: usize) -> Result<Self>
pub fn from_grayalpha8(data: &[u8], width: usize, height: usize) -> Result<Self>
Creates a new modular image from 8-bit grayscale + alpha data (2 bytes per pixel).
Sourcepub fn from_gray16_native(
data: &[u8],
width: usize,
height: usize,
) -> Result<Self>
pub fn from_gray16_native( data: &[u8], width: usize, height: usize, ) -> Result<Self>
Creates a new modular image from native-endian 16-bit grayscale data.
Input is 2 bytes per pixel (native-endian u16).
Sourcepub fn from_grayalpha16_native(
data: &[u8],
width: usize,
height: usize,
) -> Result<Self>
pub fn from_grayalpha16_native( data: &[u8], width: usize, height: usize, ) -> Result<Self>
Creates a new modular image from native-endian 16-bit grayscale + alpha data.
Input is 4 bytes per pixel (native-endian u16 gray, u16 alpha).
Sourcepub fn num_channels(&self) -> usize
pub fn num_channels(&self) -> usize
Returns the number of channels.
Sourcepub fn channel_mut(&mut self, idx: usize) -> &mut Channel
pub fn channel_mut(&mut self, idx: usize) -> &mut Channel
Returns a mutable reference to a channel.
Trait Implementations§
Source§impl Clone for ModularImage
impl Clone for ModularImage
Source§fn clone(&self) -> ModularImage
fn clone(&self) -> ModularImage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ModularImage
impl RefUnwindSafe for ModularImage
impl Send for ModularImage
impl Sync for ModularImage
impl Unpin for ModularImage
impl UnsafeUnpin for ModularImage
impl UnwindSafe for ModularImage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more