initial commit

This commit is contained in:
cbax 2024-11-05 16:32:33 -05:00
commit 14bbfcb004
6 changed files with 22297 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

1062
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

8
Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "ipng"
version = "0.1.0"
edition = "2021"
[dependencies]
image = "0.25.4"
libax = { path = "../libax" }

21195
ips.lst Normal file

File diff suppressed because it is too large Load diff

BIN
ips.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

31
src/main.rs Normal file
View file

@ -0,0 +1,31 @@
use std::fs::File;
use std::io::{prelude::*, BufReader};
use std::net::Ipv4Addr;
use libax::net::Tou32;
fn main() {
let file = File::open("ips.lst").expect("Failed to open file");
let reader = BufReader::new(file);
let mut ips: Vec<[u8; 4]> = vec![];
for line in reader.lines() {
println!("{:?}", line);
if let Ok(line) = line {
if let Ok(ip) = line.parse::<Ipv4Addr>() {
ips.push(ip.to_u32().to_le_bytes());
}
}
}
let sidelength = (ips.len() as f64).sqrt() as u32;
let mut imgbuf = image::ImageBuffer::new(sidelength, sidelength);
let mut pixnum = 0;
for (_x, _y, pixel) in imgbuf.enumerate_pixels_mut() {
let mut ipdat: [u8; 4] = ips.get(pixnum).unwrap_or(&[0; 4]).to_owned();
ipdat.reverse();
*pixel = image::Rgba(ipdat);
pixnum = pixnum + 1;
}
println!("{:?}", ips);
imgbuf.save("ips.png").unwrap();
}