Janilabo Posted September 9, 2012 Share Posted September 9, 2012 (edited) IsTextIn (improved/updated version of IsTextInArea) function IsTextIn(XS, YS, XE, YE: Integer; var x, y: Integer; S: string; Tolerance, Chars: Integer; TextColor: Integer): Boolean; var b: TSCARBitmap; begin if ((S <> '') and (XS < XE) and (YS < YE)) then case ((TextColor < 1) or (TextColor > 16777215)) of True: try b := CreateBitmapMaskFromText(S, Chars); Result := FindBitmapMaskTolerance(b, x, y, XS, YS, XE, YE, Tolerance, 0); b.Free; except end; False: try b := CreateBitmapFromText(S, Chars, TextColor); b.TranspColor := 0; Result := FindBitmapTol(x, y, b, XS, YS, XE, YE, Tolerance); b.Free; except end; end; end; FindText function FindText(var X, Y: Integer; S: string; Chars, TextColor, XS, YS, XE, YE, Tol: Integer): Boolean; var b: TSCARBitmap; begin if ((S <> '') and (XS < XE) and (YS < YE)) then begin try case (TextColor <= 0) of True: begin b := CreateBitmapFromText(S, Chars, clWhite); ReplaceColor(b, 0, 65280); ReplaceColor(b, clWhite, TextColor); b.TranspColor := 65280; end; False: begin b := CreateBitmapFromText(S, Chars, TextColor); b.TranspColor := 0; end; end; Result := FindBitmapTol(X, Y, b, XS, YS, XE, YE, Tol); b.Free; except end; end; end; FindTextEx function FindTextEx(var TPA: TPointArray; S: string; Chars, TextColor, XS, YS, XE, YE, Tol: Integer): Boolean; var b: TSCARBitmap; begin if ((S <> '') and (XS < XE) and (YS < YE)) then begin try case (TextColor <= 0) of True: begin b := CreateBitmapFromText(S, Chars, clWhite); ReplaceColor(b, 0, 65280); ReplaceColor(b, clWhite, TextColor); b.TranspColor := 65280; end; False: begin b := CreateBitmapFromText(S, Chars, TextColor); b.TranspColor := 0; end; end; Result := FindBitmapTolEx(TPA, b, XS, YS, XE, YE, Tol); b.Free; except end; end; end; Edited September 12, 2012 by Janilabo Updated the function - removed some unused variables. Added FindText(Ex). Quote Link to comment Share on other sites More sharing options...
BryceTheCoder Posted September 10, 2012 Share Posted September 10, 2012 lol alot of stuff to be put in this function:P XS, YS, XE, YE: Integer; var x, y: Integer; S: string; Tolerance, Chars: Integer; MinSpacing, MaxSpacing, TextColor: Integer but still good function, goodjob:) Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted September 11, 2012 Share Posted September 11, 2012 Man, i was going to make a function like this but the ones i keep coming up with took tolong to find anything if the area was any size. Whats the time lik with this one? Quote Link to comment Share on other sites More sharing options...
Janilabo Posted September 12, 2012 Author Share Posted September 12, 2012 Man, i was going to make a function like this but the ones i keep coming up with took tolong to find anything if the area was any size. Whats the time lik with this one?Hey shadow mate, these functions work very quickly, because they are based on Freddy's/SCAR's fast bitmap finding functions. Speed is just fine, but there is downside though; these need fonts that doesn't contain any randomized spacing between characters of the text you are looking for (good example would be RuneScape uptext).. Updated the topic: Deleted MinSpacing/MaxSpacing, because they were useless here. Also, added FindText and FindTextEx. -Jani Quote Link to comment Share on other sites More sharing options...
LordJashin Posted September 12, 2012 Share Posted September 12, 2012 Hey shadow mate, these functions work very quickly, because they are based on Freddy's/SCAR's fast bitmap finding functions. Speed is just fine, but there is downside though; these need fonts that doesn't contain any randomized spacing between characters of the text you are looking for (good example would be RuneScape uptext).. Updated the topic: Deleted MinSpacing/MaxSpacing, because they were useless here. Also, added FindText and FindTextEx. -Jani Nice! Good idea to make these anew/new and use Bitmap functions! FindTextEx was my only contribution to SRL ... You could in theory do max and min spacing and some other things. But it would be a complex operation. Adding and taking away black space only between the white colors or something like that . Quote Link to comment Share on other sites More sharing options...