Commit 542482e3 authored by Romain Vimont's avatar Romain Vimont Committed by Luca Barbato

Add method to create PlaneSlice view from a Plane

Many functions currently using a primitive slice along with the stride
information will accept a Plane(Mut)Slice instead.

As a consequence, we will often need to get a Plane(Mut)Slice instance
without any offset, so add a convenient function which do not require a
&PlaneOffset parameter.
parent d978a356
......@@ -145,6 +145,14 @@ impl<T: Pixel> Plane<T> {
PlaneMutSlice { plane: self, x: po.x, y: po.y }
pub fn as_slice(&self) -> PlaneSlice<'_, T> {
self.slice(&PlaneOffset { x: 0, y: 0 })
pub fn as_mut_slice(&mut self) -> PlaneMutSlice<'_, T> {
self.mut_slice(&PlaneOffset { x: 0, y: 0 })
fn index(&self, x: usize, y: usize) -> usize {
(y + self.cfg.yorigin) * self.cfg.stride + (x + self.cfg.xorigin)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment