Solved

take a screenshot and convert it

Posted on 2007-11-25
18
274 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
  • 12
  • 5
18 Comments
 

Author Comment

by:Troudeloup
ID: 20347221
0
 
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 

Author Comment

by:Troudeloup
ID: 20352675
0
 

Author Comment

by:Troudeloup
ID: 20352679
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

840 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