1

I'm new to Processing and I'm studying it using the Processing Handbook. I have this example code :

PImage img;

void setUp() {
  size(200, 200);
  img = loadImage("selfportrait_small.jpg");
}

void draw() {
  background(255);
  tint(255, 102);
  image(img, 0, 0, 200, 200);
  tint(255, 102, 0, 204);
  image(img, 40, 40, 200, 200);
}

When I try to run it I get a NullPointerException in the first call to image(). As you can see in the image below, the jpg file is stored in the data folder: Processing project

Am I missing something? Is there something wrong I'm not able to see?

Thanks for help.

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107

1 Answers1

2

Yes you wrote "setUp" and not "setup" :-) Since setUp() is never called the image is never loaded.

Alberto89
  • 356
  • 2
  • 6