Add Header::new() and with_colorspace()
This commit is contained in:
parent
02734e4eca
commit
3ec3d34987
1 changed files with 11 additions and 0 deletions
|
@ -41,6 +41,17 @@ const fn u32_from_be(v: &[u8]) -> u32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Header {
|
impl Header {
|
||||||
|
#[inline]
|
||||||
|
pub const fn new(width: u32, height: u32, channels: u8) -> Self {
|
||||||
|
Self { magic: QOI_MAGIC, width, height, channels, colorspace: ColorSpace::from_u8(0) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn with_colorspace(mut self, colorspace: impl Into<ColorSpace>) -> Self {
|
||||||
|
self.colorspace = colorspace.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn encoded_size() -> usize {
|
pub const fn encoded_size() -> usize {
|
||||||
QOI_HEADER_SIZE
|
QOI_HEADER_SIZE
|
||||||
|
|
Loading…
Reference in a new issue