( begin auto-generated from loadImage.xml )
Loads an image into a variable of type PImage
. Four types of
images ( .gif
) images may
be loaded. To load correctly, images must be located in the data
directory of the current sketch. In most cases, load all images in
to preload them at the start of the program. Loading
images inside draw()
will reduce the speed of a program.
parameter can also be a URL to a file found
online. For security reasons, a Processing sketch found online can only
download files from the same server from which it came. Getting around
this restriction requires a signed
parameter is used to determine the image type in
cases where the image filename does not end with a proper extension.
Specify the extension as the second parameter to loadImage()
shown in the third example on this page.
an image is not loaded successfully, the null
returned and an error message will be printed to the console. The error
message does not halt the program, however the null value may cause a
NullPointerException if your code does not check whether the value
returned from loadImage()
on the type of error, a PImage
object may still be
returned, but the width and height of the image will be set to -1. This
happens if bad image data is returned or cannot be decoded properly.
Sometimes this happens with image URLs that produce a 403 error or that
redirect to a password prompt, because loadImage()
to interpret the HTML as image data.
( end auto-generated )