-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use factor::factor::factor; | ||
|
||
use crate::image::Image; | ||
use crate::parser::ParserType; | ||
|
||
pub struct Raw(Vec<u8>); | ||
|
||
impl Raw { | ||
pub fn new(data: &[u8]) -> Self { | ||
Self(data.to_owned()) | ||
} | ||
fn byte_count(&self) -> usize { | ||
self.0.len() | ||
} | ||
fn cga_count(&self) -> usize { | ||
self.byte_count() * 4 | ||
} | ||
fn ega_count(&self) -> usize { | ||
self.byte_count() * 2 | ||
} | ||
pub fn cga_possible(&self) -> bool { | ||
self.cga_count() <= 64_000 | ||
} | ||
pub fn cga_fullscreen(&self) -> bool { | ||
self.cga_count() == 64_000 | ||
} | ||
pub fn cga_widths(&self) -> Vec<i64> { | ||
factor(self.cga_count().try_into().unwrap()) | ||
} | ||
pub fn ega_widths(&self) -> Vec<i64> { | ||
factor(self.ega_count().try_into().unwrap()) | ||
} | ||
|
||
pub fn parse(&self, parser: ParserType, width: usize) -> Image { | ||
Image(parser.process_input(&self.0, width)) | ||
} | ||
} |
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
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