We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Good evening,
I made a program for downloading images, the problem is I can not save them in an orderly way. when I have an image is no problem with the order, but my idea is to deal with over 300 different images and I want a quick program.
I want to create folders with different categories.
However although I get to do what I want in java, I fail in android.
What I can do?
this code work:
PImage a;
void setup(){ a = loadImage("http://img110.xooimage.com/files/4/5/b/mini-robot-4a0c8b8.png");
if(a != null){a.loadPixels();
a.save("aadfg.png");
}}
void draw(){if(a != null){a.loadPixels();image(a,20,20);}}
but, this code don´t work:
PImage a;
void setup(){ a = loadImage("http://img110.xooimage.com/files/4/5/b/mini-robot-4a0c8b8.png");
if(a != null){a.loadPixels();
a.save("folder/aadfg.png");
}}
void draw(){if(a != null){a.loadPixels();image(a,20,20);}}
this is the difference:
a.save("aadfg.png");
**||**
a.save("folder/aadfg.png");
regards and thanks in advance.
Answers
@anthony20::
you cannot do what you want in android mode with processing; each android app has a very precise structure with prefab folders which have always the same names; you can see that in eclipse. So if you want to save the files in # folders,the files and folders have to be created by coding and put on the internal or external storage sdcard, according to your needs & security permissions from the device and its system
@akenaton
thanks for answer. How I can create a new folder on the internal storage of the app, I access the folder to save an image and finally to access that folder to load that image at any time? Do you can show me a sample code?
@anthony20:: -some example code; could be more sophisticated looking to the existing (or not folders...) -dont forget permissions write/read
@akenaton Thanks for help me:
I can not do work your code. Errors persist.
But I found another solution that apparently works, although it will be quite laborious to apply this solution to my app.
@anthony20:: the twos codes are exactly the same except that a) you are saving inside the app package, like a library, and not in the sdcard; that is your choice (you cannot see or change the files with ddms...) b) you create a folder ("folder") and i assumed that the folder exists already, see my post "could be more sophisticated looking to the existing (or not folders...)"
@akenaton
I am try use your code:
Manifiest: <?xml version="1.0"?>
I need some additional permission?
the error is probably that the folder "myFolder" does not exist; in that case you have to create it like in your code; PS: not sure at all that it is a good idea to download while saving! - you have probably to make a runnable. Try that (permissions + some image in your data folder with the same name)
Hi @akenaton Thanks so much for help me:
The mistake was that this had not permissions of Intenet, the picture is not loaded and was an exception to be null and try to save it.
I now have two solutions, I will try to use the internal storage, as this does not require additional permissions.
@ anthony20 ::: as for me sdcard is better because you can SEE what happens at any time, even after having exported the app...
thanks for the advice and help @akenaton
I've successfully adapted my code of download images to android. I created several features that allow automatically create folders and it seems that saved the 200 images is neat, quick and correct.
Now it is the hardest part, which is to make everything work properly within the main app.
does someone know how to safe a picture taken from a camera
@mathijsvann=== supposing that you have taken the photo (eg: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE)) you have only to add an extra to the intent (intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri) and fix the fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); after that you can use the same code i have given to anthony20 for saving either on the standard folders created by android or elsewhere...