示例#1
0
    public static Pixbuf Render(Pixbuf refImage, OpenCV cv, Color color, int selected, Color selectedColor, bool filled = false, bool enabled = true, double ScaleX = 1.0, double ScaleY = 1.0)
    {
        if (Selection.EllipseMode)
        {
            if (Selection.Ellipses.Count > 0)
            {
                return(cv.DrawEllipse(refImage, Selection.Ellipses, MarkerSize, color, selected, selectedColor, filled, enabled, ScaleX, ScaleY));
            }
        }
        else
        {
            if (Selection.Boxes.Count > 0)
            {
                return(cv.DrawBox(refImage, Selection.Boxes, MarkerSize, color, selected, selectedColor, filled, enabled, ScaleX, ScaleY));
            }
        }

        return(refImage.Copy());
    }
示例#2
0
    public static void Update()
    {
        var BG = (Invert ? (255 - BackgroundLevel) : BackgroundLevel);
        var FG = (Invert ? (255 - GrayLevel) : GrayLevel);

        Pixbuf.Fill(((uint)BG << 24) | ((uint)BG << 16) | ((uint)BG << 8) | 255);

        using (OpenCV opencv = new OpenCV())
        {
            var patternColor = new Color((byte)FG, (byte)FG, (byte)FG);

            if (Custom)
            {
                Copy(CustomPixbuf);
            }

            if (Cross || Plus)
            {
                using (Pixbuf pattern = opencv.DrawCrossPlus(Pixbuf, Cross, Plus, MarkerSize, patternColor))
                {
                    Render(pattern);
                }
            }

            if (Grating)
            {
                using (Pixbuf pattern = opencv.DrawGrating(Pixbuf, PeriodX, PeriodY, FillX, FillY, TL, TR, BL, BR, patternColor))
                {
                    Render(pattern);
                }
            }

            double AspectRatio = System.Convert.ToDouble(AspectX / AspectY);

            if (Ring)
            {
                using (Pixbuf pattern = opencv.DrawRing(Pixbuf, RingDiameter, AspectRatio, MarkerSize, patternColor, FillRing, Rings, RingPeriod * MarkerSize))
                {
                    Render(pattern);
                }
            }

            if (Box)
            {
                using (Pixbuf pattern = opencv.DrawBox(Pixbuf, BoxWidth, AspectRatio, MarkerSize, patternColor, FillBox, Boxes, BoxPeriod * MarkerSize))
                {
                    Render(pattern);
                }
            }

            if (!Preview)
            {
                using (Pixbuf pattern = GtkSelection.Render(Pixbuf, opencv, patternColor, 0, patternColor, true, false))
                {
                    Render(pattern);
                }
            }

            if (FlipX)
            {
                using (Pixbuf pattern = opencv.Flip(Pixbuf, opencv.FlipX))
                {
                    Copy(pattern);
                }
            }

            if (FlipY)
            {
                using (Pixbuf pattern = opencv.Flip(Pixbuf, opencv.FlipY))
                {
                    Copy(pattern);
                }
            }
        }
    }