Question about GetPixel(); -function

I'm making a 2D platform game and I basically know what I'm doing and how I'm doing, but I need some help with GetPixel(); -function. That should return a RGB value of an image.

( http://msdn.microsoft.com/en-us/library/ms532282(VS.85).aspx )

So the actual question is, what should I enter as hdc value?
I alwreasy tired to make LoadImage return a value, but that didn't work.
Or can I even use this function with bitmaps?

I'm running Windows XP / Vista.

And sorry for not sending that counting game I made, I just never actually finished it. (It was pretty buggy and I had no more interest to fix them :P)
Last edited on
A DC is a Device Context, upon which all Win32 graphics functions are implemented. In other words, you cannot operate upon a bitmap directly (at least, not with Win32 GDI functions). You must first select it into a DC.

Here's a tutorial: http://www.winprog.org/tutorial/bitmaps.html

BTW, would you edit out the parentheses around the GetPixel URL? It is unclickable with them.

Hope this helps.
Thanks, that helped alot, but (sorry, if this is stubid question) how can I convert HBITMAP to HDC?
Sorry if it's said there but I didn't understand how to do it.

(and sorry for the bump, I ware on holidays and couldn't answer)
I mean, how to load a bitmap to HDC,
how to convert HBITMAP to HDC,
how to convert HGDIOBJ to HDC or
how to make GetPixel(); read an HDC instead of HBITMAP?

If anyone knows an answer to any of them, please answer.
Last edited on
It just says:

Server Error in '/' Application.
--------------------------------------------------------------------------------

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /en-us/library/ms533971(VS.85).aspx.

EDIT: Got working, sorry.
EDIT: I don't have the gdiplus library, where can I get it?
Last edited on
I found this thread: http://forums.msdn.microsoft.com/en/vcgeneral/thread/651ef719-65f9-4374-882c-b3a0ccb68a4a/

I tried that

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <Windows.h>

#include <gdiplus.h>

using namespace Gdiplus;

#include <iostream>

int main()

{

return 0;

}


thing , but then the compiler gave strange errors about gdiplus.h file itself.
Topic archived. No new replies allowed.