1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

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
This commit is contained in:
Ghazi-raad
2025-11-26 21:41:28 +00:00
parent 4da9a518ef
commit a27a13921b
+1 -1
View File
@@ -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;