2015년 1월 3일 토요일

How to create a button to save the drawing in paintpot app ?


I have a question. I am creating an application of paint, similar to paintpot tutorial, I would like to create a button to save the picture drawn in the gallery, I'm more hard to do it. Can anyone help me? 

I'm using MIT App Inventor 2 in Windows 7 Ultimate platform, using Google Chrome.

--

Hello,
What you want to do is save the canvas.  The canvas is the control amd surface you are drawing on.  Here is a link to Save the Canvas  .  The blocks there show  how to use a button and save your creation.  You will use a TinyDB control.   Try this, it is not too difficult.

After you work with the example and include it in your example, please return here and let us know if this suggestion answered your question.

--

Thanks Steve !

Worked perfectly, thanks for the help. 

I'm new in App Inventor, and did not know the DB Tyne. 

Until next time! 

--

Thank you very much Clever for letting us know all is working fine.  :)

Have fun with AI2 and your projects.

--
Thank you so much for the link to save the canvas.
I had trouble finding the 'call TinyDB.get value' function (bottom purple).  I looked under TinyDB but couldn't find one that fit in the notch.
Any help would be appreciated!

--

The button2 image on the right might be what you are trying to do, it a variation on the Canvas save hint:

If you save a png or jpg image to the database with TinyDB, the object you connect it to must be compatible...in this case a Canvas or Image object, both of which accept image files.  

Did this answer your question?    Please let us know.    If this example did not answer your question, please post some blocks.   Thank you.

--
Yes, the purple function on the right is what I'm looking for.  (attached)
I checked under canvas list but still couldn't find the same function.
I've attached a screenshot of my only options in TinyDB.
I'm sure it's right under my nose - I feel so stupid.
I really appreciate your help!



--
@ Vasha  ---  Your problems is this; there is a component calledTinyDB.  There is another component called TinyWebDB.   You are looking for the TinyDB in the TinyWebDB control selections.  You have to first put a TinyDB  component on to your Design screen before you can find the TinyDB blocks on the Blocks screen.  Check to see if your project has a TinyDB screen.    Does it.  If so, you should now be able to find the component.

Were you successful?

--
Doh!  I didn't know about the TinyWebDB.  Works like a charm now.  Thank you so much!

--
With this example, will the image be saved to my phone as a file that I can send to others?

--
With this example, will the image be saved to my phone as a file that I can send to others?
yes

--
Where does it get saved? I cannot find it.

--
If you save an image using the TinyDB, the image gets saved in the AppInventor folder on my tables; specifically   AppInventor/storage/emulated/o/AppInventor/assets  on my Tablet, it might be a diffeent place on your phone.


The TinyDB itself only stores text.  The TinyDB stores the path to the images and the images themselves are stored in the AppINventor folder.   Actually, all the resources for any AI2 app on your 
device is stored there I believe.  That means there might be files from various app there, not only your PaintPot app.

Look for the image in the AppInventor folder that should be on your phone.  Did you find your stored images?

@ Taifun .... is this true.   If not please correct me.

--
if you use this example How to save a canvas
the image will be stored in the root directory of your SD card
feel free to add a directory, for example file: MyDirectory/MyCanvas.png

edited by Taifun: for the path do not use "file:///mnt/sdcard" here...

--
So if I use image picker, will it show up in my gallery? If not, how do I do that?

Taifun wrote:

if you use this example How to save a canvas
the image will be stored in the root directory of your SD card
feel free to add a directory, for example file:///mnt/sdcard/MyDirectory/MyCanvas.png

--
The file directory did not work, it just randomly created its own folder in my sd card. Any advice?

--
it works without the file:///mnt/sdcard...

--
Can't see the pic

--
@Muneeb: It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

--

댓글 1개:

  1. Question... Why my saved canvas imaged dont appear con my gallery... I always have to restar my phone.

    답글삭제