SRL Archive - Help and Support

Script pick color?


Main

2009-09-12 07:20:02

:sasmokin:

JAD

2009-09-12 07:24:10

GetColor returns an integer (the color), not a true/false boolean.


var color: Integer;

color := Getcolor(x,y);

It is used many times with a boolean like:

if(GetColor(x,y) = 29385263)then

That is probably why you were thinking this.

Main

2009-09-12 07:25:31

Thanks.
BTW, where can I find the file that contains all the "findcolorspiral..","findbitmaptolerancein" function/procedures?
I looked through the includes and the tutorials, couldn't find a .scar file that contains them.

TRiLeZ

2009-09-12 07:30:42

From: Main_Ftw
Thanks.
BTW, where can I find the file that contains all the "findcolorspiral..","findbitmaptolerancein" function/procedures?
I looked through the includes and the tutorials, couldn't find a .scar file that contains them.


Those functions are in SCAR.

JAD

2009-09-12 07:32:52

Press F1 in SCAR. It opens up the manual with all that stuff.

Edit:

Color, bitmap searching and related functions

function LoadBitmap(path: string): Integer;
Loads bitmap (*.bmp) in memory and returns handle to it. Path can be absolute or relative if starts with a dot.
Example:
somepic := LoadBitmap('.\somepic.bmp');

procedure FreeBitmap(bitmap: Integer);
Releases a bitmap and frees the memory.

function BitmapFromString(Width, Height: Integer; data: string): Integer;
Loads bitmap in memory from string data and returns handle to it. (Older method)

function BitmapFromString2(Validate: Boolean; str: string): Integer;
Loads bitmap in memory from string data and returns handle to it. Data strings can be created by clicking menu Tools > Picture To String. If validate is true it'll validate the bitmap.

function BitmapFromMem(Dc: HDC): Integer;
Loads bitmap into the memory from a HDC of another bitmap in the memory.

function CreateBitmapMaskFromText(Text: string; Chars: Integer): Integer;
Creates mask image from text that can be used for searching text. Chars specifies font number returned by LoadChars2 or LoadCharsFromFont2.

function CreateBitmapFromText(Text: string; Chars: Integer; TextColor: Integer): Integer;
Creates mask image from text with a certain color that can be used for searching text. Chars specifies font number returned by LoadChars2 or LoadCharsFromFont2.

function CreateMirroredBitmap(bitmap: Integer): Integer;
Creates mirror image from another bitmap.

function GetColor(x, y: Integer): Integer;
Return color number at x, y.

function GetColors(Coords: TPointArray): TIntegerArray;
Works like GetColor, but allows you to get the color of several points, specified by Coords.

function FindColor(var x, y: Integer; color, xs, ys, xe, ye: Integer): Boolean;
Find color in box specified by xs, ys, xe, ye starting from left to right. Returns True if color found, the coordinates of the color if found is put in x,y.

function FindColorTolerance(var x, y: Integer; color, xs, ys, xe, ye: Integer; Tolerance: Integer): Boolean;
Works like the regular FindColor function 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.

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.

function FindColorSpiral2(var x, y: Integer; color, xs, ys, xe, ye: Integer): Boolean;
Find color just like FindColorSpiral, and if there is a big spot of that color then it finds the center of it.

function FindColoredAreaTolerance(var x, y: Integer; color, xs, ys, xe, ye: Integer; MinArea, Tolerance: Integer): Boolean;
Works similar to FindColorTolerance but instead of finding just 1 colored pixel and storing the coordinates into x and y, it finds an area where the colored pixel was found and stores a random coordinate according to the entered MinArea value into x,y. MinArea is specified by the count of pixels it has in an area. To find area in size 10X10 you would enter 100 as MinArea.

function FindColorSkipBox(var x, y: Integer; color, x1, y1, x2, y2: Integer; SkipBox: TBox): Boolean;
Finds a color in an area specified by x1, y1, x2 and y2, while skipping the area specified by the TBox, SkipBox.

If you'd be using a non-spiral findcolor function, the dot in the green area would be found first, but since it is in the green area which is the part where the skipbox overlaps the search area, it will ignore it, so the other dot will be found.

function FindColorSkipBoxTolerance(var x, y: Integer; color, x1, y1, x2, y2, Tolerance: Integer; SkipBox: TBox): Boolean;
Works like the regular FindColorSkipBox function 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.

function FindColorSkipBoxArray(var x, y: Integer; color, x1, y1, x2, y2: Integer; SkipBoxes: TBoxArray): Boolean;
Finds a color in an area specified by x1, y1, x2 and y2, while skipping the areas specified by the TBoxArray, SkipBoxes.

function FindColorSkipBoxArrayTolerance(var x, y: Integer; color, x1, y1, x2, y2, Tolerance: Integer; SkipBoxes: TBoxArray): Boolean;
Works like the regular FindColorSkipBoxArray function 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.

function FindColorSkipCoords(var x, y: Integer; color, x1, y1, x2, y2: Integer; SkipCoords: TPointArray): Boolean;
Finds a color in an area specified by x1, y1, x2 and y2, while skipping the coordinates specified by SkipCoords.

function FindColorSkipCoordsTolerance(var x, y: Integer; color, x1, y1, x2, y2, Tolerance: Integer; SkipCoords: TPointArray): Boolean;
Works like the regular FindColorSkipCoords function 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.

function FindColorCircle(var x, y: Integer; color, mx, my, r: Integer): Boolean;
Finds a color in a circular area specified by a set of coordinates for the midpoint (mx, my) and a radius specified by r.

function FindColorCircleTolerance(var x, y: Integer; color, mx, my, r, Tolerance: Integer): Boolean;
Works like the regular FindColorCircle function 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.

function FindColorTriangle(var x, y: Integer; color, x1, y1, x2, y2, x3, y3: Integer): Boolean;
Finds a color in a triangle defined by 3 points (x1, y1), (x2, y2) and(x3, y3). If the function returns true then the color was found. The coordinates of the found color are returned in x, y.

function FindColorTriangleTolerance(var x, y: Integer; color, x1, y1, x2, y2, x3, y3, Tolerance: Integer): Boolean;
Works like the regular FindColorTriangle function 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.

function GetBitmapAreaColors(xs, ys, xe, ye: Integer): T2DIntArray;
Returns the colors of the area specified by the points (xs, ys) and (xe, ye) in a 2 dimensional integer array.

function CountColor(Color, x1, y1, x2, y2: Integer): Integer;
Counts the instances found of Color in the area specified by x1, y1, x2 and y2.

function CountColorTolerance(Color, x1, y1, x2, y2, Tolerance: Integer): Integer;
Works like the regular CountColor function 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.

function FindColorComp(var x, y: Integer; Comp: Variant; CompType: TColorComp; xs, ys, xe, ye: Integer; Tolerance: Extended): Boolean;
Finds a certain component in the same way as FindColor(Tolerance) finds a color. You can define which colorcomponent you want to search with the CompType paramater (ccRed, ccGreen, ccBlue, ccHue, ccSat, ccLum) and you enter the value of the component you're looking for in the parameter Comp.

function FindBitmap(Bitmap: Integer; var x, y: Integer): Boolean;
Search for the bitmap in client window. If found coordinates are returned in x,y. bitmap contains handle to bitmap generated by LoadBitmap.

function FindBitmapTolerance(Bitmap: Integer; var x, y: Integer; Tol: Integer): Boolean;
Works like FindBitmap but with a tolerance parameter for finding any similar colored bitmap. Tolerance is used to find a colored bitmap in range of the bitmap you are looking for. The greater color range you want, the higher the tolerance parameter should be.

function FindBitmapIn(Bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer): Boolean;
Search for the bitmap in coordinates specified by x1, y1, x2, y2. Bitmap contains handle to bitmap generated by LoadBitmap.

function FindBitmapToleranceIn(Bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; tolerance: Integer): Boolean;
Works like FindBitmapIn but with a tolerance parameter for finding any similar colored bitmap. Tolerance is used to find a colored bitmap in range of the bitmap you are looking for. The greater color range you want, the higher the tolerance parameter should be.

function FindTransparentBitmap(Bitmap: Integer; var x, y: Integer; TranspCol, x1, y1, x2, y2: Integer): Boolean;
Search for the bitmap in coordinates specified by x1, y1, x2, y2. Bitmap contains handle to bitmap generated by LoadBitmap. The function will match any color for the the transparent color on the bitmap you're trying to find which is entered in the TranspCol variable.

function FindTransparentBitmapTolerance(Bitmap: Integer; var x, y: Integer; TranspCol, x1, y1, x2, y2: Integer; tolerance: Integer): Boolean;
Works like FindTransparentBitmap but with a tolerance parameter for finding any similar colored bitmap. Tolerance is used to find a colored bitmap in range of the bitmap you are looking for. The greater color range you want, the higher the tolerance parameter should be.

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.

function FindBitmapSpiralTolerance(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; Tolerance: Integer): Boolean;
Works like FindBitmapSpiral but with a tolerance parameter for finding any similar colored bitmap. Tolerance is used to find a colored bitmap in range of the bitmap you are looking for. The greater color range you want, the higher the tolerance parameter should be.

function FindBitmapMaskTolerance(mask: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; Tolerance, ContourTolerance: Integer): Boolean;
Essentially it works like FindBitmapIn except it identifies using the masks/shape of an object in the bitmap. Masks are specified by the colors black and white. ContourTolerance is the minimal tolerance for color difference between shape of a mask and the background in a bitmap, It makes sure the shape differs from the background.
<-- sample mask for finding letter A in any color.

function FindDeformedBitmapToleranceIn(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; tolerance: Integer; Range: Integer; AllowPartialAccuracy: Boolean; var accuracy: Extended): Boolean;
Works similar to FindBitmapToleranceIn but allows searching for partially covered or transformed bitmaps. If range is 0, it checks pixels at positions that match bitmap we are looking for; if Range ir 1, it checks neighbor pixels as well, if range is bigger, it checks further. AllowPartialAccuracy allows accuracy that is not 100% match. accuracy returns accuracy of found bitmap to bitmap we are looking for. accuracy = 1.0 means it was 100% perfect match.
Example: we are searching for .
1. Target bitmap:
FindDeformedBitmapToleranceIn(b, x, y, 0, 0, 100, 100, 70, 0, True, acc);
Results: acc = 0.825745682889
FindDeformedBitmapToleranceIn(b, x, y, 0, 0, 100, 100, 70, 1, True, acc);
Results: acc = 1.000000000000
2. Target bitmap:
FindDeformedBitmapToleranceIn(b, x, y, 0, 0, 100, 100, 70, 0, True, acc);
acc = 0.585557299843
FindDeformedBitmapToleranceIn(b, x, y, 0, 0, 100, 100, 70, 1, True, acc);
acc = 0.751962323391

function FindDeformedBitmapToleranceRotationIn(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; tolerance: Integer; Range: Integer; var accuracy: Extended; AngleIntervals: Extended; StartAngle, MaxAngle: Extended; var angle: Extended): Boolean;
Works similar to FindDeformedBitmapToleranceIn but allows searching for rotated bitmaps as well. Basically it rotates bitmap, searches in target image, then rotates again, searches again. AngleIntervals specifies by how much it rotates every time, StartAndge specifies initial rotation angle, MaxAngle specifies how far it rotates and angle returns angle of found image. All angles are specified in radians (Pi = 180&#730;)
Example:
FindDeformedBitmapToleranceRotationIn(minimaptree, x, y, 582, 37, 700, 117, 170, 0, acc, PI/10, 0, 2*PI, angle);

function FindBitmapRotated(bitmap: Integer; var x, y, Angle: Integer; x1, y1, x2, y2: Integer): Boolean;
Works like FindBitmap, but rotates the bitmap after each search by 1 degree and returns the angle of the found bitmap afterwards.

function RotateBitmap(bitmap: Integer; angle: Extended): Integer;
Rotates bitmap by specified angle in radians (Pi = 180&#730;);

function SimilarColors(col1, col2, tolerance: Integer): Boolean;
Function to test weather two colors are within tolerance range. If they are within range, it returns true, if not false.

procedure PickColor(var Color: TColor; var X, Y: Integer);
This command allows color to be picked directly from script. Color returns color picked and x, y returns coordinates the color was picked at.

function FindColors(var Points: TPointArray; Color, xs, ys, xe, ye, Tol: Integer): Boolean;
Finds all colors in the area specified by xs, ys, xe, ye and returns their coordinates in Points. Will return True if any colors are found.

function FindColorsTolerance(var Points: TPointArray; Color, xs, ys, xe, ye, Tol: Integer): Boolean;
Finds all colors with tolerance in the area specified by xs, ys, xe, ye and returns their coordinates in Points. Will return True if any colors are found.

procedure FindColorsSpiralTolerance(x, y: Integer; var Points: TPointArray; color, xs, ys, xe, ye: Integer; Tolerance: Integer);
Finds all colors in area specified by xs, ys, xe, ye and returns their coordinates into Points.

function FindBitmaps(Bitmap: Integer; var Points: TPointArray; xs, ys, xe, ye: Integer): Boolean;
Returns the coordinates of all instances of the entered Bitmap found in the search area in the Points array.

function FindBitmapsTolerance(Bitmap: Integer; var Points: TPointArray; xs, ys, xe, ye, Tol: Integer): Boolean;
Returns the coordinates of all instances of the entered Bitmap found with tolerance in the search area in the Points array.

function FindTransparentBitmaps(Bitmap: Integer; var Points: TPointArray; TranspCol, xs, ys, xe, ye, Tol: Integer): Boolean;
Returns the coordinates of all instances of the entered Bitmap found in the search area in the Points array. Pixels on the search Bitmap with the color defined by TranspCol will be skipped in the search.

function FindTransparentBitmapsTolerance(Bitmap: Integer; var Points: TPointArray; TranspCol, xs, ys, xe, ye, Tol: Integer): Boolean;
Returns the coordinates of all instances of the entered Bitmap found with tolerance in the search area in the Points array. Pixels on the search Bitmap with the color defined by TranspCol will be skipped in the search.

function CountBitmap(Bitmap: Integer; xs, ys, xe, ye: Integer): Integer;
Counts the number of instances of the entered Bitmap found in the search area.

function CountBitmapTolerance(Bitmap: Integer; xs, ys, xe, ye, Tol: Integer): Integer;
Counts the number of instances of the entered Bitmap found with tolerance in the search area.

function CountTransparentBitmap(Bitmap: Integer; TranspCol, xs, ys, xe, ye: Integer): Integer;
Counts the number of instances of the entered Bitmap found in the search area. Pixels on the search Bitmap with the color defined by TranspCol will be skipped in the search.

function CountTransparentBitmapTolerance(Bitmap: Integer; TranspCol, xs, ys, xe, ye, Tol: Integer): Integer;
Counts the number of instances of the entered Bitmap found with tolerance in the search area. Pixels on the search Bitmap with the color defined by TranspCol will be skipped in the search.

procedure GetBitmapSize(Bitmap: Integer; var Width, Height: Integer);
Returns the size of the entered Bitmap in Width and Height.

function BitmapToString(Bmp: Integer): string;
Returns a bitmapstring for the entered bitmap.

Main

2009-09-12 07:33:18

EDIT:
Ty