MCPcopy Create free account
hub / github.com/creatale/node-dv / Line2

Function Line2

deps/opencv/modules/core/src/drawing.cpp:638–829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

636
637
638static void
639Line2( Mat& img, Point2l pt1, Point2l pt2, const void* color)
640{
641 int64 dx, dy;
642 int ecount;
643 int64 ax, ay;
644 int64 i, j;
645 int x, y;
646 int64 x_step, y_step;
647 int cb = ((uchar*)color)[0];
648 int cg = ((uchar*)color)[1];
649 int cr = ((uchar*)color)[2];
650 int pix_size = (int)img.elemSize();
651 uchar *ptr = img.data, *tptr;
652 size_t step = img.step;
653 Size size = img.size();
654
655 //assert( img && (nch == 1 || nch == 3) && img.depth() == CV_8U );
656
657 Size2l sizeScaled(((int64)size.width) << XY_SHIFT, ((int64)size.height) << XY_SHIFT);
658 if( !clipLine( sizeScaled, pt1, pt2 ))
659 return;
660
661 dx = pt2.x - pt1.x;
662 dy = pt2.y - pt1.y;
663
664 j = dx < 0 ? -1 : 0;
665 ax = (dx ^ j) - j;
666 i = dy < 0 ? -1 : 0;
667 ay = (dy ^ i) - i;
668
669 if( ax > ay )
670 {
671 dx = ax;
672 dy = (dy ^ j) - j;
673 pt1.x ^= pt2.x & j;
674 pt2.x ^= pt1.x & j;
675 pt1.x ^= pt2.x & j;
676 pt1.y ^= pt2.y & j;
677 pt2.y ^= pt1.y & j;
678 pt1.y ^= pt2.y & j;
679
680 x_step = XY_ONE;
681 y_step = (dy << XY_SHIFT) / (ax | 1);
682 ecount = (int)((pt2.x - pt1.x) >> XY_SHIFT);
683 }
684 else
685 {
686 dy = ay;
687 dx = (dx ^ i) - i;
688 pt1.x ^= pt2.x & i;
689 pt2.x ^= pt1.x & i;
690 pt1.x ^= pt2.x & i;
691 pt1.y ^= pt2.y & i;
692 pt2.y ^= pt1.y & i;
693 pt1.y ^= pt2.y & i;
694
695 x_step = (dx << XY_SHIFT) / (ay | 1);

Callers 2

FillConvexPolyFunction · 0.85
ThickLineFunction · 0.85

Calls 3

clipLineFunction · 0.85
elemSizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected