Solved

take a screenshot and convert it

Posted on 2007-11-25
18
271 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
Comment Utility
0
 
LVL 55

Expert Comment

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

Author Comment

by:Troudeloup
Comment Utility
how do I import library from windows sdk ?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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
Comment Utility
what if I use a generic editor?


0
 

Author Comment

by:Troudeloup
Comment Utility
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
Comment Utility
if it is well configured in your compiler, yes.
0
 

Author Comment

by:Troudeloup
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Troudeloup
Comment Utility
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
Comment Utility
hmmm i think i can get it if i can see all the codes.
0
 

Author Comment

by:Troudeloup
Comment Utility
will you post that again?
0
 

Author Comment

by:Troudeloup
Comment Utility
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
Comment Utility
yes, it is the more suitable for your requirements
0
 

Author Comment

by:Troudeloup
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:Troudeloup
Comment Utility
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 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.

763 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

8 Experts available now in Live!

Get 1:1 Help Now