diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index c8523e17..8c2766e6 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -98,7 +98,7 @@ jobs: # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability strategy: matrix: - msrv: ["1.80.1"] # Don't forget to update the `rust-version` in Cargo.toml as well + msrv: ["1.81.0"] # Don't forget to update the `rust-version` in Cargo.toml as well name: ubuntu / ${{ matrix.msrv }} steps: - uses: actions/checkout@v4 diff --git a/Cargo.toml b/Cargo.toml index 3520d054..2d31208e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "imageproc" -version = "0.26.0" +version = "0.26.1" authors = ["theotherphil"] # note: when changed, also update `msrv` in `.github/workflows/check.yml` -rust-version = "1.80.1" +rust-version = "1.81.0" edition = "2021" license = "MIT" description = "Image processing operations" @@ -20,7 +20,7 @@ rayon = ["dep:rayon", "image/rayon"] [dependencies] ab_glyph = { version = "0.2.23", default-features = false, features = ["std"] } approx = { version = "0.5", default-features = false } -image = { version = "0.25.0", default-features = false } +image = { version = "0.25.6", default-features = false } itertools = { version = "0.13.0", default-features = false, features = [ "use_std", ] } @@ -31,7 +31,7 @@ rand = { version = "0.8.5", default-features = false, features = [ "std_rng", ] } rand_distr = { version = "0.4.3", default-features = false } -rayon = { version = "1.8.0", optional = true, default-features = false } +rayon = { version = "1.10.0", optional = true, default-features = false } sdl2 = { version = "0.36", optional = true, default-features = false, features = [ "bundled", ] } diff --git a/src/contrast.rs b/src/contrast.rs index c9024f1b..ac67c97d 100644 --- a/src/contrast.rs +++ b/src/contrast.rs @@ -462,6 +462,7 @@ fn histogram_lut(source_histc: &[u32; 256], target_histc: &[u32; 256]) -> [usize lut } +#[cfg(not(miri))] #[cfg(test)] mod tests { use super::*; diff --git a/src/drawing/text.rs b/src/drawing/text.rs index 13319afb..28eddf04 100644 --- a/src/drawing/text.rs +++ b/src/drawing/text.rs @@ -88,6 +88,8 @@ pub fn draw_text_mut( let image_width = canvas.width() as i32; let image_height = canvas.height() as i32; + let has_alpha = matches!(C::Pixel::COLOR_MODEL, "RGBA" | "YA"); + layout_glyphs(scale, font, text, |g, bb| { let x_shift = x + bb.min.x.round() as i32; let y_shift = y + bb.min.y.round() as i32; @@ -98,10 +100,19 @@ pub fn draw_text_mut( if (0..image_width).contains(&image_x) && (0..image_height).contains(&image_y) { let image_x = image_x as u32; let image_y = image_y as u32; - let pixel = canvas.get_pixel(image_x, image_y); + let mut pixel = canvas.get_pixel(image_x, image_y); let gv = gv.clamp(0.0, 1.0); - let weighted_color = weighted_sum(pixel, color, 1.0 - gv, gv); - canvas.draw_pixel(image_x, image_y, weighted_color); + + if has_alpha { + let mut color = color; + color.apply_with_alpha(|f| f, |g| Clamp::clamp(g.into() * gv)); + + pixel.blend(&color); + } else { + pixel = weighted_sum(pixel, color, 1.0 - gv, gv); + } + + canvas.draw_pixel(image_x, image_y, pixel); } }) }); diff --git a/src/template_matching.rs b/src/template_matching.rs index e51a2fb6..a9476289 100644 --- a/src/template_matching.rs +++ b/src/template_matching.rs @@ -392,7 +392,7 @@ mod methods { } fn square_sum(input: &GrayImage) -> f32 { - input.iter().map(|&x| (x as f32 * x as f32)).sum() + input.iter().map(|&x| x as f32 * x as f32).sum() } fn mult_square_sum(a: &GrayImage, b: &GrayImage) -> f32 { a.iter()