We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › using loadImage outside of the PApplet object
Page Index Toggle Pages: 1
using loadImage outside of the PApplet object (Read 1376 times)
using loadImage outside of the PApplet object
Jul 20th, 2005, 11:50am
 
Is there a way of using loadImage outside of the PApplet object?

I have libraries/howto.txt which I belive may be telling me what to do (??) but I did't get it (a bit new to java and oo).
I am making an package... I want to do something like this (but in a working way).

package foo;
import processing.core.*;

public class fool {

private PImage image;

public fool()
{
  image = new PImage();
  image = loadImage("foo.jpg");
}

public PImage getImage()
{
  return image;
}

}
Re: using loadImage outside of the PApplet object
Reply #1 - Jul 20th, 2005, 12:34pm
 
your class will need to have access to a PApplet instance in order to use its loadImage() method. you can achieve that by passing in a PApplet to the constructor of your class or pass in an PImage directly (instead of loading it from your class)

Code:
 package foo;
import processing.core.*;

public class Fool {
private PImage image;

public Fool(PApplet parent) {
image = new PImage();
image = parent.loadImage("foo.jpg");
}

public PImage getImage()
{
return image;
}
}


then use like this:

Code:
Fool me;

void setup() {
me=new Fool(this);
}
Re: using loadImage outside of the PApplet object
Reply #2 - Jul 20th, 2005, 1:24pm
 
thanks!
Page Index Toggle Pages: 1