Commit 15c0cada authored by Romain Vimont's avatar Romain Vimont Committed by Thomas Daede

Add a method to create Plane from Vec

This will help to use Plane and PlaneSlice in tests.
parent a879a1b9
...@@ -85,6 +85,26 @@ impl<T: Pixel> Plane<T> { ...@@ -85,6 +85,26 @@ impl<T: Pixel> Plane<T> {
} }
} }
pub fn wrap(data: Vec<T>, stride: usize) -> Self {
let len = data.len();
assert!(len % stride == 0);
Self {
data,
cfg: PlaneConfig {
stride,
alloc_height: len / stride,
width: stride,
height: len / stride,
xdec: 0,
ydec: 0,
xpad: 0,
ypad: 0,
xorigin: 0,
yorigin: 0,
}
}
}
pub fn pad(&mut self, w: usize, h: usize) { pub fn pad(&mut self, w: usize, h: usize) {
let xorigin = self.cfg.xorigin; let xorigin = self.cfg.xorigin;
let yorigin = self.cfg.yorigin; let yorigin = self.cfg.yorigin;
......
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