Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Take Screenshot in C

Posted on 2005-04-17
16
Medium Priority
?
506 Views
Last Modified: 2010-04-15
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)
0
Comment
Question by:neester
  • 9
  • 6
16 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 13802890
Hi neester,

There are libraries available that can do this.

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


Kent
0
 
LVL 11

Author Comment

by:neester
ID: 13802940
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...
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 13803036
>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
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 11

Author Comment

by:neester
ID: 13803098
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.
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 13803118
0
 
LVL 11

Author Comment

by:neester
ID: 13803307
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!
0
 
LVL 11

Author Comment

by:neester
ID: 13803346
ahh found it!
0
 
LVL 11

Author Comment

by:neester
ID: 13803386
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
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 13804718
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.
0
 
LVL 11

Author Comment

by:neester
ID: 13804864
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!
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 13804882
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.
0
 
LVL 11

Author Comment

by:neester
ID: 13804919
So your recommendation would be C++??
Thanks very much sunny!
probably saved me a lot of time and bother :D
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 2000 total points
ID: 13805027
I am not much experienced with what you are trying ... C++ would be a better fit than C for sure, but I cannot assure you if it is the best choice ... you need to ask that to C++ people or guys who have worked on such problems ...
0
 
LVL 11

Author Comment

by:neester
ID: 13805942
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!
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 13811827
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.
0
 
LVL 11

Author Comment

by:neester
ID: 13812690
Ahh ok :)
Sounds nice :D

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

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question