Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated items #1519

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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