A images/Piet_hello2_big_upscaled.png => images/Piet_hello2_big_upscaled.png +0 -0
A images/Piet_hello_big_upscaled.png => images/Piet_hello_big_upscaled.png +0 -0
M src/translator.rs => src/translator.rs +5 -13
@@ 16,15 16,11 @@ where P: AsRef<Path>
if let DynamicImage::ImageRgb8(rgb_img) = img {
- let mut codels: Vec<Vec<Codel>> = vec!();
- for row in rgb_img.rows() {
- codels.push(vec!());
- let len = codels.len();
- for Rgb(bytes) in row {
- let codel = Codel::from_bytes(*bytes);
- codels[len - 1].push(codel);
- }
- }
+
+ let codels = rgb_img.rows().map(|row| row.into_iter()
+ .map(|Rgb(bytes)| Codel::from_bytes(*bytes))
+ .collect()
+ ).collect();
let codel_size = codel_size(&codels);
@@ 32,14 28,10 @@ where P: AsRef<Path>
rgb_img.dimensions().1 / codel_size);
- eprintln!("dimensions: {:?}", dimensions);
-
let upscaled_codels = codels.into_iter().step_by((codel_size) as usize)
.map(|row| row.into_iter().step_by((codel_size) as usize).collect())
.collect();
- eprintln!("upscaled_codels: {:#?}", upscaled_codels);
-
return Ok(PietImage::new(dimensions, upscaled_codels));
}