Get image from print screen from clipboard

Is there any way to get the screen image from the keyboard. Say, for example, I had a website for posting images, and I need a feature in which users can insert an image and just post it that way. is it possible?

Sorry, this is such a vague question.

EDIT: Is it possible with some third-party plugin? Are there any existing Firefox plugins that do something similar?

+3
source share
5 answers

It looks like this will be possible in HTML 5 with an element Canvas. See this question.

Flash, Adobe Air. . .

+2

A Java- .

ClipboardService.

, , .

. , , ClipboardService, .

+2

, , Javascript Flash, . Flash, JavaScript . ( , , , , !)

0

, .

, , .

, CB, , , , .

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;

public class ImagefromCB
{
// If an image is on the system clipboard, this method returns it;
// otherwise it returns null.
public Image getImageFromClipboard()
{

    Clipboard systemClipboard = (Clipboard) AccessController.doPrivileged(new PrivilegedAction() {
        public Object run() 
        {
            Clipboard tempClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
         return tempClipboard;
        }
    });

    // get the contents on the clipboard in a 
    // Transferable object
    Transferable clipboardContents = systemClipboard.getContents(null);

    // check if contents are empty, if so, return null
    if (clipboardContents == null)
        return null;
    else
        try
        {
            // make sure content on clipboard is 
            // falls under a format supported by the 
            // imageFlavor Flavor
            if (clipboardContents.isDataFlavorSupported(DataFlavor.imageFlavor))
            {
                // convert the Transferable object
                // to an Image object
                Image image = (Image) clipboardContents.getTransferData(DataFlavor.imageFlavor);
                return image;
            }
        } catch (UnsupportedFlavorException ufe)
        {
            ufe.printStackTrace();
        } catch (IOException ioe)
        {
            ioe.printStackTrace();
        }
    return null;
}

public Image getCBImage()
{
    System.out.println("Copying image from system clipboard.");
    Image image = getImageFromClipboard();
    if (image != null)
    {
        return image;
    } else
    {
        System.out.println("No Image found on Clipboard");
        return null;
    }
}
}
0

The two products that do this are Jira and Youtrack . And using a Java applet. You can use these GUI products as inspiration when building your system. I especially like YouTracks Clipboard image without preview , where you do not need to interact directly with the applet.

0
source

All Articles