在IntelliJ中调试时是否可以观看BufferedImage对象? [英] Is it possible to watch BufferedImage objects while debugging in IntelliJ?

查看:96
本文介绍了在IntelliJ中调试时是否可以观看BufferedImage对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IntelliJ中调试时是否可以观看BufferedImage对象?

我的意思是查看图像的视觉内容,而不是查看内存标识.

是否还可以可视化查看自定义对象,即编写一些自定义可视化工具?

解决方案

IntelliJ IDEA 2016.1.1可以在调试时默认将 BufferedImage 对象显示为图像(可能以前的版本也支持此功能)

  1. 设置一个断点,您可以在其中访问 BufferedImage 对象
  2. 默认情况下,对于 BufferedImage 类,Idea会设置 Image 查看器,因此您只需单击以下行中的 View image 文本即可调试器窗口右侧的 BufferedImage 对象.这在 Evaluate Expression 窗口中也可用.
  3. 如果为 BufferedImage 类设置了另一个查看器,则可以通过在调试器窗口中右键单击 BufferedImage 对象,将其更改回去,然后选择查看为/图像.

图像将被加载到弹出窗口中.(您可以调整弹出窗口的大小,但不能移动.我在OS X上,Idea的窗口处理有点奇怪,在Win上可能更好)


您还可以创建自己的对象可视化器.这也可以在查看为上下文菜单中完成,在这种情况下,请选择 Create ... 选项.您可以在此处输入自定义表达式,该表达式将显示在调试器窗口中对象的行中.请注意,这仅用于以文本格式显示对象的信息.

例如,如果要在调试器窗口中将 BufferedImage 显示为 [width] x [height] ,请创建一个新视图,选择表达式单选按钮,然后输入以下表达式:

  getWidth()+"x" + getHeight() 

点击应用确定后,您将获得:

您可以通过右键单击变量手表面板并选择自定义数据视图...

Is it possible to watch BufferedImage objects while debugging in IntelliJ?

I mean to view visual content of an image, not memory identity.

Is it also possible to view custom objects visually, i.e. write some custom visualizers?

解决方案

IntelliJ IDEA 2016.1.1 is able to display BufferedImage object as image while debugging by default (probabily previous versions also support this feature).

  1. Set up a breakpoint where you can access the BufferedImage object
  2. By default, for BufferedImage class Idea will set Image viewer, so you can simply click on the View image text in the row of the BufferedImage object in the debugger window, on the very right hand side. This is also available in the Evaluate Expression window.
  3. In case another viewer is set for the BufferedImage class, you can change it back by right clicking on the BufferedImage object in the debugger window, and select View as / Image.

The image will be loaded in a popup window. (You can resize the the popup, but cannot move. I'm on OS X, the window handling of Idea is a bit weird here, maybe better on Win)


You can also create your own object visualizers. This can also be done in the View as context menu, in this case choose the Create... option. There you can enter your custom expression, which will be displayed in the row of the object in the debugger window. Please note that this is for displaying information of the object in text format only.

For example if you want to display the BufferedImage as [width]x[height] in the debugger window, create a new view, select Use following expression radio button, and enter the following expression:

getWidth() + "x" + getHeight()

After clicking Apply or OK, you will get:

You can manage your viewers by right clicking in the Variables or Watches panel, and select Customize Data Views...

这篇关于在IntelliJ中调试时是否可以观看BufferedImage对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆