From 88dca85da749c7172a9b990374534162cab01ea8 Mon Sep 17 00:00:00 2001 From: Celeste Date: Sat, 29 Jan 2022 19:13:05 +0000 Subject: [PATCH] a --- .gitignore | 1 + Cargo.lock | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 9 +++++ src/main.rs | 29 ++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..3acab50 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,95 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adler32" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "deflate" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4" +dependencies = [ + "adler32", + "byteorder", +] + +[[package]] +name = "inflate" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5f9f47468e9a76a6452271efadc88fe865a82be91fe75e6c0c57b87ccea59d4" +dependencies = [ + "adler32", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "png" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0b0cabbbd20c2d7f06dbf015e06aad59b6ca3d9ed14848783e98af9aaf19925" +dependencies = [ + "bitflags", + "deflate", + "inflate", + "num-iter", +] + +[[package]] +name = "pngxor" +version = "0.1.0" +dependencies = [ + "png", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000..c9be215 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "pngxor" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +png = "0.11.0" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 000000000..108f2b3 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,29 @@ +use std::fs::File; +use std::io::BufWriter; +use std::path::Path; +use png::HasParameters; + +fn main() { + println!("a"); + let decoder = png::Decoder::new(File::open("input.png").unwrap()); + let (info ,mut reader) = decoder.read_info().unwrap(); + let mut buf = vec![0; info.buffer_size()]; + println!("b"); + reader.next_frame(&mut buf).unwrap(); + let mut luf = [].to_vec(); + let mut i = 0; + for x in buf { + let y = x^255; + println!("{}", i); + i = i + 1; + luf.push(y); + } + let path = Path::new(r"output.png"); + let file = File::create(path).unwrap(); + let ref mut w = BufWriter::new(file); + let mut encoder = png::Encoder::new(w, info.width, info.height); + encoder.set(info.color_type).set(info.bit_depth); + let mut writer = encoder.write_header().unwrap(); + + writer.write_image_data(&luf).unwrap(); +}