someone could help me with a tutorial, or a help where to start ?
thanks in advance
someone could help me with a tutorial, or a help where to start ?
thanks in advance
What do you plan on doing with the image? You want it in a buffer to play with? Save to a file? Want it in a BITMAP? DirectX, WinAPIs?
Don't quote me on that... ...seriously
Everything is in MSDN
0.05 seconds to find code with Google
At the begining i need it in a buffer as pixels, and go with a for cycle, and look for how many colors is being used...
but Brad0407 what about that WinAPI's... ??? which API's could i use ???
Here's a hint: You can treat the screen as a whole like you would any other window.
There are so many different ways to use the APIs that you should probably decide which ones to use for yourself. I assume you at least know how to draw a bitmap cause that will be the easiest thing you'll do.Code:HDC screenDC = GetDC(0);
Don't quote me on that... ...seriously
I found this cod as a example:
is this HDC hDesktopDC = GetDC(hDesktopWnd); where will hold all the pixels, and if i wan to do a cycle for and check all the pixels how would i do it ?Code: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); }
for (i = 0; i <= hDesktopDC; i++ ) something like this ?
then what i need is to check each pixel color... how could I do this ??
That depends. Is speed important to you? GetPixel() is very slow but it's really easy. You can use GetBitmapBits or something like that if speed is important but I always have trouble getting it to work. If speed is of the utmost importance, use DirectX.
Don't quote me on that... ...seriously
Yes speed is very important to me,
I need to use something like GetBitmapBits(hDesktopDC) to get the pixels in a array ???
so when you say use directX i should change all the code or i just use directX to grap info from hDesktopDC and then use it with directX functions to retrieve information about the pixels, i'm a bit confuse ???
well, i will try to look for something about dib section, but if you could leave more information about it, would be great
If you use a back buffer, why not just set the bitmap file header data then write the contents of the back buffer after this?
didnt't understand why you saying about back buffer, i want to say im a novice at C++, i know the realy basic, and i found the code above from a a tutorial.
everything someone says here i try to find more information about it, on google, but i appreciate if someone could leave examples when talking about the stuff i could do thanks
Hmm. Do you have a back bufffer? A back buffer is a secondary place used to compile a scene then when the scene is done, it is drawn on the screen. Although not important for all programs, a back buffer is useful for games and some other types of programs. Without it, you may be seeing odd flickering effects from two images being drawn to the screen at different times and the monitor's refresh getting to the area between the drawings. If you use a back buffer, taking a screenshot is rather easy.
I'm also fairly new to C, but not entirely new to programming. I'd suggest looking up BITMAPFILEHEADER and BITMAPINFOHEADER to get the header details, and using fwrite (and the related) to write the output. The file header comes first, then the info header, then the image data itself.
My methods may not be anything standard, I mainly just use whatever works and meets my needs.
Did you click the link? What additional information were you after?
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill