Hi, I have a Android Processing sketch that used to work a few years ago but I need to update it and can’t get it to run. It seems like there is a problem with having the path in the filename string but this used to work…
for (int i=0; i<numFrames; i++) {
String imageName = "sequences/" + basename + "_pixelData/pixelData" + nf(i, 5) + ".png";
imageSequence[i] = loadImage(imageName);
println("Image "+imageName+" was loaded as "+imageSequence[i]);
}
Any idea how to work around this problem? Ideally I would like to keep my code as is and figure out how to make it run on my device.
Thanks
Phil
FATAL EXCEPTION: GLThread 787
Process: processing.test.pixelpetal_v09, PID: 1579
java.lang.IllegalArgumentException: File sequences/allseq_pixelData/pixelData00000.png contains a path separator
at android.app.ContextImpl.makeFilename(ContextImpl.java:2366)
at android.app.ContextImpl.getFileStreamPath(ContextImpl.java:1120)
at android.content.ContextWrapper.getFileStreamPath(ContextWrapper.java:191)
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.pixelpetal_v09.pixelpetal_v09.loadImageSequence(pixelpetal_v09.java:96)
at processing.test.pixelpetal_v09.pixelpetal_v09.setup(pixelpetal_v09.java:116)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
This is the fileSeparator standard issue (and i have already put answers for it in the “old” forum); till your images are in the data folder at the first level loadImage() works but if you are using subfolders it fires this error ; in order to get rid of it you have to use android AssetManager and list your subfolders (or folders/subfolders…): it will return an array of all the files inside them and so you can get your image using loadImage(myarray[i]). Of course i suppose that your images are not in the external sd card but in your app!
@Andres This is a suggestion of how to handle files with dataPath(). @Akenaton has a good point with his approach. I have a suggestion in the above link. I have to think a little bit harder to see how it could be implemented in the source code, to be able to use dataPath the same way as in processing Java.
You would need to put together an MCVE to be able to reproduce the problem. Maybe check if you are working your images too much. For instance, are you actively resizing your images in draw()? Are you loading files in this function? Very hard to make suggestions without seeing your actual code.