Leroy42 hat gesagt.:Google mal nach "How to use Clipboard"
BufferedImage image = (BufferedImage) getClipboard();
try {
ImageIO.write(image,"jpg", new File("c:\\test123.jpg"));
} catch (IOException ex) {
ex.printStackTrace();
}
André Uhres hat gesagt.:http://javaalmanac.com/egs/java.awt.datatransfer/ToClipImg.html
Code:BufferedImage image = (BufferedImage) getClipboard(); try { ImageIO.write(image,"jpg", new File("c:\\test123.jpg")); } catch (IOException ex) { ex.printStackTrace(); }
public static Image getClipboard() {
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard()
.getContents(null);
try {
if (t != null && t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
Image text = (Image) t.getTransferData(DataFlavor.imageFlavor);
return text;
}
} catch (UnsupportedFlavorException e) {
} catch (IOException e) {
}
return null;
}
Image image = new ImageIcon("ottosHaus.jpg").getImage(),
int percent = 175;
Image scaled1 = image.getScaledInstance(
(image.getWidth() * percent) / 100,
(image.getHeight() * percent) / 100,
Image.SCALE_SMOOTH );
Image scaled2 = image.getScaledInstance(
Toolkit.getDefaultToolkit().getScreenSize().width,
Toolkit.getDefaultToolkit().getScreenSize().height,
Image.SCALE_SMOOTH );
Image scaled1 = getClipboard().getScaledInstance(100,100,Image.SCALE_SMOOTH );
Fehlermeldung ?jobu0101 hat gesagt.:Wenn ich nur dieses einfach Beispiel ausprobiere, hängt er sich schon auf!Code:Image scaled1 = getClipboard().getScaledInstance(100,100,Image.SCALE_SMOOTH );
BufferedImage bufferedImage = new BufferedImage(100,100,BufferedImage.TYPE_INT_RGB);
Graphics2D bufImageGraphics = bufferedImage.createGraphics();
bufImageGraphics.drawImage(scaled1, 0, 0, null);