Creating mutable sub arrays of Image buffer
⚓ Rust 📅 2026-02-13 👤 surdeus 👁️ 1Hi I am new to rust and attempting to learn enough to evaluate the language by writing in Rust a program that I have successfully written in Kotlin. I am probably going to ask some pretty stupid questions since the resource management is totally different to that with which I am familiar.
I will be processing an image hopefully on multiple threads at once. I have written the code to do grey scale conversion the hard way (as a stepping stone to something more useful):
- Load image
- Iterate through pixels (x, y) converting each to grey
- Write the image.
How do I get mutable sub-arrays so that I can use multiple threads. image::deref_mut looks interesting, but the docs look a little dense to my untrained eye:
`impl<P, Container> IndexMut<(u32, u32)> for ImageBuffer<P, Container>
where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]> + DerefMut, `
I am assuming that the two parameters define the range of the sub array, but is this start,end or start,length? Is the resultant structure addressed as a one dimensonal array or a two dimensional array (unlikely).
My apologies if I am barking up the wrong kettle of fish.
Phill
1 post - 1 participant
🏷️ Rust_feed