2

Like the title says, I want to take a screenshot of a window application running under wine. Not the entire desktop. C would be preferred but could also use java or Pascal.

Thanks in advance

3 Answers3

3

Use imagemagick's import command to grab the window and dump it to a file...

import documentation

Wrap the call in a C system command

 system("import -window (your window name) capture.png").

Then you can access the image from the file using any of the standard image loading libraries.

justinhj
  • 11,147
  • 11
  • 58
  • 104
3

A possible way with the Linux shell:

  • use xwininfo to find the window id we're looking for
  • use import to dump a screenshot
  • (read man import and man xwininfo for more information)

Example with wine:

import -window `xwininfo -root -children | grep "Wine" | awk '{print $1}'` outfile.pcx
ChristopheD
  • 112,638
  • 29
  • 165
  • 179
1

You could duplicate the functionality of ImageMagick's import command using MagickWand (C API) or Magick++ (C++ API), but calling import directly via system() as suggested by justinhj is likely the simplest approach if you don't mind distributing import with your software.

Sparr
  • 7,489
  • 31
  • 48