I have this code to get an image from the clipboard when pressing imprt. but it returns Image how do I convert it to PImage?
public Image getImageFromClipboard( )
{
Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.imageFlavor))
{
try
{
return ((Image) ( transferable.getTransferData(DataFlavor.imageFlavor)));
}
catch (UnsupportedFlavorException e)
{
// handle this as desired
e.printStackTrace();
}
catch (IOException e)
{
// handle this as desired
e.printStackTrace();
}
}
else
{
System.err.println("getImageFromClipboard: That wasn't an image!");
}
return null;
}