Skip navigation
Currently Being Moderated

cameraRoll addBitmapData file name

Sep 26, 2011 6:18 AM

How do I get the file name of the image created by addBitmapData?

 

I'm capturing an image of a multiTouch drawing with this ...

   var cameraRoll:CameraRoll = new CameraRoll(); 

                                        var bitmapData:BitmapData = new BitmapData(bc.width, bc.height);

                                        bitmapData.draw(bc);

                                        cameraRoll.addBitmapData(bitmapData);

 

When addBitmapData is complete, I need to receive the file name back so I can display back the resulting captured image.

 

Researching the docs, it doesn't look like there is a complete event for addBitmapData.

 

Thanks,

Don

 
Replies
  • Currently Being Moderated
    Jan 19, 2012 3:54 AM   in reply to Don Kerr

    I have the same problem and can not find a solution. Created image is stored in the camera roll, but how to get the link (path) to the saved image?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 19, 2012 6:00 AM   in reply to Don Kerr

    This is not working for me. I do so.

     

    protected function saveCameraRoll(event:MouseEvent):void{

      var cr:CameraRoll = new CameraRoll();

                                            cr.addEventListener(Event.COMPLETE, onComplite);

                                            cr.addBitmapData(bitmapData);

                                  }

                                  protected function onComplite(event:Event):void

                                  {

                                            var cDir:String = File.documentsDirectory.resolvePath("DCIM/Camera/").nativePath;

                                            var cameraDir:File = new File(cDir);

                                            var files:Array = cameraDir.getDirectoryListing();

     

                                            var newFile:File = new File();

                                            newFile = files[files.length-1];

     

                                            var newPhoto:Object = new Object();

                                            newPhoto.fileName = newFile.name;

                                            newPhoto.url = newFile.url;

     

                                            navigator.pushView(views.ShareImageView, newPhoto);

                                  }

     

    In next view I want to display created image and send it by mail.

     

    [Bindable]

                                  protected var imgPath:String;

                                  protected var loader:Loader;

     

    protected function shareBtn_clickHandler(event:MouseEvent):void

                                  {

                                            AndroidExtensions.shareImage(imgPath, "Share:");

                                  }

     

                                  protected function onCreationCompleteHandler(event:FlexEvent):void

                                  {

     

                                            if(!loader)

                                            {

                                                      loader = new Loader();

                                                      loader.load(new URLRequest(data.url));

                                                      loader.contentLoaderInfo.addEventListener(Ev ent.COMPLETE, onLoadComplete);

                                            }

                                  }

     

     

                                  protected function onLoadComplete(e:Event) : void

                                  {

                                            imgPath = data.url;

                                            img.source = loader.content;

                                            shareBtn.enabled = true;

                                  }

     

    <s:BitmapImage id="img" width="100%" height="100%" fillMode="scale" scaleMode="letterbox"/>

    <s:Button id="shareBtn" label="Share" click="shareBtn_clickHandler(event)" enabled="false"/>

     

    As a result, display another image which is obtained the latter with the camera.

    And when i send the mail to the link data.url() did not attach anything. If i select an image from the gallery by cr.browseForImage() it works fine.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 19, 2012 7:36 AM   in reply to Don Kerr

    If I save the image in the gallery with CameraRoll using the code above, then I get the link to this image: newPhoto.url = newFile.url; // file:///mnt/sdcard/DCIM/Camera/20120119_112543.jpg 

     

    But it is quite another picture. My right image, which I saved with help cr.addBitmapData(bitmapData), have another link - /mnt/sdcard/DCIM/Camera/132700152384.jpg.

    I get this link if i call browseForImage() for my image. The problem is not in the path and that created images are missing in the files:Array

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 19, 2012 7:57 AM   in reply to Don Kerr

    Very strange...

    All my images created with addBitmapData displayed in the gallery, in the file system manager, but they do not come in an array getDirectoryListing (), they are not there.

    No matter how much I create new images, the array length remains the same. Miracles.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 19, 2012 8:28 AM   in reply to Don Kerr

    Add one line and all work fine! Thank you Don Kerr!

     

    var files:Array = new Array();

                                            files = cameraDir.getDirectoryListing();

                                            files.sortOn("creationDate", Array.NUMERIC); // sorting array

                                            var newFile:File = new File();

                                            newFile = files[files.length-1] as File;

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 15, 2012 3:08 PM   in reply to Don Kerr

    Any reason the share image wouldn't work in Flash Pro swf compiled with ADT?  I have the toast from the same extension working without issue.  I have the URL coming back accurately but when the AndroidExtensions.shareImage(imgPath, "Share:"); is called, nothing happens. 

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 16, 2012 6:45 AM   in reply to mola2alex

    I can't even seem to get the simplest example from that extension to work.  The toast from the same extension works without issue but share mechanism doesn't.  Not sure if there is something that makes it only work on Flex...

     

    AndroidExtensions.shareText(“My Subject”, “My Text”, “Share:”);

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 16, 2012 9:47 AM   in reply to mola2alex

    I figured out my error, didnt remove the old ANE from the compile directory when updated the ANE that supported image sharing.  Only issue I have now is that I can share with every servcie except gmail.  It shows it as attached but never sends it.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points