diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -7,8 +7,10 @@ use std::io; | |||
7 | mod decode; | 7 | mod decode; |
8 | mod encode; | 8 | mod encode; |
9 | pub mod error; | 9 | pub mod error; |
10 | mod rle; | ||
10 | 11 | ||
11 | use crate::error::{OBIError, OBIResult}; | 12 | use error::{OBIError, OBIResult}; |
13 | use rle::RLE; | ||
12 | 14 | ||
13 | #[non_exhaustive] | 15 | #[non_exhaustive] |
14 | #[derive(Copy, Clone, Debug, PartialEq)] | 16 | #[derive(Copy, Clone, Debug, PartialEq)] |
@@ -83,6 +85,14 @@ impl CompressionType { | |||
83 | _ => panic!("Invalid compression algorithm"), | 85 | _ => panic!("Invalid compression algorithm"), |
84 | } | 86 | } |
85 | } | 87 | } |
88 | pub fn to_u32(self) -> u32 { | ||
89 | match self { | ||
90 | CompressionType::None => 0, | ||
91 | CompressionType::RLE => 1, | ||
92 | CompressionType::Kosinki => 10, | ||
93 | _ => panic!("Invalid compression algorithm"), | ||
94 | } | ||
95 | } | ||
86 | } | 96 | } |
87 | 97 | ||
88 | #[derive(Debug)] | 98 | #[derive(Debug)] |
@@ -111,6 +121,10 @@ impl Image { | |||
111 | } | 121 | } |
112 | } | 122 | } |
113 | 123 | ||
124 | pub fn use_compression(&mut self, comp: CompressionType) { | ||
125 | self.image_info_header.compression_type = comp.to_u32(); | ||
126 | } | ||
127 | |||
114 | pub fn width(&self) -> u32 { | 128 | pub fn width(&self) -> u32 { |
115 | self.image_info_header.width | 129 | self.image_info_header.width |
116 | } | 130 | } |