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 & HelpSyntax Questions › problem with loadImage on Windows XP
Page Index Toggle Pages: 1
problem with loadImage on Windows XP (Read 745 times)
problem with loadImage on Windows XP
Oct 3rd, 2005, 5:54pm
 
I am helping a student run the following lines of code:

size(400, 400);
PImage bg = loadImage("image.jpg");
background(bg);

and these error messages come up:

java.lang.RuntimeException: openStream() could not open image.jpg
    at processsing.core.PApplet.die(PApplet.java:1811)
    at processsing.core.PApplet.die(PApplet.java:1829)
    at processsing.core.PApplet.openStream(PApplet.java:3212)
    at processsing.core.PApplet.loadBytes(PApplet.java:3219)
    at processsing.core.PApplet.loadImage(PApplet.java:2710)
    at processsing.core.PApplet.loadImage(PApplet.java:2704)
   at Temporary_6984_3108.setup(Temporary_6984_3108.java:3)
   at processsing.core.PApplet.display(PApplet.java:1050)
   at processsing.core.PGraphics.requestDisplay(PGraphics.java:362)
   at processsing.core.PApplet.run(PApplet.java:951)
   at java.lang.Thread.run(Unknown Source)

She is running Windows XP, with Java installed.  The image is a jpg, cropped to 400x400 pixels.

The program runs fine on a Mac, and loads the image properly

Other processing sketches (as long as an image isn't trying to load) run fine on this machine.

Thanks

Doug Easterly
Re: problem with loadImage on Windows XP
Reply #1 - Oct 3rd, 2005, 6:44pm
 

I know this sounds obvious, but is the image stored in the data folder?

looks to me as though the error is to do with locating the file.
Re: problem with loadImage on Windows XP
Reply #2 - Oct 10th, 2005, 4:51pm
 
yeah - the first thing i checked was to make sure that her image was a jpeg, scaled to the same size as the sketch window, and that it was saved inside of her sketch folder.
Re: problem with loadImage on Windows XP
Reply #3 - Oct 10th, 2005, 5:07pm
 
i'm guessing it has to do with the fact that processing has trouble loading images outside setup()

so this should work:
PImage bg;
void setup()
{
size(400, 400);
noLoop();
bg = loadImage("image.jpg");
}
void draw()
{
background(bg);
}

-seltar
Re: problem with loadImage on Windows XP
Reply #4 - Oct 10th, 2005, 7:29pm
 
nah, cuz a program run in "static" mode is effectively the same as the entire program being smooshed inside setup().

could you post the sketch so we can try on another windows machine? it almost sounds as though there's something screwed up with her java installation if no images are loading properly.
Page Index Toggle Pages: 1