You are not logged in.

#1 2009-01-13 23:01:12

Envil
Member
Registered: 2008-11-18
Posts: 52

[solved] Taking a screenshot with c++

Is there some somewhat easy way to get a screenshot of my desktop in c++ trough some library or so?
Or am i better of just calling some external program which will take care of that? if so which one would be good? (Screenshots should be saved as .bmp or high quality png with a filename of my choice)

I dont need the actual image inside my program, i just want to take screenshots at a certain time and have them saved with a specific file name.

Last edited by Envil (2009-01-14 23:04:03)

Offline

#2 2009-01-14 00:21:26

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: [solved] Taking a screenshot with c++

you can use imagemagick's import command:

import -window root screenshot.png

or look at it's source code and do it in c/c++

Offline

#3 2009-01-14 07:34:39

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: [solved] Taking a screenshot with c++

Can't you just use scrot+cron or something? You'd get to not program in C++, anyway.

Offline

#4 2009-01-14 11:47:47

Envil
Member
Registered: 2008-11-18
Posts: 52

Re: [solved] Taking a screenshot with c++

Doing it with cron wouldnt be good since the c++ program performs certain steps, when its done with those i want the screenshot taken and this doesnt always happen at exactly the same times so its better to trigger it from the program.

Offline

#5 2009-01-14 17:58:53

liquibyte
Member
Registered: 2007-11-11
Posts: 91
Website

Re: [solved] Taking a screenshot with c++

I'm sure if you play with it you could make it function in much less code.  I'm actually glad I found this myself, I hope you can use it.

http://svn.gnome.org/viewvc/gnome-utils … iew=markup

Offline

#6 2009-01-14 19:57:52

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: [solved] Taking a screenshot with c++

Just exec to scrot or similar at the end of your program.  Time to implement: 02 seconds.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#7 2009-01-14 21:40:23

linkmaster03
Member
Registered: 2008-12-27
Posts: 269

Re: [solved] Taking a screenshot with c++

I also recommend the 'import' command. I use it all the time for everyday screenshots. It can save into perfect quality .png. I have never used scrot.

Last edited by linkmaster03 (2009-01-14 21:40:56)

Offline

#8 2009-01-14 23:03:47

Envil
Member
Registered: 2008-11-18
Posts: 52

Re: [solved] Taking a screenshot with c++

Gonna go with exec'ing import, ty all ^^

Offline

Board footer

Powered by FluxBB