From 6f78cc263ece610e5a1d6cd42ad9bb2148f06ef0 Mon Sep 17 00:00:00 2001 From: gennyble Date: Wed, 7 Jun 2023 01:06:33 -0500 Subject: so tired --- .gitignore | 1 + Cargo.lock | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 15 ++++++++++++ 4 files changed, 95 insertions(+) diff --git a/.gitignore b/.gitignore index ea8c4bf..e39cff4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +*.png \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 8bd6592..35c8a49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,84 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "fdeflate" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "flate2" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "l16-lri" version = "0.1.0" +dependencies = [ + "png", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", + "simd-adler32", +] + +[[package]] +name = "png" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaeebc51f9e7d2c150d3f3bfeb667f2aa985db5ef1e3d212847bdedb488beeaa" +dependencies = [ + "bitflags", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + +[[package]] +name = "simd-adler32" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" diff --git a/Cargo.toml b/Cargo.toml index 1ccab4a..bed2472 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +png = "0.17.8" diff --git a/src/main.rs b/src/main.rs index 210da62..1978569 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +use std::fs::File; + // This code is going to be rough. Just trying to parse this using the technique // I know: just play with the raw data fn main() { @@ -18,6 +20,9 @@ fn main() { reserved, } = header; + //AHHH it does not seem the combined legth or header length are correct? it seems like nonsense? + //drat. we'll know when I try and parse the message I think I extracted. 1510 bytes seems too + //small almost. println!("\nMagic: {magic_number}\nCombined Length: {combined_length}\nHeader Length: {header_length}\nMessage Length: {message_length}\nKind: {kind}\nReserved: {reserved:?}\nNext 8 Bytes: {:?}", &data[0..8]); let message = &data[..message_length as usize]; @@ -26,7 +31,17 @@ fn main() { println!("\nTook Message of {message_length} bytes"); println!("{} bytes left", data.len()); + let rt = (data.len() as f32).sqrt().floor() as usize; + println!("{} png", rt * rt); + println!("{:?}", &data[0..32]); + + let file = File::create("ahh.png").unwrap(); + let mut enc = png::Encoder::new(file, rt as u32, rt as u32); + enc.set_color(png::ColorType::Grayscale); + enc.set_depth(png::BitDepth::Eight); + let mut writer = enc.write_header().unwrap(); + writer.write_image_data(&data[..rt * rt]).unwrap(); } struct LightHeader { -- cgit 1.4.1-3-g733a5