Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use file FROM the phone #134

Open
Turtlemod opened this issue Mar 30, 2024 · 7 comments
Open

How do I use file FROM the phone #134

Turtlemod opened this issue Mar 30, 2024 · 7 comments

Comments

@Turtlemod
Copy link

I'm trying to make something to find an image on the phone (eg. Test.jpg) and as far as the reference goes I can use the file path, but either I don't know the path or doing somthing wrong

This is my code so far

PImage webImg;

void setup() {
size(400,400);
String url = "/Testfolder/Test.jpg";

webImg = loadImage(url);
}

void draw() {
background(0);

image(webImg, 0, 0);

}

@FlamingFury321
Copy link

Are you on Android? If so: /storage/emulated/0/testfolder/ would be your path

@Turtlemod
Copy link
Author

Turtlemod commented Mar 31, 2024

PImage webImg;

void setup() {
size(400,400);
String url = "/storage/emulated/0/testfolder/test.jpg";
// Load image from a web server
webImg = loadImage(url);
}

void draw() {
background(0);
image(webImg, 0, 0);
}

I tried it and it still crashed the sketch and I am on Android

@Turtlemod
Copy link
Author

It says all of this

Failed to delete old APK file
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:152)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:239)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:279)
at java.io.BufferedInputStream.read(BufferedInputStream.java:338)
at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:1044)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:961)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:1076)
at processing.core.PApplet.loadImage(PApplet.java:3992)
at processing.test.testingimages.testingimages.setup(testingimages.java:25)
at processing.core.PApplet.handleDraw(PApplet.java:1801)
at processing.core.PSurfaceNone.callDraw(PSurfaceNone.java:471)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:503)
Could not load the image because the bitmap was empty.
java.lang.NullPointerException: Attempt to read from field 'int processing.core.PImage.width' on a null object reference in method 'void processing.core.PGraphics.image(processing.core.PImage, float, float)'
at processing.core.PGraphics.image(PGraphics.java:2843)
at processing.core.PApplet.image(PApplet.java:8707)
at processing.test.testingimages.testingimages.draw(testingimages.java:30)
at processing.core.PApplet.handleDraw(PApplet.java:1818)
at processing.core.PSurfaceNone.callDraw(PSurfaceNone.java:471)

@FlamingFury321
Copy link

FlamingFury321 commented Mar 31, 2024

The images have to be placed inside Sketchbook -> Projectfolder -> data. So you should use: loadImage("test.jpg").
Under Settings -> General you can choose the sketchbook location:
Screenshot_20240331_233940_APDE.jpg

@Turtlemod
Copy link
Author

But I want to use photos from anywhere on the phone by just renaming or moving it to a not data folder

@Leamucho
Copy link

Hey @Turtlemod , in plain processing you would do it like this for the '"just outside" folder named '0texts'

"../0texts/m3.txt"

I mean you aren't putting stuff inside 'data' but on a folder called '0texts' that is one level up the folder of your sketch, so you have, '0texts' with your sketch folder besides on the same level.
I think you can use '../../ **' to go up more levels, but I'm not that much unoccupied to test that for you, sorry... good luck

@Turtlemod
Copy link
Author

@Leamucho
By same level you mean like this

Screenshot_20240429_101230_Cx File Explorer.jpg

And just to clarify I want to use the "testfolder" to hold images and then this uses it

Screenshot_20240429_101710_APDE.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants