Пример #1
0
        /// <summary>
        /// Sets the dialog to use the clipboard image's dimensions, if possible.
        /// </summary>
        /// <returns>True if an image was on the clipboard, false otherwise.</returns>
        private static bool TryUseClipboardImageSize(NewImageDialog dialog)
        {
            bool clipboardUsed = false;

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable())
            {
                Gdk.Pixbuf image = cb.WaitForImage();
                if (image != null)
                {
                    clipboardUsed         = true;
                    dialog.NewImageWidth  = image.Width;
                    dialog.NewImageHeight = image.Height;
                    image.Dispose();
                }
            }

            cb.Dispose();

            return(clipboardUsed);
        }
Пример #2
0
        /// <summary>
        /// Gets the width and height of an image on the clipboard,
        /// if available.
        /// </summary>
        /// <param name="width">Destination for the image width.</param>
        /// <param name="height">Destination for the image height.</param>
        /// <returns>True if dimensions were available, false otherwise.</returns>
        private static bool GetClipboardImageSize(out int width, out int height)
        {
            bool clipboardUsed = false;

            width = height = 0;

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable())
            {
                Gdk.Pixbuf image = cb.WaitForImage();
                if (image != null)
                {
                    clipboardUsed = true;
                    width         = image.Width;
                    height        = image.Height;
                    image.Dispose();
                }
            }

            cb.Dispose();

            return(clipboardUsed);
        }