MCPcopy Create free account
hub / github.com/KAlO2/PerfectShow / DrawShape

Function DrawShape

jni/stasm/misc.cpp:607–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605}
606
607void DrawShape( // draw a shape on an image
608 CImage& img, // io
609 const Shape& shape, // in
610 unsigned color, // in: rrggbb, default is 0xff0000 (red)
611 bool dots, // in: true for dots only, default is false
612 int linewidth) // in: default -1 means automatic
613{
614 const double width = ShapeWidth(shape);
615 if (linewidth <= 0)
616 linewidth = width > 700? 3: width > 300? 2: 1;
617 CvScalar cvcolor(ToCvColor(color));
618 int i = 0, j=0;
619 do // use do and not for loop because some points may be unused
620 {
621 while (i < shape.rows && !PointUsed(shape, i)) // skip unused points
622 i++;
623 if (i < shape.rows)
624 {
625 if (dots)
626 {
627 const int ix = cvRound(shape(i, IX)), iy = cvRound(shape(i, IY));
628 if (ix >= 0 && ix < img.cols && iy >= 0 && iy < img.rows)
629 {
630 img(iy, ix)[0] = (color >> 0) & 0xff;
631 img(iy, ix)[1] = (color >> 8) & 0xff;
632 img(iy, ix)[2] = (color >> 16) & 0xff;
633 }
634 }
635 else // lines
636 {
637 j = i+1;
638 while (j < shape.rows && !PointUsed(shape, j))
639 j++;
640 if (j < shape.rows)
641 cv::line(img,
642 cv::Point(cvRound(shape(i, IX)), cvRound(shape(i, IY))),
643 cv::Point(cvRound(shape(j, IX)), cvRound(shape(j, IY))),
644 cvcolor, linewidth);
645 }
646 }
647 i++;
648 }
649 while (i < shape.rows && j < shape.rows);
650}
651
652void ImgPrintf( // printf on image
653 CImage& img, // io

Callers 2

stasm_search_auto_extFunction · 0.85
TraceShapeFunction · 0.85

Calls 4

ShapeWidthFunction · 0.85
ToCvColorFunction · 0.85
PointUsedFunction · 0.85
lineFunction · 0.85

Tested by

no test coverage detected