Extract a function into a submodule
This commit is contained in:
parent
3497040b78
commit
348c7dbc56
2 changed files with 11 additions and 6 deletions
|
|
@ -44,6 +44,16 @@ impl ColorType {
|
||||||
ColorType::RGBA => 6,
|
ColorType::RGBA => 6,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn channels_per_pixel(&self) -> u8 {
|
||||||
|
match *self {
|
||||||
|
ColorType::Grayscale | ColorType::Indexed => 1,
|
||||||
|
ColorType::GrayscaleAlpha => 2,
|
||||||
|
ColorType::RGB => 3,
|
||||||
|
ColorType::RGBA => 4,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||||
|
|
|
||||||
|
|
@ -172,12 +172,7 @@ impl PngData {
|
||||||
/// Return the number of channels in the image, based on color type
|
/// Return the number of channels in the image, based on color type
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn channels_per_pixel(&self) -> u8 {
|
pub fn channels_per_pixel(&self) -> u8 {
|
||||||
match self.ihdr_data.color_type {
|
self.ihdr_data.color_type.channels_per_pixel()
|
||||||
ColorType::Grayscale | ColorType::Indexed => 1,
|
|
||||||
ColorType::GrayscaleAlpha => 2,
|
|
||||||
ColorType::RGB => 3,
|
|
||||||
ColorType::RGBA => 4,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format the `PngData` struct into a valid PNG bytestream
|
/// Format the `PngData` struct into a valid PNG bytestream
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue