Solved

take a screenshot and convert it

Posted on 2007-11-25
18
272 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now