We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there!,
I was trying to use the selectInput
for loading an image in processing android mode and it didn't work. I also tried to use the SelectFile library, which is unfortunately not working with the latest processing.
any other libraries or methods to dynamically load image?
Any help would be much appreciated!
Thanks in advance :)
Answers
@yousufalin===
i am not sure to understand what you want: is it a file chooser dialog in order that the user can choose a file???
Then: is this file supposed to be anywhere on the device (gallery ...sd card) OR is this file supposed to be in your app???
@akenaton, Thank you for your reply.
you got the question right! . I would like to create a button which will allow me to load the image from my sdcard/gallery.
:)
@yousufalin===
in this case you can use an intent with action getContent.
@akenaton thank you for the clue.
I am completely new to android stuff.. Was reading through some of the posts in StackOverFlow.. I was able to write only the following part
with this code, I am able to access my device to search for images. But I don't know how to select an image from the gallery and load it as the image in
image(img,0,0);
@yousufalin===
you are on the good way! - Now=
add createChooser to your startActivityForResult()
add a method onActivityResult()
in this method get the path (URI) to the selected image with a cursor
load the image (from the URI) and do something with it
i give you only the guideline but i think that is better than complete code for learning
problems you probably have:
The code is not exactly) the same if you are targetting API<18 or >18
Android knows about Bitmaps, not about PImage and you have to look at Bitmaps in android docs, though i think (without having never done that) that there is a way to "translate" bitmaps into PImage
In order to put your bitmap on screen you have to create an imageView.
Try and tell me...
usage:
PImage img[] = loadImages("photos");
This example load entire "photos" folder from assets of APK
@erkosone===
of course && i do know as this is the code i have given on this forum...But that is NOT what @yusufalin was asking: select input and let the user choose an object...