image-rs / color_quant

Color quantization library
MIT License
36 stars 16 forks source link

Unify `image::math::nq` with this crate #10

Closed TianyiShi2001 closed 4 years ago

TianyiShi2001 commented 4 years ago

Unify image::math::nq. See: https://github.com/image-rs/image/issues/1338

Summary:

image::math::nq used f64::from(<some i32 value>) and i32::from(<some u8 value>), but these conversions cannot be lossy, so I kept them as .. as f64 and .. as i32

TianyiShi2001 commented 4 years ago

I'll add more syntax chages, for example:

let (r, g, b, a) = {
                let p = &pixels[CHANNELS * pos..][..CHANNELS];
                (p[0] as f64, p[1] as f64, p[2] as f64, p[3] as f64)

will probably become p.chunks_exact().

But these will be in another PR. The topic of this PR is just to unite with image::math::nq