Class ImageUtils
A class for image utilities, such as OCR, image comparisons, and image find operations.
public class ImageUtils
- Inheritance
-
ImageUtils
- Inherited Members
Constructors
ImageUtils()
public ImageUtils()
Methods
CompareImages(Image, Image, ImageMaskArea, byte, byte)
Checks whether the defined mask areas within two images match, given the specified pixel and RGB tolerance values.
public static bool CompareImages(Image firstImage, Image secondImage, ImageMaskArea maskArea, byte pixelTolerance = 0, byte rgbTolerance = 0)
Parameters
firstImageImageThe expected image.
secondImageImageThe image to compare to the expected image.
maskAreaImageMaskAreaThe mask area within the two images to use for the comparison.
pixelTolerancebyteOptional. The percentage of pixels that can differ between the two mask areas, and still be considered a match. Default = 0.
rgbTolerancebyteOptional. The percent by which the RGB values of the pixels in the two images can differ, and still be considered a match. Default = 0.
Returns
Remarks
Returns true only if the mask areas match and the two provided images are the same size.
CompareImages(Image, Image, byte, byte)
Checks whether two images are a match, given the specified pixel and RGB tolerance values.
public static bool CompareImages(Image firstImage, Image secondImage, byte pixelTolerance = 0, byte rgbTolerance = 0)
Parameters
firstImageImageThe expected image.
secondImageImageThe image to compare to the expected image.
pixelTolerancebyteOptional. The percentage of pixels that can differ between the two images, and still be considered a match. Default = 0.
rgbTolerancebyteOptional. The percent by which the RGB values of the pixels in the two images can differ, and still be considered a match. Default = 0.
Returns
GetImageLocations(Image, Image, byte)
Returns the first 100 locations of an image inside the source image. If the number of images found exceeds 100 images, a GeneralReplayException is thrown.
public static Point[] GetImageLocations(Image sourceImage, Image imageToFind, byte similarity = 100)
Parameters
sourceImageImageThe source image to check.
imageToFindImageThe image to locate within the sourceImage.
similaritybyteOptional. The minimum similarity (as a percentage) above which the find is considered successful. Default = 100.
Returns
- Point[]
GetText(Image)
Returns all text within the supplied image.
public static string GetText(Image image)
Parameters
imageImageThe image to use for the search.
Returns
GetText(Image, Rectangle)
Returns all text within the supplied rectangle inside the supplied image.
public static string GetText(Image image, Rectangle textArea)
Parameters
imageImageThe image to use for the search.
textAreaRectangleAn inner rectangle within the image.
Returns
LocateImage(Image, Image, byte)
Locates an image inside the provided source image.
public static Point? LocateImage(Image sourceImage, Image imageToFind, byte similarity = 100)
Parameters
sourceImageImageThe source image to check.
imageToFindImageThe image to locate within the sourceImage.
similaritybyteOptional. The minimum similarity (as a percentage) above which the find is considered successful. Default = 100.
Returns
LocateText(Image, string)
Returns all rectangle areas within the supplied image that contain the specified text.
public static Rectangle[] LocateText(Image image, string textToFind)
Parameters
Returns
LocateText(Image, string, Rectangle)
Returns all rectangle areas within the supplied rectangle that contain the specified text.
public static Rectangle[] LocateText(Image image, string textToFind, Rectangle textArea)
Parameters
imageImageThe image to use for the search.
textToFindstringThe text string to find.
textAreaRectangleAn inner rectangle within the image.