We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey guys, I'm trying to display and image as my background in the void setup()
but it shows me the ArrayIndexOutOfBoundException: Coordinate out of bounds! error.
However, when I use background(img);
in the void draw()
, it works.
PImage sourceImg;
int dw, dh;
void setup () {
sourceImg = loadImage("test2.jpg");
surface.setResizable(true);
dw = sourceImg.width;
dh = sourceImg.height;
surface.setSize(dw, dh);
background(sourceImg); //HERE IT GIVES ME THE ERROR
}
void draw() {
//background(sourceImg); //HERE IT WORKS
}
I don't know how to fix this. I need the background image to be drawn one time at the start of the program. What does that error mean?
Thx in advance!
Answers
This next should fix it pending Processing version (I believe).
Kf
To access surface:
Kf
https://forum.Processing.org/two/discussion/18033/how-to-set-processing-to-automatically-detect-an-image-size-and-set-it-as-a-background
https://forum.Processing.org/two/discussion/16705/null-pointer-exception-when-loading-image-in-settings-p3-1-1#Item_1
Thanks guys!