mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 15:44:29 +00:00
craft-develop: a cancelled inpaint with an impossible patch radius is still cancelled
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user