在控制台应用程序中显示图像?
我有一个控制台应用程序,它会在屏幕上抓取一些数据,现在我需要进行图像比较。如果图像不同,我想向用户显示图像。在控制台应用程序执行期间显示两个图像的最佳方式是什么?我假设我会使用某种进程间通信来来回发送信息,但我不确定我到底会如何以良好的方式做到这一点。
另外,如果可能的话,我宁愿不将图像存储到文件中。没有理由保留数据,如果控制台应用程序意外终止,最好不要在文件系统上留下任何污垢。
有谁对如何最好地实现这一目标有任何想法?
I have a console application which screen scrapes some data, and now I need to do image comparisons. If the images are different, I want to show the images to the user. What's the best way to display two images during the execution of a console application? I'm assuming I would use some sort of inter-process communication to send information back and forth, but I'm not sure how exactly I would go about doing that in a good fashion.
Also, I'd rather NOT store the images to files if possible. There's no reason to persist the data, and if the console application terminates unexpectedly, it's better if I don't have any dirt left on the file system.
Does anyone have any thoughts on how best to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定我是否理解这种担忧。您应该完全能够有条件地弹出 Swing
JFrame
或 AWTFrame< /code>
来自您的控制台应用程序,我错了吗?
I am not sure I understand the concern. You should be perfectly able to conditionally pop up either a Swing
JFrame
or AWTFrame
from your console application, am I wrong?您可以使用例如 BufferedImage 来构造图像,或 javax.imageio 中的实用程序 如果您的图像已经采用某种常见格式(例如 PNG、JPEG、BMP)。至于向用户显示,只需使用常规的 Java GUI 东西,Swing 或 AWT。如果控制台部分需要在显示图像时继续处理,请在单独的线程中运行 GUI。
使用图像教程可能包含一些有用的示例。
You can use e.g. BufferedImage to construct images, or the utilities in javax.imageio if your image is already in some common format (e.g. PNG, JPEG, BMP). As for displaying to the user, just use the regular Java GUI stuff, either Swing or AWT. Run the GUI in a separate thread if the console part needs to keep processing while the images are being displayed.
The Working with Images tutorial may contain some helpful examples.