if let Some(r) = self.iter.next() {
let g = self.iter.next().unwrap_or(T::zero());
let b = self.iter.next().unwrap_or(T::zero());
- println!("{} {} {}", r.as_(), g.as_(), b.as_());
Some(Rgb([r.as_(), g.as_(), b.as_()]))
}
else {
format!("Hello {name}!")
}
-fn make_png(dim_x: u32, dim_y: u32, scale: u32, data: &str) -> Result<Cursor<Vec<u8>>, ImageError> {
+fn make_png(dim_x: u32, dim_y: u32, scale: u32, data: &mut dyn Iterator<Item = u8>) -> Result<Cursor<Vec<u8>>, ImageError> {
let mut img: RgbImage = ImageBuffer::new(dim_x, dim_y);
let mut pixels = img.pixels_mut();
- for sp in ToRgbIter::new(percent_decode_str(&data).into_iter().borrow_mut()) {
+ for sp in ToRgbIter::new(data) {
let mut dp = pixels.next().unwrap();
println!("{:?}", sp);
dp.0 = sp.0;
#[get("/gen/0/{data}")]
async fn img_gen0(req: HttpRequest) -> Result<impl Responder> {
let data = req.uri().path().split("/").skip(3).next().unwrap();
- let cursor = make_png(32, 32, 16, &data)?;
+ let cursor = make_png(32, 32, 16, percent_decode_str(&data).into_iter().borrow_mut())?;
Ok(HttpResponse::build(StatusCode::OK)
.content_type("image/png")
.body(cursor.into_inner()))