aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index f949d06..3995c16 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,8 +7,10 @@ use std::io;
7mod decode; 7mod decode;
8mod encode; 8mod encode;
9pub mod error; 9pub mod error;
10mod rle;
10 11
11use crate::error::{OBIError, OBIResult}; 12use error::{OBIError, OBIResult};
13use 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 }