divide idk

This commit is contained in:
bendn 2023-10-28 21:02:59 +07:00
parent 2c88066426
commit fcb40e93be
No known key found for this signature in database
GPG key ID: 0D9D3A2A3B2A93D6
2 changed files with 9 additions and 0 deletions

View file

@ -75,6 +75,8 @@ macro_rules! alg {
.resize(&ChannelCount::<N>::handle(i).view(), &mut dst.view_mut()) .resize(&ChannelCount::<N>::handle(i).view(), &mut dst.view_mut())
} }
ChannelCount::<N>::unhandle(&mut dst);
// SAFETY: ctor // SAFETY: ctor
unsafe { Image::new(dst.width(), dst.height(), dst.into_vec().into()) } unsafe { Image::new(dst.width(), dst.height(), dst.into_vec().into()) }
} }

View file

@ -49,6 +49,8 @@ pub trait AlphaDiv<const N: usize>: Sealed + ToImageView<N> {
type P: fr::PixelExt + fr::Convolution + fr::AlphaMulDiv; type P: fr::PixelExt + fr::Convolution + fr::AlphaMulDiv;
#[doc(hidden)] #[doc(hidden)]
fn handle(i: Image<&mut [u8], N>) -> fr::Image<'_, <Self as AlphaDiv<N>>::P>; fn handle(i: Image<&mut [u8], N>) -> fr::Image<'_, <Self as AlphaDiv<N>>::P>;
#[doc(hidden)]
fn unhandle(i: &mut fr::Image<<Self as AlphaDiv<N>>::P>);
} }
/// Generic helper for [`Image`] and [`fr::Image`] transfers. /// Generic helper for [`Image`] and [`fr::Image`] transfers.
@ -83,6 +85,11 @@ macro_rules! adiv {
i i
} }
fn unhandle(i: &mut fr::Image<<Self as AlphaDiv<$n>>::P>) {
// SAFETY: mhm
unsafe { fr::MulDiv::default().divide_alpha_inplace(&mut i.view_mut()) }
}
} }
}; };
} }