简体   繁体   English

从Java剪贴板对象作为图像检索时,Outlook的剪贴板副本始终设置为黑色背景

[英]Clipboard copy from outlook always has black background set when retrieved as image from Java clipboard object

Here are the application steps 这是申请步骤

  1. copy some richtext from a html email message or from a website(a combination of text + image) 从html电子邮件或网站中复制一些富文本(文本+图片的组合)
  2. In your java code retrieve the content copied from the clipboard object as BufferredImage 在您的Java代码中,检索从剪贴板对象复制的内容为BufferredImage
  3. 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'. 找到了解决方案-它是使用一种了解'image \\ x-emf'模仿类型的自定义系统风格。 strip first 8 bytes and write the remaining content as Bufferred image 剥离前8个字节并将剩余内容写为Bufferred映像

Found the solution - it is to use a custom system flavour which understands the mimetype of 'image\\x-emf'. 找到了解决方案-它是使用一种了解'image \\ x-emf'模仿类型的自定义系统风格。 strip first 8 bytes and write the remaining content as Bufferred image 剥离前8个字节并将剩余内容写为Bufferred映像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM