caused
2009-07-02 21:26:01
Heya.
Is there an easy way, to make Functions like
FindBitmapToleranceIn,
FindColor and
FindColorTolerance
to search from the lower right corner to the upper left corner ?
~caused
[php]function FindColorSpiral(var x, y: Integer; color, xs, ys, xe, ye: Integer): Boolean;
Find color in box specified by xs, ys, xe, ye but start from x,y.
function FindColorSpiralTolerance(var x, y: Integer; color, xs, ys, xe, ye: Integer; Tolerance: Integer): Boolean;
Works like the regular FindColorSpiral but with a tolerance parameter for finding any similar color. Tolerance is used to find a color in range of the color you are looking for. The greater color range you want, the higher the tolerance parameter should be.[/php]
For the last one
[php]
function FindBitmapSpiral(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer): Boolean;
Search for the bitmap in coordinates specified by x1, y1, x2, y2 starting from x, y. Bitmap contains handle to bitmap generated by LoadBitmap.[/php]
caused
2009-07-02 21:35:35
Thanks Nauman, but i would need a function that works like the functions i mentioned, not scanning in a spirals, but vertically.
Yeah, so if you wanted to start from the lower right corner, then you would use a cord in the lower right corner, as it starts from that point.
If your not happy with that then the answer is no.
caused
2009-07-02 21:41:32
But it searches in spirals, doesnt it ?_?.
I'd need to search like that:
x= pixel o= searched
xxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx
xxxxxxxxooooooooo
I think find spiral color does something like:
xxxxxxxxxxxxxxxoo
xxxxxxxxxxxxooooo
xxxxxxxxxxooooooo
xxxxxxxxooooooooo
~caused
Blumblebee
2009-07-02 21:46:55
function FindColorSpiral(var x, y: Integer; color, xs, ys, xe, ye: Integer): Boolean;
notice the xs, ys, we, ye? this is where you can edit to create a box on the screen for you to search.
to make it search from one side to the other you can simply start the search at the farthest left point by adjusting the x and y value.
caused
2009-07-02 21:56:27
No, I dont think you understood me yet xD….
so…
Example 100x100 image.
I need a function that first scans from:
– x cord —- y cord
1. 100to0 | 100
2. 100to0 | 99
3. 100to0 | 98
4. 100to0 | 97
…
100. 100to0 | 1
Hope that makes it clear =).
~caused
mastaraymond
2009-07-03 13:19:06
Not possible with bitmapfinding..
With color finding you can just do FindColorsTolerance, and after that ReverseTPA(TPA); Should do the trick.
mixster
2009-07-03 13:43:45
Unless he doesn't mind slowdowns.
In theory, repeatedly searching from the point found onwards until it didn't find anything would result in finding the last bitmap.
Alternatively, setting search area to very bottom right then incrementing it after each unsuccessful search should do it.
Then the only problem exists in that if there are two on the same line, it may miss the latter one. This would depend on if the search area was expanded by 1 horizontally each time then one vertically and resets the x search area (for second option). For the first option, since there's no FindBitmapSkipBox or the like, you would have to each drop down a line after finding one to ensure it doesn't re-find the same one, thus possibly missing one further to the right of it. The way around this would be to perform a search for the rest of that line first then go onto the next line, but unsure as to the success of this.
caused
2009-07-03 20:50:46
From: mixster
Unless he doesn't mind slowdowns.
In theory, repeatedly searching from the point found onwards until it didn't find anything would result in finding the last bitmap.
Thats what I'm doing now =).
Thanks for your replies
Nadeem
2009-07-04 00:00:49
Why don't you just create a downto loop and enter coords starting from lower right decreasing to top left?
~NS
Shuttleu
2009-07-04 01:54:07
just whiped this up
try it
FindColorReverse(var x, y: Integer; Color: Integer): Boolean;
var
i, j: Integer;
begin
for i:=MSY2-1 downto MSY1 do
begin
for j:=MSX2-1 downto MSX1 do
begin
Result:= FindColor(x, y, Color, j, i, MSX2, MSY2);
if Result then break;
end;
if Result then break;
end;
end;
~shut
caused
2009-07-04 02:05:15
Thanks shuttle U. I Saved that to my include files i made for "advanced" colorfinding :).
It's slow, but does the job : ). Though, for my purpose i can skip 10 pixels all the time, to make it faster, that way i got the function i have made pretty fast.
I'll try yours later =). Thanks again!
~caused
/E: I Think you could make it more efficient, if you'd count MSX2 -1, after every loop, that way, it would only search 1 pixel a time, not the whole row from "current position" to end.
Shuttleu
2009-07-04 02:09:54
From: caused
Thanks shuttle U. I Saved that to my include files i made for "advanced" colorfinding :).
It's slow, but does the job : ). Though, for my purpose i can skip 10 pixels all the time, to make it faster, that way i got the function i have made pretty fast.
I'll try yours later =). Thanks again!
~caused
if you want it to skip 10 at a time then do this
FindColorReverse(var x, y: Integer; Color: Integer): Boolean;
var
i, j: Integer;
begin
for i:=MSY2-1 downto MSY1 do
begin
for j:=MSX2-1 downto MSX1 do
begin
Result:= FindColor(x, y, Color, j, i, MSX2, MSY2);
if Result then break;
j:= j - 9;
end;
if Result then break;
end;
end;
:)
~shut
caused
2009-07-04 02:12:32
Thanks!, yeah i figured something similar out, and also edited my post above with another Idea to make it quicker =)
Shuttleu
2009-07-04 02:17:37
using your other idea
FindColorReverse(var x, y: Integer; Color: Integer): Boolean;
var
i, j: Integer;
begin
for i:=MSY2 downto MSY1 do
begin
for j:=MSX2 downto MSX1 do
begin
Result:= (GetColor(j, i) = Color);
if Result then
begin
x:= j;
y:= i;
break;
end;
end;
if Result then break;
end;
end;
~shut
caused
2009-07-04 03:01:14
Oh, yeah, that does the Job.
Thanks for the effort, Shuttleu! =)