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_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 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 more