MonkeyImage

    You do not need to create new instances of MonkeyImage. Instead, use to create a new instance from a screenshot. For example, use:




    ## Public methods




    #### string convertToBytes ( string format)




    Converts the current image to a particular format and returns it as a string that you can then access as an iterable of binary bytes.




    ##### Arguments


    format The desired output format. All of the common raster output formats are supported. The default value is "png" (Portable Network Graphics).

    tuple getRawPixel (integer x, integer y)

    Returns the single pixel at the image location (x,y), as an a tuple of integer, in the form (a,r,g,b).

    Arguments
    Returns
    • A tuple of integers representing the pixel, in the form (a,r,g,b) where a is the alpha channel value, and r, g, and b are the red, green, and blue values, respectively.

    tuple getRawPixelInt (integer x, integer y)

    Returns the single pixel at the image location (x,y), as an an integer. Use this method to economize on memory.

    Arguments
    x The horizontal position of the pixel, starting with 0 at the left of the screen in the orientation it had when the screenshot was taken.
    y The vertical position of the pixel, starting with 0 at the top of the screen in the orientation it had when the screenshot was taken.
    Returns
    • The a,r,g, and b values of the pixel as 8-bit values combined into a 32-bit integer, with a as the leftmost 8 bits, r the next rightmost, and so forth.

    MonkeyImage getSubImage (tuple rect)

    Creates a new MonkeyImage object from a rectangular selection of the current image.

    Arguments
    Returns

    boolean sameAs ( MonkeyImage otherImage, float percent )

    Compares this object to another and returns the result of the comparison. The percent argument specifies the percentage difference that is allowed for the two images to be "equal".

    Arguments
    other Another MonkeyImage object to compare to this one.
    percent A float in the range 0.0 to 1.0, inclusive, indicating the percentage of pixels that need to be the same for the method to return true. The default is 1.0, indicating that all the pixels must match.
    Returns
    • Boolean true if the images match, or boolean false otherwise.

    void writeToFile (string filename, string format)

    Writes the current image to the file specified by , in the format specified by format.

    Arguments