How do I store a BufferedImage into the system clipboard?
Jigar's code does indeed store a BufferedImage into the clipboard, although to be specific, it puts a screen-capture of the entire screen into the clipboard.
This may or may not be what you were after. In case you wanted to copy your own specific BufferedImage, in order to accomplish this, I replaced the constructor from Jigar's example with a copyImage() method.
public class CopyImagetoClipBoard implements ClipboardOwner
{
public void copyImage(BufferedImage bi)
{
TransferableImage trans = new TransferableImage( bi );
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
c.setContents( trans, this );
}
Remove the main() method within his class too.
You can then copy your BufferedImage with code such as this:
BufferedImage bim;
// set bim to your desired BufferedImage content
// ...
CopyImagetoClipBoard ci = new CopyImagetoClipBoard();
ci.copyImage(bim);