gpt4 book ai didi

java - 从 JFrame 录制视频

转载 作者:太空宇宙 更新时间:2023-11-04 12:45:00 25 4
gpt4 key购买 nike

我有一个 JFrame 应用程序,可以生成长时间运行的输出。我想知道我是否可以录制该内容并生成高帧速率的视频或帧/图像,以便稍后将它们转换为视频?

最佳答案

您可以像这样生成 JFrame 内容的图像:

public static void main(String[] a) throws Exception {

final JFrame frame = new JFrame("My Frame");
frame.getContentPane().setBackground(Color.CYAN);
frame.setSize(400, 400);
frame.setVisible(true);

final BufferedImage image = new BufferedImage(frame.getWidth(),
frame.getHeight(), BufferedImage.TYPE_INT_ARGB);
frame.paint(image.getGraphics());
File outputfile = new File("C:/Temp/frame.png");
ImageIO.write(image, "png", outputfile);
}

然后使用任何可用的软件转换器来构建视频。

关于java - 从 JFrame 录制视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36422170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com