fast image operations
add buf_unchecked
| -rw-r--r-- | src/indexed/builder.rs | 10 | ||||
| -rw-r--r-- | src/lib.rs | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/indexed/builder.rs b/src/indexed/builder.rs index b00c12f..e8b5ad1 100644 --- a/src/indexed/builder.rs +++ b/src/indexed/builder.rs @@ -57,6 +57,16 @@ impl<B, P> Builder<B, P> { .unwrap() } + pub unsafe fn buf_unchecked<I>(self, buffer: B) -> Image<B, P> + where + B: AsRef<[I]>, + { + Image { + buffer: crate::Image::build(self.width, self.height).buf(buffer), + palette: self.palette.expect("require palette"), + } + } + /// Allocates a zeroed buffer. #[track_caller] #[must_use] @@ -485,7 +485,9 @@ impl<T, const CHANNELS: usize> Image<T, CHANNELS> { #[inline] /// Returns a iterator over every pixel - pub fn chunked<'a, U: 'a>(&'a self) -> impl DoubleEndedIterator<Item = &'a [U; CHANNELS]> + pub fn chunked<'a, U: 'a>( + &'a self, + ) -> impl DoubleEndedIterator<Item = &'a [U; CHANNELS]> + ExactSizeIterator where T: AsRef<[U]>, { |