Created
July 15, 2019 03:58
-
-
Save SnoozeTime/730e697816bc3ea9ea5edf41b0e6b0c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl<P, Container> ImageBuffer<P, Container> | |
where | |
P: Pixel<Subpixel = u8> + 'static, | |
Container: Deref<Target = [u8]>, | |
{ | |
/// Saves the buffer to a file at the path specified. | |
/// | |
/// The image format is derived from the file extension. | |
/// Currently only jpeg and png files are supported. | |
pub fn save<Q>(&self, path: Q) -> io::Result<()> | |
where | |
Q: AsRef<Path>, | |
{ | |
// This is valid as the subpixel is u8. | |
save_buffer( | |
path, | |
self, | |
self.width(), | |
self.height(), | |
<P as Pixel>::COLOR_TYPE, | |
) | |
} | |
} | |
impl<P, Container> ImageBuffer<P, Container> | |
where | |
P: Pixel<Subpixel = u16> + 'static, | |
Container: Deref<Target = [u16]>, | |
{ | |
/// Saves the buffer to a file at the path specified | |
/// | |
/// | |
pub fn saveu16<Q>(&self, path: Q) -> io::Result<()> | |
where | |
Q: AsRef<Path>, | |
{ | |
save_buffer_u16( | |
path, | |
self, | |
self.width(), | |
self.height(), | |
<P as Pixel>::COLOR_TYPE, | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment