Results 1 to 9 of 9
I want to write a simple program to capture complete desktop screenshot in pure C on linux i.e no QT or Xlib...
- 07-05-2011 #1Just Joined!
- Join Date
- Jul 2011
- Posts
- 6
Program to capture desktop screenshot in pure C
I want to write a simple program to capture complete desktop screenshot in pure C on linux i.e no QT or Xlib
Last edited by vampire36; 07-05-2011 at 12:56 PM.
- 07-06-2011 #2Just Joined!
- Join Date
- Jan 2011
- Location
- Fairfax, Virginia, USA
- Posts
- 94
Hi vampire36,
I've done this in the past. If you don't mind using X, I'd recommend taking a look at the "X Window Dump" xwd program because its really pretty simple. I'd imagine you want to produce some kind of common image format other than an .xwd (.xwd's are really big), so that will be your trickiest part. You can use code from ImageMagik as a guide you.
Here is the source code for xwd:
http://cvsweb.xfree86.org/cvsweb/*ch...ype=text/plainLast edited by BrianMicek; 07-06-2011 at 02:26 AM. Reason: augmentation
- 07-06-2011 #3Just Joined!
- Join Date
- Jul 2011
- Posts
- 6
Well i wanted a pure C program...
Don't want to use xwd as well !!!
Could you suggest something else ???
- 07-06-2011 #4
- 07-06-2011 #5Just Joined!
- Join Date
- Jul 2011
- Posts
- 6
yup I got that...
I went through that already...
But it uses Xlib and stuff...
i wanted something in pure C if possible...
- 07-06-2011 #6Just Joined!
- Join Date
- Jul 2011
- Posts
- 6
- 07-06-2011 #7Just Joined!
- Join Date
- Mar 2011
- Posts
- 4
Even pure C would have to interact with the xlib resources to be aware of existing screens running on desktop. Seems like a lot of "recreating the wheel" to write all in C, unless your application requires it.
I prefer ImageMagik you can simply add code like this in C to use:
xwd is a more likely already installed on more systems.Code:%%system("import -window root root.jpeg")
However you will still need to format the .xwd to your preferred format.Code:%%system(xwd -root -out test.xwd)
- 07-06-2011 #8Just Joined!
- Join Date
- Jul 2011
- Posts
- 6
Na that would fork a new process and want to avoid that...
so no commandline would work...
even xlib would be fine...
i wanna capture the image and dump in raw format into a file...
any suggestion ???
- 07-07-2011 #9Just Joined!
- Join Date
- Apr 2011
- Posts
- 19
XGetImage
You probably want to use XGetImage as the X call. To grab stuff off the xcreenm you have to use X, X is the screen
I'd suggest looking at the xwd stuff to figure out how to open the display and the associated setup. The bible on this stuff is the OReilly books by Adrian Nye vol's 1 & 2, The Xlib Programming manual & X Reference manual. Worthwhile investment if you are going to do much in X.


Reply With Quote
