Py5Image.load_pixels()#

Loads the pixel data for the image into its Py5Image.pixels[] array.

Examples#

example picture for load_pixels()
 1def setup():
 2    global my_image
 3    global half_image
 4    half_image = py5.width * py5.height//2
 5    my_image = py5.load_image("apples.jpg")
 6    my_image.load_pixels()
 7    for i in range(0, half_image):
 8        my_image.pixels[i+half_image] = my_image.pixels[i]
 9
10    my_image.update_pixels()
11
12
13def draw():
14    py5.image(my_image, 0, 0)

Description#

Loads the pixel data for the image into its Py5Image.pixels[] array. This function must always be called before reading from or writing to Py5Image.pixels[].

Underlying Processing method: PImage.loadPixels

Syntax#

load_pixels() -> None

Updated on November 12, 2021 11:30:58am UTC