View previous topic :: View next topic |
Author |
Message |
TraxMate Master Cheater Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Sun Oct 26, 2008 3:00 am Post subject: [C++] Pixels |
|
|
This is a little program I made to master(kinda..) GetPixel . It allows you to read the RGB value from a certain point and I made it so you can draw at the screen ^^.
Source is included.
|
|
Back to top |
|
|
Noz3001 I'm a spammer Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Sun Oct 26, 2008 4:08 am Post subject: |
|
|
You should draw a line between the pixels in the Draw part. Will make it look better. ^_^
|
|
Back to top |
|
|
TraxMate Master Cheater Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Sun Oct 26, 2008 4:22 am Post subject: |
|
|
noz3001 wrote: | You should draw a line between the pixels in the Draw part. Will make it look better. ^_^ | How do you mean? I don't understand :S. Could you explain better?
|
|
Back to top |
|
|
blackmorpheus Expert Cheater Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Sun Oct 26, 2008 4:30 pm Post subject: |
|
|
doesnt work
|
|
Back to top |
|
|
--Pillboi-- Grandmaster Cheater Supreme Reputation: 0
Joined: 06 Mar 2007 Posts: 1383 Location: I don't understand the question. Is this a 1 to 10 thing?
|
Posted: Mon Oct 27, 2008 1:30 pm Post subject: |
|
|
Don't spam blackmorpheus
_________________
Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair. |
|
Back to top |
|
|
hcavolsdsadgadsg I'm a spammer Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Mon Oct 27, 2008 4:48 pm Post subject: |
|
|
1. You never release your DC.
2. Sleeping your main loop is pointless, since it will just wait for input at the start.
3. Why are you using printf instead of cout?
4. You can use the RGB macro instead of splitting up your COLORREF.
instead of: Code: | COLORREF Color = GetPixel(hdc, x, y);
BYTE Red, Green, Blue;
Red = GetRValue(Color);
Green = GetGValue(Color);
Blue = GetBValue(Color);
if(Red == r, Green == g, Blue == b) |
You can just do Code: | if(Color == RGB(r, g, b)) |
or even
Code: | if(GetPixel(hdc, x, y) == RGB(r, g, b)) |
5. ERROR_SUCCESS may be more descriptive than FALSE...
6. You can do: Code: | while(!GetAsyncKeyState(VK_F12)) | instead of Code: | if(GetAsyncKeyState(VK_F12))
draw = false; | within the loop.
7. Just get the DC once instead of OVER AND OVER.
8. You'll probably find a switch statement neater.
SOME FOOD FOR THOUGHT. GDI is fun.
|
|
Back to top |
|
|
TraxMate Master Cheater Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Tue Oct 28, 2008 7:03 am Post subject: |
|
|
Thanks slovach, that was some usefull tips.
|
|
Back to top |
|
|
--Pillboi-- Grandmaster Cheater Supreme Reputation: 0
Joined: 06 Mar 2007 Posts: 1383 Location: I don't understand the question. Is this a 1 to 10 thing?
|
Posted: Tue Oct 28, 2008 9:26 am Post subject: |
|
|
slovach wrote: | 6. You can do: Code: | while(!GetAsyncKeyState(VK_F12)) | instead of Code: | if(GetAsyncKeyState(VK_F12))
draw = false; | within the loop. |
I haven't looked at his code, but those statements do different things.
Your code will only draw while F12 is not down, where as his code will stop drawing all together.
_________________
Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair. |
|
Back to top |
|
|
TraxMate Master Cheater Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Tue Oct 28, 2008 10:40 am Post subject: |
|
|
--Pillboi-- wrote: | slovach wrote: | 6. You can do: Code: | while(!GetAsyncKeyState(VK_F12)) | instead of Code: | if(GetAsyncKeyState(VK_F12))
draw = false; | within the loop. |
I haven't looked at his code, but those statements do different things.
Your code will only draw while F12 is not down, where as his code will stop drawing all together. | If you look at my code you can see that that method is better than the one I used.
|
|
Back to top |
|
|
hcavolsdsadgadsg I'm a spammer Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Oct 28, 2008 12:26 pm Post subject: |
|
|
--Pillboi-- wrote: | slovach wrote: | 6. You can do: Code: | while(!GetAsyncKeyState(VK_F12)) | instead of Code: | if(GetAsyncKeyState(VK_F12))
draw = false; | within the loop. |
I haven't looked at his code, but those statements do different things.
Your code will only draw while F12 is not down, where as his code will stop drawing all together. |
Wrong. The condition is met, so the loop stops.
|
|
Back to top |
|
|
--Pillboi-- Grandmaster Cheater Supreme Reputation: 0
Joined: 06 Mar 2007 Posts: 1383 Location: I don't understand the question. Is this a 1 to 10 thing?
|
Posted: Tue Oct 28, 2008 3:00 pm Post subject: |
|
|
Sorry, yes your right. For some reason I was thinking that those statements were within a constant loop.
_________________
Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair. |
|
Back to top |
|
|
nog_lorp Grandmaster Cheater Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Tue Oct 28, 2008 4:37 pm Post subject: |
|
|
slovach wrote: | 3. Why are you using printf instead of cout? |
stdio is faster?
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish |
|
Back to top |
|
|
hcavolsdsadgadsg I'm a spammer Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Oct 28, 2008 4:54 pm Post subject: |
|
|
nog_lorp wrote: | slovach wrote: | 3. Why are you using printf instead of cout? |
stdio is faster? |
Yeah, who needs to use ASM or anything in speed critical parts? Just replace your cout's with printf's.
|
|
Back to top |
|
|
Silent Storm Advanced Cheater Reputation: 0
Joined: 03 Jan 2008 Posts: 61 Location: registry
|
Posted: Sun Mar 29, 2009 6:11 am Post subject: |
|
|
Could you reupp the files pls
|
|
Back to top |
|
|
TraxMate Master Cheater Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Sat Apr 18, 2009 2:09 pm Post subject: |
|
|
Silent Storm wrote: | Could you reupp the files pls | No I don't have the files left on my pc, sorry.
|
|
Back to top |
|
|
|