Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
komradus
komradus's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
loadImage() with Android causes fatal exception
[1 Reply]
06-May-2013 01:57 AM
Forum:
Android Processing
So I'm trying to get a sketch for android load and then draw an image.
But when I run on my device, this happens:
FATAL EXCEPTION: Animation Thread
java.lang.IllegalArgumentException: File resources/cannon.png contains a path separator
at android.app.ContextImpl.makeFilename(ContextImpl.java:1660)
at android.app.ContextImpl.getFileStreamPath(ContextImpl.java:812)
at android.content.ContextWrapper.getFileStreamPath(ContextWrapper.java:175)
at processing.core.PApplet.sketchPath(Unknown Source)
at processing.core.PApplet.createInputRaw(Unknown Source)
at processing.core.PApplet.createInput(Unknown Source)
at processing.core.PApplet.loadImage(Unknown Source)
at processing.test.imagetest.ImageTest.setup(ImageTest.java:30)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphicsAndroid2D.requestDraw(PGraphicsAndroid2D.java:169)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:856)
And my code looks like this:
PImage img;
void setup ()
{
size(200, 200);
img = loadImage("resources/cannon.png");
}
void draw ()
{
image(img, 0, 0, width, height);
}
My file structure has a folder in the sketch's directory called "resources" with a file called "cannon.png" inside.
When I tried moving "cannon.png" right next to the (only) .pde file and changing line 6 to be:
img = loadImage("cannon.png");
I get a null pointer exception saying that "cannon.png" cannot be found.
What is going on and how can I get around this?
«Prev
Next »
Moderate user : komradus
Forum