From a27a13921b6a47780bde064e931b38d969fc18de Mon Sep 17 00:00:00 2001 From: Ghazi-raad Date: Wed, 26 Nov 2025 21:41:28 +0000 Subject: [PATCH] Fix LINE_4/LINE_8 swap in drawContours (issue #26413) Changed condition to correctly route LINE_8 to Line() instead of Line2(). The condition 'line_type == 1 || line_type == 4' was causing LINE_8 (value 8) to be processed by Line2() which implements 4-connectivity, and LINE_4 (value 4) to be processed by Line() which was implementing 8-connectivity behavior. This resulted in swapped line connectivity. Changed to 'line_type == 1 || line_type == 8' so LINE_8 goes to Line() with 8-connectivity and LINE_4 goes to Line2() with 4-connectivity, matching the documented behavior where LINE_4 should produce 4-connected lines and LINE_8 should produce 8-connected lines. Fixes #26413 --- modules/imgproc/src/drawing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgproc/src/drawing.cpp b/modules/imgproc/src/drawing.cpp index 8214b17013..fcac9ff303 100644 --- a/modules/imgproc/src/drawing.cpp +++ b/modules/imgproc/src/drawing.cpp @@ -1667,7 +1667,7 @@ ThickLine( Mat& img, Point2l p0, Point2l p1, const void* color, { if( line_type < cv::LINE_AA ) { - if( line_type == 1 || line_type == 4 || shift == 0 ) + if( line_type == 1 || line_type == 8 || shift == 0 ) { p0.x = (p0.x + (XY_ONE>>1)) >> XY_SHIFT; p0.y = (p0.y + (XY_ONE>>1)) >> XY_SHIFT;