Py5Image.load_np_pixels()#
Loads the pixel data of the image into the Py5Image.np_pixels[] array.
Examples#
def setup():
my_image = py5.load_image("apples.jpg")
my_image.load_np_pixels()
my_image.np_pixels[:50, :, :] = my_image.np_pixels[50:100, :, :]
my_image.update_np_pixels()
py5.image(my_image, 0, 0)
Description#
Loads the pixel data of the image into the Py5Image.np_pixels[] array. This method must always be called before reading from or writing to Py5Image.np_pixels[]. Subsequent changes to the image will not be reflected in Py5Image.np_pixels[] until py5image_load_np_pixels()
is called again.
The load_np_pixels()
method is similar to Py5Image.load_pixels() in that load_np_pixels()
must be called before reading from or writing to Py5Image.np_pixels[] just as Py5Image.load_pixels() must be called before reading from or writing to Py5Image.pixels[].
Note that load_np_pixels()
will as a side effect call Py5Image.load_pixels(), so if your code needs to read Py5Image.np_pixels[] and Py5Image.pixels[] simultaneously, there is no need for a separate call to Py5Image.load_pixels(). However, be aware that modifying both Py5Image.np_pixels[] and Py5Image.pixels[] simultaneously will likely result in the updates to Py5Image.pixels[] being discarded.
Signatures#
load_np_pixels() -> None
Updated on March 06, 2023 02:49:26am UTC