Introduction
ZPE 1.6.4 (August 2018) completely redesigns the manner in which images are used in ZPE. Instead of defining them as a native type within the language and runtime environment images are now simply encapsulated within ZPEObjects.
What this allows for is more consistent and concise syntaxes and a more object oriented way of handling them. The 'image object syntax' as it is now known helps handle this better.
The following guide shows the core functionalities of the image object, better known by it's internal name as the Image.
Image object functions
The following is a list of internal functions the Image object exposes. All functions are ZPEObjectNativeFunctions unless specified therefore run in native code.
-
new_image
(integer width, integer height) ⇒ object - Creates a new image and stores it within the object.
-
open
(string file) ⇒ object -
Opens an image from a specified file and puts in to the current object. The image can then be manipulated
using the language functionalities. It will return
false
if the file could not be found. -
save
(string file) ⇒ object - Saves the image to a file path, file. The format is decided based on the extension.
-
transform_greyscale
() ⇒ object - Transforms the image with the greyscale filter.
-
transform_sepia
() ⇒ object - Transforms the image with the sepia filter.
-
transform_invert_colour
() ⇒ object - Transforms the image with the inverted colour filter.
-
transform_resize
(integer width, integer height) ⇒ object - Resizes the image to the specified width and height parameters.
-
transform_rotate
(integer degrees) ⇒ object - Takes in an image and rotates the image to the specified degrees.
-
get_width
() ⇒ object - Returns the width dimension of the image.
-
image_get_height
() ⇒ object - Returns the height dimension of the image.
-
get_pixel
(integer x_coordinate, integer y_coordinate, [boolean associative]) ⇒ list - Returns a list which contains information about a single pixel. The list will contain the red (r), green (g), blue (b) and alpha data. If the associative variable is given a true value, the array will instead become an associative array: {r => red_value, g => green_value, b => blue_value, a => alpha_value}.
-
image_set_pixel
(integer x_coordinate, integer y_coordinate, list color) ⇒ object - This function sets a pixel in the image. If the set pixel operation fails, it returns the boolean value false. If the set pixel operation succeeds, it return the image. Any operation should be prepared for failure.
-
base64_encode
() ⇒ string -
Return a base64 encoding of the image.
Added in 1.7.8
-
screen_grab
() ⇒ object - Captures the screen of the computer at the point when the command is issued and stores it within the current image object.
-
display
() ⇒ object - Displays the image.
Prior to version 1.7.4
Prior to version 1.7.4 the built-in generate_image
function was used to create
an image object. The function was a simple one - it's job was to create an
image object with an image of some specified parameters. This image is a simple
placeholder or can be used for drawing on to (future versions).
An image is generated using the functions described on the generate_image function page.