Skip to content

Commit 0e2e48b

Browse files
authored
Merge pull request #26 from image-rs/new-release
Release 1.2.0
2 parents 0c9c839 + 56c7859 commit 0e2e48b

5 files changed

Lines changed: 31 additions & 17 deletions

File tree

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
rust: ["1.36.0", stable, beta, nightly]
12+
rust: ["1.56.0", stable, beta, nightly]
1313
command: [build, test]
1414
steps:
1515
- uses: actions/checkout@v2
@@ -18,7 +18,7 @@ jobs:
1818
run: >
1919
cargo build --verbose
2020
- name: test
21-
if: ${{ matrix.rust != '1.36.0' }}
21+
if: ${{ matrix.rust != '1.56.0' }}
2222
run: >
2323
cargo test --tests --benches
2424
# TODO: add criterion benchmarks?

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 2.0.0
2+
3+
- Add `no_std` support using `core` and `alloc` only, and raise the MSRV from Rust 1.34.2 to 1.36.0 (https://github.com/image-rs/color_quant/pull/24)
4+
- Add `NeuQuant::color_map_alpha` for retrieving the palette alpha channel, useful for PNG `tRNS` chunks (https://github.com/image-rs/color_quant/pull/23)
5+
- Fix `search_netindex` so palette index 0 is checked and both search directions are handled correctly (https://github.com/image-rs/color_quant/pull/16)
6+
- Fix a sampling prime typo by changing `478` to `487` (https://github.com/image-rs/color_quant/pull/14)
7+
- Forbid unsafe code in the crate (https://github.com/image-rs/color_quant/pull/22)
8+
- Improve and specialize internal math operations used by the quantizer, and document their provenance (https://github.com/image-rs/color_quant/pull/24)
9+
110
## 1.1.0
211

312
- Unify with `image::math::nq` as per https://github.com/image-rs/image/issues/1338 (https://github.com/image-rs/color_quant/pull/10)

Cargo.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
[package]
22
name = "color_quant"
3+
version = "2.0.0"
4+
edition = "2021"
5+
resolver = "2"
6+
7+
# For now, the minimal version where this field can be defined and respected.
8+
rust-version = "1.56"
9+
310
license = "MIT"
4-
version = "1.1.0"
5-
authors = ["nwin <nwin@users.noreply.github.com>"]
6-
readme = "README.md"
711
description = "Color quantization library to reduce n colors to 256 colors."
12+
authors = ["nwin <nwin@users.noreply.github.com>", "The image-rs Developers"]
13+
readme = "README.md"
14+
15+
documentation = "https://docs.rs/color_quant"
816
repository = "https://github.com/image-rs/color_quant.git"
17+
homepage = "https://github.com/image-rs/color_quant"
18+
categories = ["multimedia::images"]

src/lib.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ that this copyright notice remain intact.
6868
//! let indixes: Vec<u8> = data.chunks(4).map(|pix| nq.index_of(pix) as u8).collect();
6969
//! let color_map = nq.color_map_rgba();
7070
//! ```
71-
7271
#![forbid(unsafe_code)]
7372
#![no_std]
7473

@@ -101,12 +100,8 @@ pub enum ControlFlow {
101100
}
102101

103102
impl ControlFlow {
104-
fn is_break(self) -> bool {
105-
if let ControlFlow::Break = self {
106-
true
107-
} else {
108-
false
109-
}
103+
fn is_break(&self) -> bool {
104+
matches!(self, ControlFlow::Break)
110105
}
111106
}
112107

@@ -147,7 +142,7 @@ impl NeuQuant {
147142
netindex: vec![0; 256],
148143
bias: Vec::with_capacity(netsize),
149144
freq: Vec::with_capacity(netsize),
150-
samplefac: samplefac,
145+
samplefac,
151146
netsize: colors,
152147
};
153148
this.init(pixels);
@@ -171,7 +166,7 @@ impl NeuQuant {
171166
r: tmp,
172167
g: tmp,
173168
b: tmp,
174-
a: a,
169+
a,
175170
});
176171
self.colormap.push(Color {
177172
r: 0,
@@ -326,7 +321,7 @@ impl NeuQuant {
326321
}
327322
self.freq[bestpos as usize] += BETA;
328323
self.bias[bestpos as usize] -= BETAGAMMA;
329-
return bestbiaspos;
324+
bestbiaspos
330325
}
331326

332327
/// Main learning loop
@@ -449,7 +444,7 @@ impl NeuQuant {
449444
}
450445
/// Search for best matching color
451446
fn search_netindex(&self, b: u8, g: u8, r: u8, a: u8) -> usize {
452-
let mut best_dist = core::i32::MAX;
447+
let mut best_dist = i32::MAX;
453448
let first_guess = self.netindex[g as usize];
454449
let mut best_pos = first_guess;
455450
let mut i = best_pos;

src/math.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(crate) fn abs(a: f64) -> f64 {
1212
} else if a.is_sign_negative() {
1313
-a
1414
} else {
15-
core::f64::NAN
15+
f64::NAN
1616
}
1717
}
1818

0 commit comments

Comments
 (0)