Solved

take a screenshot and convert it

Posted on 2007-11-25
18
277 Views
Last Modified: 2010-05-18
how do I take screenshot and then process each pixel on the screenshot into

a combination of

RGB?

for instance


array[1280][1024] == 125, 150, 150
0
Comment
Question by:Troudeloup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 5
18 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20347421
Why do you ask the same again, just continue with the old question.
0
 

Author Comment

by:Troudeloup
ID: 20347581
how do I import library from windows sdk ?
0
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!

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20347593
that's a generic question, usually, you create a project in your compiler IDE, specifying it is a Win32 project. The compiler will include proper libraries in your project definition.
Then, in your source code you usually have to include <windows.h> header.
0
 

Author Comment

by:Troudeloup
ID: 20347602
what if I use a generic editor?


0
 

Author Comment

by:Troudeloup
ID: 20347606
so if I just include the line  

#include <windows.h>


mingw would know to pull from windows sdk?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20347621
if it is well configured in your compiler, yes.
0
 

Author Comment

by:Troudeloup
ID: 20347632
http://msdn2.microsoft.com/en-us/library/ms532282.aspx


I don't get this part;  can you walk me through specifc codes?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20347646
it is hard to explain this way. you need to get a bitmap first. Have you read the article I suggested about Screen Capturing at www.codeproject.com?
0
 

Author Comment

by:Troudeloup
ID: 20347651
COLORREF GetPixel(
  HDC hdc,    // handle to DC
  int nXPos,  // x-coordinate of pixel
  int nYPos   // y-coordinate of pixel
);


is hdc of HWND type obtained from

HWND FindWindow

what does it return?



0
 

Author Comment

by:Troudeloup
ID: 20347655
hmmm i think i can get it if i can see all the codes.
0
 

Author Comment

by:Troudeloup
ID: 20347705
will you post that again?
0
 

Author Comment

by:Troudeloup
ID: 20347735
this taking it the GDI way the easiest way to do it?

http://www.codeproject.com/dialog/screencap.asp
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20347754
yes, it is the more suitable for your requirements
0
 

Author Comment

by:Troudeloup
ID: 20347856
Void CaptureScreen()
{
    int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
    int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
    HWND hDesktopWnd = GetDesktopWindow();
    HDC hDesktopDC = GetDC(hDesktopWnd);
    HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
    HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC,
                            nScreenWidth, nScreenHeight);
    SelectObject(hCaptureDC,hCaptureBitmap);
    BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,
           hDesktopDC,0,0,SRCCOPY|CAPTUREBLT);
    SaveCapturedBitmap(hCaptureBitmap); //Place holder - Put your code
                                //here to save the captured image to disk
    ReleaseDC(hDesktopWnd,hDesktopDC);
    DeleteDC(hCaptureDC);
    DeleteObject(hCaptureBitmap);
}






this code seems to take screen shot on the whole screen - but i need to take it only on specific focused window given its handle.

1)  only the window
2) give handle to it



also, what's the name of the variable HDC that I pass to the getpixel function?

can you show me a sample code?
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 20350384
Troudeloup, you posted the same question again in http:Q_22981685.html.

Would you stop doing so? All who answered for the second question may hve done it for nothing as the question most likely will be deleted by a moderator.

Regards, Alex
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

688 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