From 09665b139f10afb5e2f68f153d56b828b3dcffc3 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Sun, 16 May 2021 15:17:40 +0200 Subject: [PATCH] Monitor: Clip zone polygon to image size when dumping The polygon vertex coordinated of extra_zone are directly parsed from user input. Clip the resulting polygon to the image size so we don't try to draw outside of the image. This is already done for zone polygons stored and loaded from the DB. --- src/zm_monitor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 56cbf868a..36d04bbec 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1481,6 +1481,10 @@ void Monitor::DumpZoneImage(const char *zone_string) { zone_image->Colourise(ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB); } + extra_zone = extra_zone.GetClipped(Box({0, 0}, + {static_cast(zone_image->Width()), + static_cast(zone_image->Height())})); + for (const Zone &zone : zones) { if (exclude_id && (!extra_colour || !extra_zone.GetVertices().empty()) && zone.Id() == exclude_id) { continue;