Loading...
Logo
Processing Forum

PImage: loadImage not defined

Answered
  • Need more info
  • Answered
  • Working on it
in Integration and Hardware  •  3 years ago  
I'm using Eclipse with processing 1.2.1, and I can't seem to access PImage's loadImage method. I have imported the .jar successfully into the build path, and I have been able to run the other examples in the tutorials without a hitch.
Copy code
  1. import processing.core.*;
  2. public class Test {
  3.       void setup() {
  4.             PImage img = loadImage("test.jpg", "jpg");
  5.       }
  6. }
On line 4, "loadImage" is underlined red. The error reads:
The method loadImage(String, String) is undefined for the type Test 
I've also tried doing it other ways, e.g.:
Copy code
  1. PImage img; //also tried PImage img = new PImage();
  2. img = loadImage("test.jpg", "jpg");
I also tried these without the second parameter (which should not make a difference anyway if I read the documentation correctly). Same result with anything I try... It just doesn't seem to resolve PImage's loadImage method.

Replies(2)

I just noticed that the documentation specifies to use createImage() instead of new PImage(). I tried the following:
Copy code
  1. ...
  2. PImage img = createImage(604, 453, "RGB");
  3. ...
But I got the error: 
The method createImage(int, int, String) is undefined for the type Test
It seems almost as if it's not even resolving the PImage class at all... It is, however, because I don't receive any error when declaring the PImage object (I would expect "PImage cannot be resolved to a type" if that were the case).
Well, I feel dumb. Forgot to do this when I started writing the class:
Copy code
  1. public class Test extends PApplet {
I also needed a visibility for the setup function, and some other obvious stuff.