Py5Image

Py5Image#

Datatype for storing images.

Examples#

example picture for Py5Image

def setup():
    global photo
    photo = py5.load_image("laDefense.jpg")


def draw():
    py5.image(photo, 0, 0)

Description#

Datatype for storing images. Py5 can load .gif, .jpg, .tga, and .png images using the load_image() function. Py5 can also convert common Python image objects using the convert_image() function. Images may be displayed in 2D and 3D space. The Py5Image class contains fields for the Py5Image.width and Py5Image.height of the image, as well as arrays called Py5Image.pixels[] and Py5Image.np_pixels[] that contain the values for every pixel in the image. The methods described below allow easy access to the image’s pixels and alpha channel and simplify the process of compositing.

Before using the Py5Image.pixels[] array, be sure to use the Py5Image.load_pixels() method on the image to make sure that the pixel data is properly loaded. Similarly, be sure to use the Py5Image.load_np_pixels() method on the image before using the Py5Image.np_pixels[] array.

To create a new image, use the create_image() function. Do not use the syntax Py5Image().

Underlying Processing class: PImage

The following methods and fields are provided:

Updated on March 06, 2023 02:49:26am UTC