From 9089794d4622e47bfec09d8aa486b974ee1ce252 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Fri, 23 Jun 2023 14:29:49 +0200 Subject: [PATCH] ROIFilter: Fix --- common/ROIFilter.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/ROIFilter.h b/common/ROIFilter.h index 339755c3..be96f0c5 100644 --- a/common/ROIFilter.h +++ b/common/ROIFilter.h @@ -25,13 +25,13 @@ public: if (in_width <= 0) return; if (x0 >= width) return; - if (x0 + in_width >= width) in_width = width - 1 - x0; + if (x0 + in_width >= width) in_width = width - x0; if (y0 < 0) { in_height += y0; y0 = 0; } if (in_height <= 0) return; if (y0 >= height) return; - if (y0 + in_height >= height) in_height = height - 1 - y0; + if (y0 + in_height >= height) in_height = height - y0; for (size_t y = y0; y < y0 + in_height; y++) { for (size_t x = x0; x < x0 + in_width; x++) { @@ -45,11 +45,14 @@ public: if (in_width <= 0) return; if (x0 >= width) return; - if (x0 + in_width >= width) in_width = width - 1 - x0; + if (x0 + in_width >= width) in_width = width - x0; if (y0 < 0) { in_height += y0; y0 = 0; } if (in_height <= 0) return; + if (y0 >= height) return; + if (y0 + in_height >= height) in_height = height - y0; + for (size_t y = y0; y < y0 + in_height; y++) { for (size_t x = x0; x < x0 + in_width; x++) { mask[y * width + x] &= ~mask_value;