MCPcopy Create free account
hub / github.com/ImageOptim/libimagequant / liq_op3

Function liq_op3

src/blur.rs:37–58  ·  view source on GitHub ↗
(src: &[u8], dst: &mut [u8], width: usize, height: usize, op: impl Fn(u8, u8) -> u8)

Source from the content-addressed store, hash-verified

35}
36
37pub(crate) fn liq_op3(src: &[u8], dst: &mut [u8], width: usize, height: usize, op: impl Fn(u8, u8) -> u8) {
38 for j in 0..height {
39 let row = &src[j * width..][..width];
40 let dst = &mut dst[j * width..][..width];
41 let prevrow = &src[j.saturating_sub(1) * width..][..width];
42 let nextrow = &src[(j + 1).min(height - 1) * width..][..width];
43 let mut prev: u8;
44 let mut curr = row[0];
45 let mut next = row[0];
46 for i in 0..width - 1 {
47 prev = curr;
48 curr = next;
49 next = row[i + 1];
50 let t1 = op(prev, next);
51 let t2 = op(nextrow[i], prevrow[i]);
52 dst[i] = op(curr, op(t1, t2));
53 }
54 let t1 = op(curr, next);
55 let t2 = op(nextrow[width - 1], prevrow[width - 1]);
56 dst[width - 1] = op(curr, op(t1, t2));
57 }
58}
59
60/// Picks minimum of neighboring pixels (blur + darken)
61#[inline(never)]

Callers 2

liq_max3Function · 0.85
liq_min3Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected