Skip to content
Snippets Groups Projects
Commit 0dd9bf45 authored by Stephen D's avatar Stephen D
Browse files

revert interpolation/oversampling code

parent fa8a594d
Branches master
No related tags found
No related merge requests found
......@@ -3,27 +3,23 @@ use image::{GenericImageView, ImageReader, Rgba};
const TOAST_TIME_SECONDS: u64 = 10;
const CENTER_X: f64 = 100.0;
const CENTER_Y: f64 = 100.0;
const BREAD_HEIGHT: f64 = 0.4;
const IDLE_HEIGHT: f64 = BREAD_HEIGHT + 8.0;
const PIXEL_SIZE_MM: f64 = 1.5;
const BREAD_HEIGHT: f64 = 0.6;
const IDLE_HEIGHT: f64 = BREAD_HEIGHT + 10.0;
const PIXEL_SIZE_MM: f64 = 3.0;
fn main() -> anyhow::Result<()> {
let img = ImageReader::open("/home/stephen/Downloads/scd31-qr.png")?.decode()?;
preamble();
// 2x oversampling
for x in 0..(img.width() * 2 - 1) {
for y in 0..(img.height() * 2 - 1) {
let black = is_black(img.get_pixel(x / 2, y / 2))
&& is_black(img.get_pixel(x / 2 + x % 2, y / 2))
&& is_black(img.get_pixel(x / 2, y / 2 + y % 2))
&& is_black(img.get_pixel(x / 2 + x % 2, y / 2 + y % 2));
for x in 0..(img.width()) {
for y in 0..(img.height()) {
let black = is_black(img.get_pixel(x, y));
if black {
toast(
x as f64 - (img.width() as f64),
(img.height() as f64) - y as f64, // correct for reflection when printing
x as f64 - (img.width() as f64 / 2.0),
(img.height() as f64 / 2.0) - y as f64, // correct for reflection when printing
);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment