GetPixel() help
-
I am trying to retrieve the RGB code of GetPixel() and I have a slight bit of understanding of C++, I'm pretty fluent in Java and VB.net, but the first parameter for the GetPixel function has to be some sort of HDC thing, how would I return it as RGB or hexadecimal, like using it as this: GetPixel(0,50,50); returns a number that is too large for an integer 42929... Can anyone help me? Please don't write a bunch of classes and constructors and stuff, just simple non-OOP code, best if its just one word, it's less confusing. Thanks alot.
-
I am trying to retrieve the RGB code of GetPixel() and I have a slight bit of understanding of C++, I'm pretty fluent in Java and VB.net, but the first parameter for the GetPixel function has to be some sort of HDC thing, how would I return it as RGB or hexadecimal, like using it as this: GetPixel(0,50,50); returns a number that is too large for an integer 42929... Can anyone help me? Please don't write a bunch of classes and constructors and stuff, just simple non-OOP code, best if its just one word, it's less confusing. Thanks alot.
It returns a
COLORREF
(a DWORD in nature!), You must useGetRValue
,GetGValue
, andGetBValue
to extract individual RGB values.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.
-
It returns a
COLORREF
(a DWORD in nature!), You must useGetRValue
,GetGValue
, andGetBValue
to extract individual RGB values.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.
-
Thanks, I sorta understand what you mean, but can you tell me what additional code I need to use it/how to set it up?
For eg:
BYTE redValue;
BYTE greenValue;
BYTE blueValue;redValue = GetRValue(GetPixel(hdc,50,50));
greenalue = GetGValue(GetPixel(hdc,50,50));
blueValue = GetBValue(GetPixel(hdc,50,50));
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.
-
For eg:
BYTE redValue;
BYTE greenValue;
BYTE blueValue;redValue = GetRValue(GetPixel(hdc,50,50));
greenalue = GetGValue(GetPixel(hdc,50,50));
blueValue = GetBValue(GetPixel(hdc,50,50));
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.
-
arunforce wrote:
undeclared identifier.
Weird exception!;P But is it not good you learn something before asking questions? I help you out : HDC[^]
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.
-
Are you trying to get the color of a pixel on the screen? In a bitmap? If a bitmap, what form of bitmap...Windows device independent, Windows device dependent?
"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")
-
You only wanted one word, but for Windows graphics programming, DCs are an essential concept, regardless of classes and OOP stuff. If you decide you want to learn it, here's some free info: Device Contexts[^]
"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")
-
Sorry, I should of specified. It's just to get the pixel color of the pixel on the entire screen, doesn't matter what application or whatever, I could probably code it in VB or Java easier, but I want to make it professional. It's been a good 2 years since I've even touched C++, and it's a bit troubling. C++'s keywords and stuff throw me off, I find that it has no relation to a similar structure, and it's a bit confusing. I probably need more experience, but then again, I'm just 17. :/
-
Sorry, I should of specified. It's just to get the pixel color of the pixel on the entire screen, doesn't matter what application or whatever, I could probably code it in VB or Java easier, but I want to make it professional. It's been a good 2 years since I've even touched C++, and it's a bit troubling. C++'s keywords and stuff throw me off, I find that it has no relation to a similar structure, and it's a bit confusing. I probably need more experience, but then again, I'm just 17. :/
arunforce wrote:
It's just to get the pixel color of the pixel on the entire screen
In that case, as Vunic suggested, the GetDC(NULL) API will get you a screen DC. Don't forget to free it when you are finished with it (ReleaseDC()). Mark
"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")
-
Sorry, I should of specified. It's just to get the pixel color of the pixel on the entire screen, doesn't matter what application or whatever, I could probably code it in VB or Java easier, but I want to make it professional. It's been a good 2 years since I've even touched C++, and it's a bit troubling. C++'s keywords and stuff throw me off, I find that it has no relation to a similar structure, and it's a bit confusing. I probably need more experience, but then again, I'm just 17. :/
arunforce wrote:
I could probably code it in VB or Java easier
Yup it is, when you opt for the Ignorance is bliss thinge. Just 17? Great, you are trying something good. At your age I never managed to install an IDE in my pc. The only user-made directory in my pc was "GAMES". C:\CD GAMES. :-D lol.. it was all games.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.
-
arunforce wrote:
undeclared identifier.
Weird exception!;P But is it not good you learn something before asking questions? I help you out : HDC[^]
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.
"undeclared identifier" Your code has an error maybe compiler has an internal error;P;)
WhiteSky