Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-06-2011, 03:09 AM   #1
goJohnnyGo
Registered User
 
Join Date: Sep 2011
Posts: 1
Default How to Save Full Resolution Image Back to CameraRoll (Android)

Device: Nexus One
OS: Android 2.3.4
Class: CameraRoll
Error: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="Error #2038: File I/O Error." errorID=2038]

I'm trying to develop a photo app but am having problems saving the full sized version of the image back to the CameraRoll. This is very frustrating as I've only seen examples saving the stage to CameraRoll (which I can get to work).

Is there a limitation to saving back to CameraRoll?? When I try to load an image (2592 x 1944) and save it directly back to CameraRoll using addBitmapData(), I get the following error.

[ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="Error #2038: File I/O Error." errorID=2038]

Here's a code sample.

Code:
// class vars for CameraRoll and Loader
private var _cameraRoll:CameraRoll = new CameraRoll();
private var _loader:Loader = new Loader();

// launch _cameraRoll
private function launchCameraRoll(e:MouseEvent):void {
     _cameraRoll.addEventListener(MediaEvent.SELECT, loadImg);
     _cameraRoll.browseForImage();
}

// open selected image using _loader
private function loadImg(e:MediaEvent):void {
     if (e.data.isAsync) {
          _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadImgError);
          _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, saveImage);
          _loader.loadFilePromise(e.data);
     } else {
          _loader.loadFilePromise(e.data);
          saveImage();
     }
}

// once loaded, save image immediately back to _cameraRoll
private function saveImage(e:Event = null):void {
     _cameraRoll.addEventListener(ErrorEvent.ERROR, onError);
     _cameraRoll.addEventListener(Event.COMPLETE, onComplete);
    
     var bmd:BitmapData = new BitmapData(_loader.width, _loader.height);    
     bmd.draw(_loader);
    
     _cameraRoll.addBitmapData(bmd);
}
 
// trace error
private function onError(e:ErrorEvent):void {
     trace(e);  // [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="Error #2038: File I/O Error." errorID=2038]
}
 
// show complete status
private function onComplete(e:Event):void {
     trace("complete");
}
goJohnnyGo is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:49 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.