Pinta.Core.Document.GetSelectedBounds C# (CSharp) Method

GetSelectedBounds() public method

public GetSelectedBounds ( bool canvasOnly ) : Gdk.Rectangle
canvasOnly bool false for the whole selection, true for the part only on our canvas
return Gdk.Rectangle
        public Gdk.Rectangle GetSelectedBounds(bool canvasOnly)
        {
            var bounds = Selection.SelectionPath.GetBounds();

            if (canvasOnly)
                bounds = ClampToImageSize (bounds);

            return bounds;
        }

Usage Example

Example #1
0
        private void HandlerPintaCoreActionsEditCopyActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (PintaCore.Tools.CurrentTool?.DoHandleCopy(doc, cb) == true)
            {
                return;
            }

            PintaCore.Tools.Commit();

            using (ImageSurface src = doc.Layers.GetClippedLayer(doc.Layers.CurrentUserLayerIndex)) {
                Gdk.Rectangle rect = doc.GetSelectedBounds(true);
                if (rect.Width == 0 || rect.Height == 0)
                {
                    return;
                }

                ImageSurface dest = CairoExtensions.CreateImageSurface(Format.Argb32, rect.Width, rect.Height);

                using (Context g = new Context(dest)) {
                    g.SetSourceSurface(src, -rect.X, -rect.Y);
                    g.Paint();
                }

                cb.Image = dest.ToPixbuf();

                (dest as IDisposable).Dispose();
            }
        }
All Usage Examples Of Pinta.Core.Document::GetSelectedBounds