From fcb40e93bec40b1965435a027a8101e5d5e230c3 Mon Sep 17 00:00:00 2001 From: bendn Date: Sat, 28 Oct 2023 21:02:59 +0700 Subject: [PATCH] divide idk --- src/scale/algorithms.rs | 2 ++ src/scale/traits.rs | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/scale/algorithms.rs b/src/scale/algorithms.rs index d1dd6cf..55a71d2 100644 --- a/src/scale/algorithms.rs +++ b/src/scale/algorithms.rs @@ -75,6 +75,8 @@ macro_rules! alg { .resize(&ChannelCount::::handle(i).view(), &mut dst.view_mut()) } + ChannelCount::::unhandle(&mut dst); + // SAFETY: ctor unsafe { Image::new(dst.width(), dst.height(), dst.into_vec().into()) } } diff --git a/src/scale/traits.rs b/src/scale/traits.rs index 66d1ddb..68c2b16 100644 --- a/src/scale/traits.rs +++ b/src/scale/traits.rs @@ -49,6 +49,8 @@ pub trait AlphaDiv: Sealed + ToImageView { type P: fr::PixelExt + fr::Convolution + fr::AlphaMulDiv; #[doc(hidden)] fn handle(i: Image<&mut [u8], N>) -> fr::Image<'_, >::P>; + #[doc(hidden)] + fn unhandle(i: &mut fr::Image<>::P>); } /// Generic helper for [`Image`] and [`fr::Image`] transfers. @@ -83,6 +85,11 @@ macro_rules! adiv { i } + + fn unhandle(i: &mut fr::Image<>::P>) { + // SAFETY: mhm + unsafe { fr::MulDiv::default().divide_alpha_inplace(&mut i.view_mut()) } + } } }; }