Image Watch

Image Watch is a Visual Studio debugger Watch window for viewing in-memory bitmaps when debugging native C++ code.

Install Image Watch Extension

Image Watch is supported in the most recent versions of Visual Studio. To install:

  1. Select Extensions > Manage Extensions in Visual Studio, or go to the Visual Studio Marketplace.

  2. Search for Image Watch, and choose the Extension that most closely matches your version of Visual Studio.

Inspect an image

To bring up Image Watch for the first time: break in the debugger and select View > Other Windows > Image Watch. Note that you only need to do this once: just like Visual Studio’s built-in Watch window, Image Watch will disappear when you stop debugging, and automatically reopen next time you start debugging.

Image Watch acts as both Locals and Watch window together. A radio button at the top left (Figure 1, A) switches between the two modes, which work just like Visual Studio’s built-in Locals and Watch windows: in Locals mode, the Image List (Figure 1, B) gets automatically populated with all image-valued variables that are on the current stack frame. In Watch mode, image items are added manually by the user, for example, by typing in image-valued expressions.

FIGURE 1:

Screenshot of Image Watch while debugging.

Every listed image (Figure 1, C) has a square icon denoting whether the image expression is valid (blue) or invalid (gray). For valid expressions, additional information is shown: a thumbnail, the image size (width x height in pixels), the pixel format (“number of channels x channel data type [optional format string]”), and the expression’s C++ type. Image Watch supports these C/C++ Types and these Pixel Formats.

One image at a time can be selected (Figure 1, D) for viewing in the Image Viewer to the right (Figure 1, E). The Image Viewer supports panning (mouse drag) and zooming (mouse wheel). The current magnification factor is shown on the upper right (Figure 1, F). Pixel coordinates at the current mouse position (Figure 1, G) and the corresponding pixel value are displayed at the top (Figure 1, H). In addition, pixels values are displayed directly on the pixels at sufficiently high zoom levels.

Image Watch introduces a magnifying glass symbol next to image-valued expressions in Visual Studio’s built-in Autos, Locals, and Watch window (Figure 1, I), and also in the code editor’s debugger tooltip (Figure 1, J). Clicking on the magnifying glass adds the expression to Image Watch’s Watch list.

See also