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); } } } }
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(); }
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(); }
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); } }
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(); } } }
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); } } }
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); } } } }