aboutsummaryrefslogtreecommitdiff
path: root/src/layer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/layer.rs')
-rw-r--r--src/layer.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/layer.rs b/src/layer.rs
index a8057a0..ff69f7d 100644
--- a/src/layer.rs
+++ b/src/layer.rs
@@ -12,6 +12,7 @@ use image::{
ColorType, ImageBuffer, ImageEncoder, Pixel, RgbaImage,
};
use num_traits::Zero;
+use rayon::iter::{IntoParallelIterator, ParallelIterator};
pub const TILE_HEIGHT: u64 = 256;
pub const TILE_WIDTH: u64 = 256;
@@ -104,6 +105,18 @@ impl<P: Pixel> TileLayer<P> {
}
}
+impl<P> TileLayer<P>
+where
+ P: Pixel + Send,
+ P::Subpixel: Send,
+{
+ pub fn into_parallel_tiles(
+ self,
+ ) -> impl ParallelIterator<Item = (u64, u64, ImageBuffer<P, Vec<P::Subpixel>>)> {
+ IntoParallelIterator::into_par_iter(self.tiles).map(|((x, y), t)| (x, y, t))
+ }
+}
+
pub fn compress_png<P: AsRef<Path>>(image: &RgbaImage, path: P) -> Result<()> {
let outstream = BufWriter::new(File::create(path)?);
let encoder =