We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want to create a processing app which first asks the user to choose an image he has on his computer, and then executes the program with that image. What want is something like a window to pop when the app starts which lets you select a image of your choice, which then is put in the data folder. How would I do this?
Answers
https://processing.org/reference/selectInput_.html
hint
also set a marker if the image was already loaded
in
draw()
if the image was not loaded : wait
if the image was already loaded proceed with the program
Thanks for the quick response!! Thats exactly what I needed. I'm quite new to processing so I don't understand it completely. How exactly do I "use" the image after I've done this function? Normally I would just have specified the image and could have done something like this
image(img, 0, 0); filter(GRAY);
How do I do this with a image selected by the user?
@Bob123 you create some var= Image img; and assign it to your selected image (by user) then (some boolean, imageSelected) you can use it in draw() as you have done...
img = loadImage( theNameThatHasBeenEntered );
I mean: selectInput does not return anything (void). How do I assign a variable from that function? I'd be really happy if someone could post an example : )
I tried adding these two lines to be to view the image
size(300,300); image(img, 0, 0);
I put them in setup() right under "selectInput". But an error code comes up "NullPointerExeption" What have I done wrong?
oh dear
you lack some basic understanding
is this exam / homework of some sort?
I wrote all this in my first post.....
see above....
;-)
No its not homework. I usually programm arduino, and I need this for an arduino project. Unfortunatly I haven't got a lot of experience with processing. (As you may have noticed.) Sorry if Im bit slow. So what have I done wrong? Is it the missing "marker"?
yes the missing "marker"
it is just a boolean I called imageSelected in my example
but you need
we don't have a way to do something when user hits cancel but never mind