问题
Here are the application steps
- copy some richtext from a html email message or from a website(a combination of text + image)
- In your java code retrieve the content copied from the clipboard object as BufferredImage
- Save the retrieved image object as image file on disk
You'll notice that in the saved file, the image comes fine, any non-black text appears fine but black text seems lost in the black background. Could not find a way to override the black background for the generated image. Some example code below.
BufferedImage image = null;
try {
image = (BufferedImage) transferable.getTransferData(DataFlavor.imageFlavor);
} catch (UnsupportedFlavorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
saveImageToDisk(image);
private void saveImageToDisk(BufferedImage image) {
File outputFile = new File("c:\\image.png");
try {
ImageIO.write(image, "png", outputFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Found the solution - it is to use a custom system flavour which understands the mimetype of 'image\x-emf'. strip first 8 bytes and write the remaining content as Bufferred image
回答1:
Found the solution - it is to use a custom system flavour which understands the mimetype of 'image\x-emf'. strip first 8 bytes and write the remaining content as Bufferred image
来源:https://stackoverflow.com/questions/15977001/clipboard-copy-from-outlook-always-has-black-background-set-when-retrieved-as-im