Skip to content

Commit

Permalink
Merge pull request #1519 from JulianKnodt/rm_deprecated
Browse files Browse the repository at this point in the history
Remove deprecated items
  • Loading branch information
fintelia authored Jul 20, 2021
2 parents 304815f + 6583f29 commit ca537c2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 173 deletions.
27 changes: 0 additions & 27 deletions src/imageops/colorops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use std::f64::consts::PI;

use crate::color::{Luma, Rgba};
use crate::image::{GenericImage, GenericImageView};
#[allow(deprecated)]
use crate::math::nq;
use crate::traits::{Pixel, Primitive};
use crate::utils::clamp;
use crate::ImageBuffer;
Expand Down Expand Up @@ -394,31 +392,6 @@ impl ColorMap for BiLevel {
}
}

#[allow(deprecated)]
impl ColorMap for nq::NeuQuant {
type Color = Rgba<u8>;

#[inline(always)]
fn index_of(&self, color: &Rgba<u8>) -> usize {
self.index_of(color.channels())
}

#[inline(always)]
fn lookup(&self, idx: usize) -> Option<Self::Color> {
self.lookup(idx).map(|p| p.into())
}

/// Indicate NeuQuant implements `lookup`.
fn has_lookup(&self) -> bool {
true
}

#[inline(always)]
fn map_color(&self, color: &mut Rgba<u8>) {
self.map_pixel(color.channels_mut())
}
}

impl ColorMap for color_quant::NeuQuant {
type Color = Rgba<u8>;

Expand Down
5 changes: 2 additions & 3 deletions src/math/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Mathematical helper functions and types.
pub mod nq;
pub mod utils;
mod utils;

mod rect;
pub use self::rect::Rect;
pub(crate) use self::utils::resize_dimensions;
pub(super) use utils::resize_dimensions;
116 changes: 0 additions & 116 deletions src/math/nq.rs

This file was deleted.

34 changes: 7 additions & 27 deletions src/math/utils.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,17 @@
//! Shared mathematical utility functions.
/// Cut value to be inside given range
///
/// ```
/// use image::math::utils;
///
/// assert_eq!(utils::clamp(-5, 0, 10), 0);
/// assert_eq!(utils::clamp( 6, 0, 10), 6);
/// assert_eq!(utils::clamp(15, 0, 10), 10);
/// ```
#[inline]
#[deprecated]
pub fn clamp<N>(a: N, min: N, max: N) -> N
where
N: PartialOrd,
{
if a < min {
return min;
}
if a > max {
return max;
}
a
}

/// Calculates the width and height an image should be resized to.
/// This preserves aspect ratio, and based on the `fill` parameter
/// will either fill the dimensions to fit inside the smaller constraint
/// (will overflow the specified bounds on one axis to preserve
/// aspect ratio), or will shrink so that both dimensions are
/// completely contained with in the given `width` and `height`,
/// with empty space on one axis.
pub(crate) fn resize_dimensions(width: u32, height: u32, nwidth: u32, nheight: u32, fill: bool) -> (u32, u32) {
pub(crate) fn resize_dimensions(
width: u32,
height: u32,
nwidth: u32,
nheight: u32,
fill: bool,
) -> (u32, u32) {
let ratio = u64::from(width) * u64::from(nheight);
let nratio = u64::from(nwidth) * u64::from(height);

Expand Down

0 comments on commit ca537c2

Please sign in to comment.