craft-develop: a cancelled inpaint with an impossible patch radius is still cancelled

This commit is contained in:
texjer
2026-11-18 16:09:33 -05:00
parent 440235aadf
commit bf655268d7
2 changed files with 4 additions and 0 deletions
+3
View File
@@ -57,6 +57,9 @@ mod tests {
let p = CompleteParams { patch_radius, ..CompleteParams::default() };
assert_eq!(complete(32, 32, 1, &[0.5; 32 * 32], &hole, &p), None, "radius {patch_radius}");
}
// Cancelled is still cancelled, not "nothing to copy from".
let p = CompleteParams { patch_radius: 16, ..CompleteParams::default() };
assert_eq!(complete_with(32, 32, 1, &[0.5; 32 * 32], &hole, &p, &|| true), Err(Cancelled));
// A radius the image has room for still fills.
let p = CompleteParams { patch_radius: 5, ..CompleteParams::default() };
assert!(complete(32, 32, 1, &[0.5; 32 * 32], &hole, &p).is_some());
+1
View File
@@ -401,6 +401,7 @@ pub fn complete_with(
// A patch wider than the image has no place to be copied from, which is the `None` the search below
// would reach anyway. Said here, before `2 * r + 1` and `r as i32` can overflow on an absurd radius.
if r > (w.min(h) - 1) / 2 {
check()?;
return Ok(None);
}
let psz = 2 * r + 1;