xwdtopnm reads an X11 or X10 window dump file as input and produces a PNM image as output. The type of the output image depends on the input file - if it's black and white, the output is PBM. If it's grayscale, the output is PGM. Otherwise, it's PPM. The program tells you which type it is writing.
Using this program, you can convert anything you can display on an X workstation's screen into a PNM image. Just display whatever you're interested in, run the xwd program to capture the contents of the window, run it through xwdtopnm, and then use pamcut to select the part you want.