Save image to disk

Monkey Forums/Monkey Beginners/Save image to disk

My_Fat_Fox(Posted 2015) [#1]
I want to save an rgb array as an image file to the sdcard on an Android device, and I'm struggling to figure out how to do this.

Can anyone suggest the easiest way to save a file in this way? I also want to be able to email the image file, but that's another project, perhaps.

Converting an image array to a bitmap files I can manage, it's saving it somewhere that is causing me a headache.

I have played with the filesystem module, and it works, saving and loading data from test.bin, but I think it's just a virtual file system that doesn't save to a file anywhere accessible by other software, which doesn't help me much.

Any suggestions would be gratefully received.


degac(Posted 2015) [#2]
Hi

I found something about an 'external' protocol for Android (I must admit it is a long time I don't touch Monkey... so this is just new even for me)

here an example

So it (seems) possible to save 'outside' the app.
Another thing is 'convert' your data-array in a .JPG or .PNG standard format.
I think there are around source code to convert in Monkey.

ps: I haven't found any information on the documentation about 'external'... so I don't know if it is/was something experimental or not...


Pierrou(Posted 2015) [#3]
Is Mark's answer at the bottom of this topic http://www.monkey-x.com/Community/posts.php?topic=5074&post=67956
what you are looking for?
It works fine for me when I need to import or export text files.


My_Fat_Fox(Posted 2015) [#4]
Thanks degac and Pierrou, both those suggestions look very promising.
I'll play around, see how it goes and report back here.


My_Fat_Fox(Posted 2015) [#5]
Filestream works perfectly to save and load files from an Android device (Kindle) sdcard when I import both brl.json and brl.filestream and refer to "monkey://external/filename.txt".

I also wanted to create a directory on the Kindle when the app is first installed or on first run and found that importing the brl.filesystem namespace allows me to use CreateDir("monkey://external/dirname").

Thanks again!


degac(Posted 2015) [#6]
Thanks to you to give us a feedback and more informations about the 'real' use of this.
This weekend I want to play around this feature.

ps: btw Kindle or Amazon Fire?


My_Fat_Fox(Posted 2015) [#7]
It's a Kindle Fire HD.