コード例 #1
0
    protected void DrawBoxes()
    {
        if (!Paused)
        {
            return;
        }

        if (GtkSelection.Selection.Count() > 0)
        {
            var dest  = worldImage.GdkWindow;
            var gc    = new Gdk.GC(dest);
            var boxes = GtkSelection.Selection.BoundingBoxes();

            for (int i = 0; i < boxes.Count; i++)
            {
                if (i == GtkSelection.Selected - 1 || ShowColonies.Active)
                {
                    var box = boxes[i];

                    var w = Math.Abs(box.X1 - box.X0);
                    var h = Math.Abs(box.Y1 - box.Y0);

                    gc.RgbFgColor = i != GtkSelection.Selected - 1 ? GtkSelection.SelectedColor : Colonies[i].ArtificialLife.ColonyColor;
                    gc.SetLineAttributes(GtkSelection.MarkerSize, LineStyle.Solid, CapStyle.Round, JoinStyle.Round);

                    GtkSelection.DrawBox(gc, dest, box.X0, box.Y0, box.X1, box.Y1, w, h, false);
                }
            }
        }
    }
コード例 #2
0
    protected void RenderImage()
    {
        if (OriginalImage != null)
        {
            using (Pixbuf pb = GtkSelection.Render(OriginalImage.ScaleSimple(imageBox.WidthRequest, imageBox.HeightRequest, InterpType.Bilinear), cv, markerColor.Color, GtkSelection.Selected, GtkSelection.SelectedColor, false, true))
            {
                Scale(pb, imageBox.Pixbuf);
            }
        }

        CollectGarbage();
    }
コード例 #3
0
ファイル: MainWindow.cs プロジェクト: daelsepara/CameraApp
    protected void RenderImage()
    {
        if (OriginalImage != null)
        {
            using (Pixbuf pb = GtkSelection.Render(OriginalImage.ScaleSimple(cameraImage.WidthRequest, cameraImage.HeightRequest, InterpType.Bilinear), opencv, GtkSelection.MarkerColor, GtkSelection.Selected, GtkSelection.SelectedColor, false, true))
            {
                if (cameraImage.Pixbuf != null && pb != null)
                {
                    pb.CopyArea(0, 0, cameraImage.Pixbuf.Width, cameraImage.Pixbuf.Height, cameraImage.Pixbuf, 0, 0);
                }
            }
        }

        CollectGarbage();
    }
コード例 #4
0
    void Redraw(Gtk.Image background)
    {
        if (background == null)
        {
            return;
        }

        var dest = background.GdkWindow;
        var gc   = new Gdk.GC(dest);

        dest.DrawPixbuf(gc, background.Pixbuf, 0, 0, 0, 0, background.WidthRequest, background.HeightRequest, RgbDither.None, 0, 0);

        if (IsSelecting)
        {
            GtkSelection.Draw(gc, dest, X0, Y0, X1, Y1);
        }
    }
コード例 #5
0
ファイル: MainWindow.cs プロジェクト: daelsepara/CameraApp
    protected void OnSaveProcessedImageButtonClicked(object o, EventArgs e)
    {
        if (ControlsActive)
        {
            if (GtkSelection.Selection.Count() > 0)
            {
                ImageSaver.Title = "Save Processed Image";

                if (!string.IsNullOrEmpty(ImageSaver.Filename))
                {
                    var directory = System.IO.Path.GetDirectoryName(ImageSaver.Filename);

                    if (Directory.Exists(directory))
                    {
                        ImageSaver.SetCurrentFolder(directory);
                    }
                }

                if (ImageSaver.Run() == Convert.ToInt32(ResponseType.Accept))
                {
                    if (!string.IsNullOrEmpty(ImageSaver.Filename))
                    {
                        var FileName = ImageSaver.Filename;

                        if (!FileName.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
                        {
                            FileName += ".png";
                        }

                        var ScaleX = Convert.ToDouble(OriginalImage.Width) / cameraImage.WidthRequest;
                        var ScaleY = Convert.ToDouble(OriginalImage.Height) / cameraImage.HeightRequest;

                        using (Pixbuf pb = GtkSelection.Render(OriginalImage, opencv, GtkSelection.MarkerColor, GtkSelection.Selected, GtkSelection.SelectedColor, false, true, ScaleX, ScaleY))
                        {
                            if (cameraImage.Pixbuf != null && pb != null)
                            {
                                pb.Save(FileName, "png");
                            }
                        }
                    }
                }

                ImageSaver.Hide();
            }
        }
    }
コード例 #6
0
    void DrawSelection()
    {
        if (Paused)
        {
            if (worldPixbuf == null)
            {
                return;
            }

            var dest = worldImage.GdkWindow;
            var gc   = new Gdk.GC(dest);

            dest.DrawPixbuf(gc, worldPixbuf, 0, 0, 0, 0, worldPixbuf.Width, worldPixbuf.Height, RgbDither.None, 0, 0);

            if (IsSelecting)
            {
                GtkSelection.Draw(gc, dest, X0, Y0, X1, Y1);
            }
        }
    }
コード例 #7
0
ファイル: Pattern.cs プロジェクト: daelsepara/CameraApp
    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);
                }
            }
        }
    }