Oh ok, well how can i fix it then.
Just a guess, but it's probably because your compare r_pixel_one to itself =/
Originally Posted by exert from ur code
Oh ok, well how can i fix it then.
Compare it to the pixel you want to test. So your comparing the pixel your testing to tree or background. You don understand if you compare a r_pixel_one to itself it will always be greater then itself -20.
That's like saying 10 > 10 -20. It will be always true and accomplishes nothing. What you want is something like this:
(|x - y| <= 20)
see now if x is 20 and y is 40, 20 - 40 = -20, then we take the abs value and its 20, which is <= 20.
if both x & y are unsigned chars you don't even have to worry about abs value assuming you always subtract the smaller from the larger, otherwise you'll loop back around.
And might I ask what exactly your trying to do, because there's got to be an easier way...
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
258456 (02-14-2011)
OMG, thanks so much why06, your post helped so much that i started cracking up at how stupid my logic was. It's so obvious now that you explained it. If i could thank you multiple times i would. Thanks.
I am working on a runescape bot and this new feature will detect if i am cutting wood from the yew tree or if i got pulled into some random event in which both colors will change dramatically. Once my bot detects that it is in a random event, it will text me and then it will close itself. I wish there was an easier and more reliable way than using colors because it's really unreliable but it will work in my situation i guess.
Can i also do it like this:
would that work or am i just doing the same thing?Code:int r = r_pixel_one-20; // then do the if statement... RGB(r_pixel_one >= r .......and so on
Last edited by 258456; 02-14-2011 at 09:47 PM.
np. happens to everyone, and myself plenty of times. It's often easier for others to see obvious things you might have missed, and then ur feel like a dumbass >_>, but life goes on...
Nope.Can i also do it like this:
would that work or am i just doing the same thing?Code:int r = r_pixel_one; // then do the if statement... RGB(r_pixel_one >= r - 20.......and so on
Once they are equal
The same problem comes up...Code:int r = r_pixel_one;
Code:RGB(r_pixel_one >= r - 20
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
Oh ya huh, lol there's the stupidity again. How can I fix it, I m puzzled cuz I can't really put any number values because they are always different
Last edited by 258456; 02-14-2011 at 10:04 PM.
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
258456 (02-15-2011)
Ya I see what u r saying idk y I just posted that, lol it's really late at night where I m as u can tell, lol. Do u have any suggestions on how to solve this problem. Btw thanks for being such a great help.
The only idea coming to my mind right now is this:
Sorry that I can't really test anything since I m on the itouch lol. Thanks so much for your help I know I say it a lot but your help really means a lot to me.Code:tree= RGB(r_pixel_one || r_pixel_one +1 || r_pixel_one+2 ... and so on)
Last edited by 258456; 02-14-2011 at 10:18 PM.
No, doesn't work like that o_O
Ah we-a blaze the fyah, make it bun dem!
258456 (02-15-2011)
Ya I kinda figured it wouldn't be that easy. Any suggestions?
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
258456 (02-15-2011)
Well, the problem isn't that i don't know what to do with the number (value of r_pixel), the problem is that if i want to do something else i will press the numpad 1 and then it will detect the pixel which will be another number. The r pixel is usually about 5-6.
EDIT: WHOAAAAAA!!!!! i think i just made a breakthrough, can i do this:
Code:r_pixel_one = GetRValue(pixel2); int r = GetRValue(pixel2); COLORREF tree = RGB(r_pixel_one >= r -20...........and so on.);
Wouldn't this work?
Last edited by 258456; 02-15-2011 at 08:24 AM.
HOW DO I DO THIS HD. My brain is going to explode. I am pretty sure you knew the answer from the beginning.
If you want to check if COLORREF pixel2 is between for example RGB(200, 150, 100) and RGB(225, 125, 200) you'd use the following code:
if it's not that what you're trying to do please rephrase it =3Code:char r = ((char*)pixel2)[0]; //or GetRValue(pixel2) char g = ((char*)pixel2)[1]; //GetGValue(pixel2) char b = ((char*)pixel2)[2]; //GetBValue(pixel2) if( (r >= 200 && r <= 225) &&//Red is ok (g <= 150 && g >= 125) &&//Green is ok (b >= 100 && b <= 200) )//B is also ok { //all are ok ...more code here... }
Ah we-a blaze the fyah, make it bun dem!
258456 (02-15-2011)