Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ea7369

Browse files
committed
Adjust bounds on from_raw_rgb
These new bounds ensure that only our own pixel types can be used. That prepares changing our approach of algorithms such that we can optimize for individual cases without falling prey to needs for specialization. More context can be found here: <#2596 (comment)>
1 parent dd60a60 commit 6ea7369

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/images/buffer.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,9 +1464,8 @@ impl<P: Pixel> ImageBuffer<P, Vec<P::Subpixel>> {
14641464

14651465
impl<S, Container> ImageBuffer<Rgb<S>, Container>
14661466
where
1467-
S: crate::Primitive + crate::traits::Enlargeable,
1468-
Rgb<S>: Pixel,
1469-
Container: DerefMut<Target = [<Rgb<S> as Pixel>::Subpixel]>,
1467+
Rgb<S>: PixelWithColorType<Subpixel = S>,
1468+
Container: DerefMut<Target = [S]>,
14701469
{
14711470
/// Construct an image by swapping `Bgr` channels into an `Rgb` order.
14721471
pub fn from_raw_bgr(width: u32, height: u32, container: Container) -> Option<Self> {
@@ -1491,9 +1490,8 @@ where
14911490

14921491
impl<S, Container> ImageBuffer<Rgba<S>, Container>
14931492
where
1494-
S: crate::Primitive + crate::traits::Enlargeable,
1495-
Rgb<S>: Pixel,
1496-
Container: DerefMut<Target = [<Rgba<S> as Pixel>::Subpixel]>,
1493+
Rgba<S>: PixelWithColorType<Subpixel = S>,
1494+
Container: DerefMut<Target = [S]>,
14971495
{
14981496
/// Construct an image by swapping `BgrA` channels into an `RgbA` order.
14991497
pub fn from_raw_bgra(width: u32, height: u32, container: Container) -> Option<Self> {

0 commit comments

Comments
 (0)