Skip to main content

ferroui_base/media/imaging/
png_bitmap_encoder_options.rs

1/// Specifies whether a compression operation emphasizes speed or size.
2#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
3#[repr(i32)]
4pub enum CompressionLevel {
5    /// Balances compression and speed.
6    #[default]
7    Optimal = 0,
8    /// Completes as quickly as possible, even if the result is not optimally
9    /// compressed.
10    Fastest = 1,
11    /// Performs no compression.
12    NoCompression = 2,
13    /// Produces the smallest result, even if the operation takes longer.
14    SmallestSize = 3,
15}
16
17/// Options for the PNG bitmap encoder.
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19pub struct PngBitmapEncoderOptions {
20    /// The compression level of the encoded image.
21    pub compression_level: CompressionLevel,
22}
23
24impl PngBitmapEncoderOptions {
25    /// The default options: optimal compression.
26    pub const DEFAULT: PngBitmapEncoderOptions = PngBitmapEncoderOptions { compression_level: CompressionLevel::Optimal };
27}
28
29impl Default for PngBitmapEncoderOptions {
30    fn default() -> Self {
31        Self::DEFAULT
32    }
33}