Solved

take a screenshot and convert it

Posted on 2007-11-25
18
276 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
 

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
Industry Leaders: 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
 

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

734 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