protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, PointD point) { Point pos = new Point ((int)point.X, (int)point.Y); // Don't do anything if we're outside the canvas if (pos.X < 0 || pos.X >= PintaCore.Workspace.ImageSize.X) return; if (pos.Y < 0 || pos.Y >= PintaCore.Workspace.ImageSize.Y) return; base.OnMouseDown (canvas, args, point); ImageSurface surface = PintaCore.Layers.CurrentLayer.Surface; ImageSurface stencil_surface = new ImageSurface (Format.Argb32, (int)surface.Width, (int)surface.Height); IBitVector2D stencilBuffer = new BitVector2DSurfaceAdapter (stencil_surface); int tol = (int)(Tolerance * Tolerance * 256); Rectangle boundingBox; if (IsContinguousMode) FillStencilFromPoint (surface, stencilBuffer, pos, tol, out boundingBox); else FillStencilByColor (surface, stencilBuffer, surface.GetColorBgra (pos.X, pos.Y), tol, out boundingBox); stencil = stencilBuffer; OnFillRegionComputed (null); }
protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, PointD point) { Point pos = new Point ((int)point.X, (int)point.Y); // Don't do anything if we're outside the canvas if (pos.X < 0 || pos.X >= PintaCore.Workspace.ImageSize.Width) return; if (pos.Y < 0 || pos.Y >= PintaCore.Workspace.ImageSize.Height) return; base.OnMouseDown (canvas, args, point); Gdk.Region currentRegion = Gdk.Region.Rectangle(PintaCore.Layers.SelectionPath.GetBounds()); // See if the mouse click is valid if (!currentRegion.PointIn (pos.X, pos.Y) && limitToSelection) { currentRegion.Dispose (); currentRegion = null; return; } ImageSurface surface = PintaCore.Layers.CurrentLayer.Surface; ImageSurface stencil_surface = new ImageSurface (Format.Argb32, (int)surface.Width, (int)surface.Height); IBitVector2D stencilBuffer = new BitVector2DSurfaceAdapter (stencil_surface); int tol = (int)(Tolerance * Tolerance * 256); Rectangle boundingBox; surface.Flush (); if (IsContinguousMode) FillStencilFromPoint (surface, stencilBuffer, pos, tol, out boundingBox, currentRegion, limitToSelection); else FillStencilByColor (surface, stencilBuffer, surface.GetColorBgra (pos.X, pos.Y), tol, out boundingBox, currentRegion, LimitToSelection); surface.MarkDirty (); stencil = stencilBuffer; Point[][] polygonSet = stencilBuffer.CreatePolygonSet (boundingBox, 0, 0); OnFillRegionComputed (polygonSet); }
protected override void OnMouseDown (Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, PointD point) { Document doc = PintaCore.Workspace.ActiveDocument; Point pos = new Point ((int)point.X, (int)point.Y); // Don't do anything if we're outside the canvas if (pos.X < 0 || pos.X >= doc.ImageSize.Width) return; if (pos.Y < 0 || pos.Y >= doc.ImageSize.Height) return; base.OnMouseDown (canvas, args, point); Gdk.Region currentRegion = Gdk.Region.Rectangle (doc.GetSelectedBounds (true)); // See if the mouse click is valid if (!currentRegion.PointIn (pos.X, pos.Y) && limitToSelection) { currentRegion.Dispose (); currentRegion = null; return; } ImageSurface surface = doc.CurrentUserLayer.Surface; using (var stencil_surface = new ImageSurface (Format.Argb32, (int)surface.Width, (int)surface.Height)) { IBitVector2D stencilBuffer = new BitVector2DSurfaceAdapter (stencil_surface); int tol = (int)(Tolerance * Tolerance * 256); Rectangle boundingBox; if (IsContinguousMode) FillStencilFromPoint (surface, stencilBuffer, pos, tol, out boundingBox, currentRegion, limitToSelection); else FillStencilByColor (surface, stencilBuffer, surface.GetColorBgraUnchecked (pos.X, pos.Y), tol, out boundingBox, currentRegion, LimitToSelection); OnFillRegionComputed (stencilBuffer); // If a derived tool is only going to use the stencil, // don't waste time building the polygon set if (CalculatePolygonSet) { Point[][] polygonSet = stencilBuffer.CreatePolygonSet (boundingBox, 0, 0); OnFillRegionComputed (polygonSet); } } }