7

How do I programatically take a screenshot of an application in Linux? I'm using c++. Any idea? For windows there are a lot of resources but I can't find anything for linux

Any help? Thanks

lothar
  • 19,853
  • 5
  • 45
  • 59
Noyoudont
  • 155
  • 3
  • 7

3 Answers3

2

Already answered here:

Screenshot of a windows application running under wine (linux)

Edit: if you want to do it in C, try Xlib. Some links:

Community
  • 1
  • 1
ChristopheD
  • 112,638
  • 29
  • 165
  • 179
  • Humm... Since I'm building a screencast application, I need it to be as fast as possible. Saving it to disk and opening it again is probably time consuming. But I'll give it a try! – Noyoudont May 07 '09 at 20:39
  • Xlib alone does not really help. AFAIK, there is no way to do fast screenshots purely using Xlib. – Zifre May 07 '09 at 21:11
  • @Zifre: Yes you can take a screenshot with Xlib. http://stackoverflow.com/questions/8249669/how-do-take-a-screenshot-correctly-with-xlib And, right now - I am doing it in python, both with python-Xlib and with ctypes as well (py-Xlib is to slow for such a task). – b0bz Apr 22 '13 at 03:32
1

If you just want a screen recorder, try using xvidcap. If you want to make your own, try looking at the sources. I'm not really sure how it works though. My guess is that it uses the XShm extension somehow.

Zifre
  • 26,504
  • 11
  • 85
  • 105
-1

Can't you just do this with http://www.imagemagick.org/script/index.php ?

It's usually onboard the linux repos, and you can do a lot more than just take a screen shot with it... http://tips.webdesign10.com/how-to-take-a-screenshot-on-ubuntu-linux