Saving image to device
Right now AIR is not capable to save an image directly to iOS photo or Android Gallery. Usually developers have to open the image in a web browser for the user to download.
We have added the `saveToCameraRoll` function to be able to save a bitmap data instance to an image in the user’s camera roll.
Cheers
-
Nice work! Would you mind sharing some code for people to see how to do this?
-
Michael Cizenski commented
FYI, I was able to make the header portion work w/ AS3 only. I open the Android created image (with all the exif goodies intact) and write ONLY the header information into a separate byteArray. Then after I create encode the new bitmap image, I simply write the image header byteArray + new Image byteArray into my new file. Fast and efficient and I don't have to actually decode/parse the exif information.
-
Good ideas, I'll have a look into keeping the EXIF data for you.
Regarding the simulator fall back, shouldn't be too hard for us to drop the normal png/jpg as3 encoders in there. I'll make sure that goes into the next release
-
Michael Cizenski commented
When you make the next addition to the image ane would it be possible to allow it to also work on MAC/PC in the simulator using the already available jpg/png encoder as a fallback?
-
Michael Cizenski commented
I was wondering how the image encoder handles metadata from pictures. For example, right now if users take a picture I can save the bitmap directly and it will have the EXIF data intact.
Some of my users want to have a stamp on the picture so I can take their image information and draw another image on top and encode the new image, no problem. The issue is that the EXIF information from the original bitmap data is now lost.Perhaps we can have the image encoder accept an optional bitmap data object and an X,Y coord and it will overlay the image before encoding AND keep the original camera's EXIF Data. It would also be super if we could modify some of the EXIF fields like comments and keywords.
-
Antoine Mouquod commented
I've been using the File Class to do that kind of data storage (BitmapData > ByteArray > File).
Not super easy though and an extension could help a lot of people I guess. :) -
Correct, you can just save it to the camera roll, our extension was created out of a need to save a BitmapData to another path. You can use this to store temp images or create directories separate from the camera roll to store images.
-
Antoine Mouquod commented
Actually you can already with flash.media.CameraRoll; (at least on Android)
And something like :if (CameraRoll.supportsAddBitmapData){
cameraRoll.addEventListener(Event.COMPLETE, onAddComplete);
cameraRoll.addEventListener(ErrorEvent.ERROR, onAddError);
cameraRoll.addBitmapData(myBitmapData);
}onAddComplete and onAddError are just listeners to know when it's done.