Link to home
Start Free TrialLog in
Avatar of neester
neesterFlag for Australia

asked on

Take Screenshot in C

Hey Guys,
Just a question.

I am about to start a new project where I hope to develop a program which will screenshot games as you play, and upload the image to a webserver.
Firstly - I need to know if C would be the best language to use?

How easy is it for C to take a screenshot and resize/convert it to a 600*480 JPG??
How easy is it to open a HTTP connection?
I can make a PHP script to accept a file upload - I just need to know how easy it is to actually upload the file...

I haven't done much on this level with C...

This question will probably end up with points being split.
So PLEASE even if someone has posted something GREAT.
Post too!
I will award anything useful!

Thanks people!

(btw, google is so hard, when searching for example "c" code. type: screenshot + c in goolge and you get 50,000 results that don't help)
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Hi neester,

There are libraries available that can do this.

If you're into C++, that's probably a cleaner solution.


Kent
Avatar of neester

ASKER

Hmm...
I would love to try it!

Any example code would be lovely!
At the moment, I use Pelles C and GCC to code.
What is a good program for C++??

I have MS Visual C++
From Vis Studio 6...
>How easy is it for C to take a screenshot and resize/convert it to a 600*480 JPG??
Not very sure about taking a screen shot ... you can take a look at ijg jpeg library for conversion part though ... I think ijg library has the conversion facility

>How easy is it to open a HTTP connection?
>I can make a PHP script to accept a file upload - I just need to know how easy it is to actually upload the file..
this should not be too difficult ... google for libcurl
Avatar of neester

ASKER

Ahh curl,
Will that work on Windows.

I have used it with Perl and PHP before.
Never with C.
Like I said, I am pretty new to C here :S

I just want something thats ultra efficent.
It just needs to take a screenshot.
Slowly resize and compress the image - low cpu usage if possible,
then upload.

Needs to work on Windows.
Avatar of neester

ASKER

Yeah sunny i went there

http://curl.haxx.se/libcurl/c/

looks good!

BUT, where do i actually download it?
I found install instructions, but no download links?
Looks great though!
Definatly worth some points!!!

Now how do I take screenshots?
Thanks!
Avatar of neester

ASKER

ahh found it!
Avatar of neester

ASKER

Ok I downloade CURL, it is an exe, not a normal .h header file.

See this: http://curl.haxx.se/lxr/source/docs/examples/simple.c

How do I compile that?
I am using Pelles C...
:D
If you downloaded source, compiling and installation instructions should be a part of it. Look for a file named README.txt or something similar.

I am not sure how you can take a screen shot from a program ... there are several tools to do this ... Also, for windows Ctrl+Print Scrn and Alt+Print Scrn work ... Dont know if windows provides some useful APIs for the same.
Avatar of neester

ASKER

Ahh ok thanx sunny!

Maybe i should try C++??
I am a bit irritated with C's lack of string handling.
Makes life "seemingly unnecessaryly hard"...

Thanks for your input so far:)

Appreciate it very much!
I will concede that C is not the best tool for this job ... C is better suited for system software, OS programming and other things where you need the control and flexibility that C offers.
Avatar of neester

ASKER

So your recommendation would be C++??
Thanks very much sunny!
probably saved me a lot of time and bother :D
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of neester

ASKER

Thanks a lot sunny!
It answered my questions!
:)


Another question.
I will accept your answer.
Are there many people who help in the C section?
I havent noticed many???

Thanks!
There are many good experts in C section ... But all of them are not around all the time ... Also, as compared to some other TAs we are lot more friendly here ... We show each other mutual respect ... If one expert is handling the question satisfactorily, chances are no other expert is going to jump in with same/similar advise in hunt for points ... We are competitive but in a healthy collaborative way.
Avatar of neester

ASKER

Ahh ok :)
Sounds nice :D

WebDev section can get a bit cutthroat at times :)
hehe

Thanks again!
I will ask around the C++ section!