【问题标题】:How to capture the contents of graphics as an image [duplicate]如何将图形的内容捕获为图像[重复]
【发布时间】:2014-06-25 12:50:53
【问题描述】:

我有一个透明的 jframe,上面有滚动文本,我只需要捕获 jframe 而不是它后面的内容。起初,java.awt.Robot 看起来很有希望,但它并不仅仅捕获 jframe 的图形上下文。也许有人知道 API 的一部分可以帮助解决这个问题......

【问题讨论】:

    标签: java swing video-capture


    【解决方案1】:

    你可以

    1. 使用 JFrame 的大小创建一个 BufferedImage
    2. 使用 BufferedImage 的图形调用 JFrame 的 print() 方法

    代码:

    BufferedImage image = new BufferedImage(frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_INT_RGB);
    frame.print(image.getGraphics());
    

    【讨论】:

    • 包含代码;请考虑接受
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-11
    • 2014-12-13
    • 2013-07-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多