akaihola / shootadoc-rust

A Rust implementation of Shoot A Doc
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Use views to prevent image copies #3

Closed akaihola closed 3 years ago

akaihola commented 3 years ago

I was still intrigued by the problem of using views. I didn't manage managed to do it, but and in this incomplete implementation

I can't wrap my head around solved this by using GenericImageView instead of GenericImage:

error[E0277]: the trait bound `&image::ImageBuffer<image::Luma<u8>, std::vec::Vec<u8>>: std::ops::DerefMut` is not satisfied
  --> src/main.rs:39:26
   |
14 | fn brightest<T: GenericImage>(img1: T, img2: T) -> GrayImage {
   |                 ------------ required by this bound in `brightest`
...
39 |         let top_pixels = brightest(orig, left);
   |                          ^^^^^^^^^ the trait `std::ops::DerefMut` is not implemented for `&image::ImageBuffer<image::Luma<u8>, std::vec::Vec<u8>>`
   |
   = help: the following implementations were found:
             <image::ImageBuffer<P, Container> as std::ops::DerefMut>
   = note: `std::ops::DerefMut` is implemented for `&mut image::ImageBuffer<image::Luma<u8>, std::vec::Vec<u8>>`, but not for `&image::ImageBuffer<image::Luma<u8>, std::vec::Vec<u8>>`
   = note: required because of the requirements on the impl of `image::GenericImage` for `image::SubImage<&image::ImageBuffer<image::Luma<u8>, std::vec::Vec<u8>>>`
samoylovfp commented 3 years ago

Wow! Kudos for figuring this out!