Download and save picture in FB4 / AIR app

I have download and display an Image successfully in a Flash Builder 4 / AIR application.

The application also saves the ByteArray downloaded to a local drive.

protected function creationCompleteHandler( event:FlexEvent ):void
{
     var loader:Loader = new Loader();
     var file:File = new File();
     loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
     var request:URLRequest = new URLRequest( "http://. . . /01-Cafe.jpg" );
     loader.load( request );
}

private function imageLoaded( event:Event ):void
{
     // displaying the image
     this.testImg.source = event.target.content;

     // saving the image file
     var fs:FileStream = new FileStream();
     var path:File = new File( File.desktopDirectory.nativePath + File.separator + "01-Cafe.jpg" );
     fs.openAsync( path, FileMode.WRITE );
     fs.writeBytes( event.target.bytes, 0, event.target.bytes.bytesAvailable );
     fs.close();
}

try to open the file saved in Photoshop CS4 gives the following error:

"Could not complete your request because we find a unknown or invalid JPEG marker."

IrfanView open the file in a Flash drive.

The application that saved the file can load and display.

What does the download data to the JPEG file?

How to save a JPEG file valid since the ByteArray Loader?

Thank you

David

> This is incorrect.

Sorry, my mistake. I meant .bitmapData Bitmap (event.target.content). It will take only a convert JPG JPGEncoder.

Interesting to know that LoaderInfo.bytes has extra bytes at the beginning.

Is that what you could not only use URLLoader to get bytes from the JPG, save that bytearray another before passing on Loader.loadBytes to display the image?

See you soon,.

Rémy

Tags: Flash Builder

Similar Questions

  • why I can't download and save the files to my laptop... it disappears in the air... I have windows vista and ie8... Please help I'm going crazy... this laptop is my tool work... thank you. __

    why I can't download and save the files to my laptop... it disappears in the air... I have windows vista and ie8... Please help I'm going crazy... this laptop is my work tool... Thank you.

    Hello locness2411,

    Have you checked your download folder? Also you can put where you want to save a file to the desktop as, for example. Take a look at these links: http://www.tweaklibrary.com/Software_Applications/Internet-Explorer/27/Set-default-download-path-of-Internet-Explorer/10153/ or http://www.windowsreference.com/internet-explorer/how-to-change-the-default-download-directory-for-internet-explorer/ that can help you in what you want to change. Hope this helps you. Let us know anyway. Make it a great day!

    "And in the end the love you take, is equal to The Love You Make" (The Beatles last song from their latest album, Abbey Road.)

  • How to download and save a file mp3 songs or movies

    How to download and save a file mp3 songs or movies

    Hello

    a lot of songs and movies have taken your ability to simply download the site now. If you want to search for the download of instructions on individual Web sites. (Amazon.com example) However, the best way to download is the right click on a pic/song/video/file and select Save.

    calculation of the happy,

    B Eddie

  • Download and save videa clips of DP on PC card

    I have a camcorder with a PYD card. I can plug the camera on PC and watch the clips but when I try and save and store I get the message that says that Windows cannot open them in Media Player. They will not be displayed in the library or any where that I can play the pictures - if I can play the sound. Help please.

    I have a camcorder with a PYD card. I can plug the camera on PC and watch the clips but when I try and save and store I get the message that says that Windows cannot open them in Media Player. They will not be displayed in the library or any where that I can play the pictures - if I can play the sound. Help please.

    ====================================
    What is the brand and model of your camcorder?

    What is a PYD card?

    What is the (extension) format of video clips?

    Looks like the format of your video clips
    not compatible with Windows Media Player.

    You can download and install a more versatile
    Media player, or you can consider converting
    video clips to a more universal format.

    Another option would be to download and install
    a codec Pack.

  • How to download and save an audio file?

    I am trying to download audio (MP3) files that have been sent to me in zip files. Once I click on the link to download provided by the sender, the link download and I can then open it on my computer and unzip the file, showing the different MP3 files. But when I click on the file, there are no options that allow me to save on my computer. I just get an audio square, and then he just started playing. Any suggestions?

    Thank you

    Keith

    Drag and drop one of your regular files, or even on your desktop?

    But why are you asking in a help forum for an email client?

  • Download Helper - how to download and save files .wmv WITHOUT the video being downloaded reading on screen?

    Windows 7 Pro
    Latest Version of Firefox
    Latest Version of Download Helper
    Windows Media Player and VLC are installed

    When I download a video file (.wmv, usually) the video starts to play on the screen of the monitor prior to my being able to use Download Helper to download the video and save it on the hard drive. This generally translates the video stopping and playing and stopping the process of download because of the speed of download available. There is never any problem with the final download hard disk.

    Today I installed the latest version of Firefox and Download Helper on another computer.
    Windows 7
    Latest Version of Firefox
    Latest Version of Download Helper
    Windows Media Player (not) is installed

    Downloaded the same .wmv file you downloaded above and the video started to play on the screen of the monitor. Download Helper has allowed me to download the file on the disk hard WITHOUT constantly tuned to the video start/stop/start/stop etc.

    Which option (in which program) would allow playback of the video to be turned on and off all by downloading the .wmv file?

    Thank you.

    Once the download has started, you can go to another web page. The
    Download must be a separate function.

  • How to download and send pictures of Web sites

    original title: stumped!
    My question is heard elementary to most of you here, but I'm a newcomer to these things that we called computers. My question is this, when I see a photo on a site Web how do I email this picture to someone else? I recently saw a photo that was on MSNBC that showed the northern lights to wash on a boat in Norway and I wanted to send this photo to my father. There was a little red button part, said on this subject and I clicked on which he brought a box that says E-mail of... and then send an e-mail to... and when I filled it and clicked on send, nothing happened! Please tell me what I'm doing wrong. Thanks for any help you can give me

    Hi Scorpio012,
    First off don't worry, everyone starts as a beginner. The important thing is to learn how to identify what you need and how to ask.
    OK you can do that two ways.
    1. you can right click on the image and a small menu appears. The options provided should be 'save' or ' save under.
    If you click on it and save the image on your computer (you choose where you place), then you can open your e-mail program and send it as an attachment as usual.
    2. some sites, you cannot upload photos so that they allow you to use the option you have described.
    After selecting sharing and enter all the information, make sure everything is filled out. You should get a popup message that the message was sent.

    B Eddie

  • How to download and install the emulator ripple signed App from a Web site

    I've packed with success and sign my application using emulator of ripple. After the packaging and signing process completed three directories were created in my corresponding output directory. Directories are listed below:

    OTAInstall

    StandardInstall

    ApplicationNameDirectory

    In the OTAInstall directory, there are 18 files (files with the following extensions: cod, jad, and 1 - 16.cod)

    In the StandardInstall directory, there are 4 files (files with the following extensions: alx, cod, csi, cso)

    In the ApplicationNameDirectory directory, there is a copy of the original of the application

    My question is which files should I put on my site for visitors can download and install the application on a Blackberry smartphone.

    Any help is appreciated

    Thanks in advance

    WS1

    Well, since I'm testing with friends, I downloaded all in a folder and then told them to click on the jad file.  They were able to see all the files even if, as the record was available.

    The jad file contains app and author info and BB will automatically download the cod files when the user clicks on download.  Are you talking about a link in a web page well?  If so, see this:

    http://StackOverflow.com/questions/7531174/how-to-provide-JAD-file-download-link

    and

    http://StackOverflow.com/questions/3725989/providing-JAD-file-download-link

  • Download and save audio and video files

    Hello

    I am trying to record audio and video files that are larger than 5 MB in size.

    I open a Http connection and asking to 128 KB each time until the completion of the data transmission.

    for some files that are 1 to 2 MB code does not work well, but if you have large files MB it throws the error, ' Eception Exception: myApp Application (201) does not; process is completed"

    How can I fix this error. I searched the forum for this error, I found some funda but has not found a solution.

    AM making ala invokeAndLater() and therefore not blocking is not the eventThread.

    Here is the flow of my code that establishes the connection and starts to download.

    the following code snippet shows the flow of the code.

    // Constructor: displays a popup screen that allows the user to select a list of audio/video files for the download. 
    
    // Dictionary obj is a vector that contains list of file names.// IAudioVideoPopUp is an interface implemented by the caller. 
    
    public AudioVideoPopUp(Dictionary[] v, IAudioVideoPopUp guideIntroManager)  {     super(new VerticalFieldManager());        if( v!= null)     {         caller = guideIntroManager;           for(int i =0; i< v.length; i++)            {             btnFileNames = new MyButtonField(v[i].value.toString(), "images/button1_big.png", "images/button2_big.png",  true, Font.PLAIN, 18, v[i]);             btnFileNames.setChangeListener(new FieldChangeListener()              {                     public void fieldChanged(Field field, int context)                    {                     if(field instanceof MyButtonField)                        {                         final MyButtonField tempField = (MyButtonField) field;                            UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());                           synchronized (UiApplication.getEventLock()) {                             UiApplication.getUiApplication().invokeLater(new Runnable(){                                  public void run()                                 {                                     UiApplication.getUiApplication().pushScreen(new WaitScreen());                                        caller.onClick(((MyButtonField) tempField).getDictionaryData());                                  }                             });                           }//                           PopupCloseThread pct = new PopupCloseThread(field);//                         pct.start();                      }                 }             });               add(btnFileNames);            }
    
              btnCancel = new MyButtonField("Close", "images/button1.png", "images/button2.png", true, Font.PLAIN, 18);         btnCancel.setChangeListener(new FieldChangeListener()             {                 public void fieldChanged(Field field, int context)                {                 UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());               }         });           add(btnCancel);       }
    
       }
    
    // onClick method that was implemented in the caller. 
    
    // dictionary is a vector, contains info about the selected file in the popup.
    
    public void onClick(Dictionary dictionary)   {     if(dictionary != null)        {         switch(ContentType)           {         case 1:               playAudio(dictionary);                break;            case 2:               videoSelected(dictionary);                break;            default:              break;            }     } }
    
    // the following code calls for the downloading and saving of the file.
    
    private boolean downloadAndSaveVideo(long movieID2, String fileName, String URL, int fileSize)    {     if(URL!= null)        {         try           {             String videoFileURL = AppConstants.SDCARD+AppConstants.CONTENT_PATH+fileName;             if(new DownloadCombiner(URL, videoFileURL, 128*1024).run())               {                 return updateVideoTable(movieID2, videoFileURL);              }         }             catch (Exception e)           {             Tools.print("XCO: GuideIntroManager: downloadAndSave: Error..:" + e.toString());          }     }     return false; }
    
    // this is not a thread class. // here an repeatdly making the requests to get all the data.// please go thru the run().
    
    public DownloadCombiner(String remoteName, String localName,         /*int connection,*/ int chunksize)    {     this.remoteName = remoteName;     this.localName = localName;       this.chunksize = chunksize;   }
    
    public boolean run()     {     boolean result = false;       try       {         int chunkIndex = 0;           int totalSize = 0;
    
              /*             * File connection             */           FileConnection file = (FileConnection) Connector.open(localName);         if (!file.exists()) {             file.create();            }         file.setWritable(true);           OutputStream out = file.openOutputStream();
    
             /*             * HTTP Connections            */           String currentFile = remoteName; //+ connectionType();            Tools.Debug("Full URL: " + currentFile);          HttpConnection conn;          InputStream in;           int rangeStart = 0;           int rangeEnd = 0;         while(true)           {             Tools.Debug("Opening Chunk: " + chunkIndex);
    
                  conn = (HttpConnection) Connector.open(currentFile,Connector.READ_WRITE, true);
    
                  rangeStart = chunkIndex * chunksize;              rangeEnd = rangeStart + chunksize - 1;
    
                  Tools.Debug("Requesting Range: " + rangeStart + "-" + rangeEnd);
    
                  conn.setRequestProperty("Range", "bytes=" + rangeStart + "-"+ rangeEnd);
    
                  int responseCode = conn.getResponseCode();                if(responseCode != 200 && responseCode != 206)                {                 Tools.Debug("Response Code = " + conn.getResponseCode());                 break;                }
    
                  Tools.Debug("Retreived Range: "+ conn.getHeaderField("Content-Range"));
    
                  in = conn.openInputStream();              int length = -1;              byte[] readBlock = new byte[256];             int fileSize = 0;
    
                  while((length = in.read(readBlock)) != -1)                {                 out.write(readBlock, 0, length);                  fileSize += length;                   //Thread.yield(); // Try not to get cut off               }             totalSize += fileSize;
    
                  Tools.Debug("Chunk Downloaded: " + fileSize + " Bytes");              chunkIndex++; // index (range) increase               in.close();               conn.close();             in = null;                conn = null;              /*                 * Pause to allow connections to close and other Threads to run.               */               //Thread.sleep(1000);         }         Tools.Debug("Full file downloaded: " + totalSize + " Bytes");         if(totalSize>0)            {             result = true;                Tools.Debug("Wrote file to local storage");           }else{                result = false;               file.delete();            }         out.close();          file.close();     }         catch (Exception e)       {         result = false;           Tools.Debug(e.toString());        }
    
          return result;    }
    

    A little patience please.  Don't forget that you are awake does not mean that other people are.  I'd leave a Thread open for at least 24 hours before bumping.

    I'm sorry to tell you that invokeLater runs the executable on the wire of the event, not a separate Thread.  If you have actually started the treatment in the very thing you're trying to get away from.

    You must run the execution in DownloadCombiner treatment in a separate Thread.  This is why, in the article, which I suppose you DownloadCombiner, it extends Thread.

    Just for the record, DownloadCombiner is here:

    How - to download large files using the BlackBerry Mobile data system
    Article number: DB-00619
    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800431/How_To _...

  • Download and save a file in JDeveloper - iOS particularly

    I'm developing an application native simple iOS, using the Oracle JDeveloper .

    How can I download a file, giving a URL and store it in the storage of iOS? For example, in Android, the code to access the storage is Environment.getExternalStorageDirectory() and I can use it to download a file, a HttpURLConnection and the requestMode to GET .

    Once the JDeveloper allows you to deploy applications for Android and iOS devices, how can I make these calls? What are java classes that allow me to download and store a file? I found no information in the Oracle documentation.

    Thank you

    Will be.

    The model of Mobile ADF is provided by Oracle ADF. Download a file from a URL as in the ADF, which several references are available.

    JDeveloper, Oracle ADF & amp; Java: Download the file from the url using Oracle ADF & Java-Download Manager

    Download the file from the URL using ADF (emergency assistance required)

    ADF Code Bits: Bit #19 - downloading a file

    Oracle ADF: Download the file in ADF

  • would like to know how to download and save adobe photoshop

    How to activate and save adob photoshop cc I number of vip

    https://helpx.Adobe.com/x-productkb/global/redemption-code-help.html

    Mylenium

  • Cannot download and save files.

    I can't download anything or save. Also, I can't download driver HP Web page

    OT: I can not download from the net or save files


    Hello

    Method 1:

    To download the file in Internet Explorer:
    a. close all Windows Internet Explorer or Explorer Windows that are currently open.
    b. open Internet Explorer, click Tools and then click Internet Options.
    d. click on the Security tab , click Internetand then click on the custom level button.
    e. scroll down to the downloads category and set the file to activate download.
    f. click OK.


    Method 2:

    Run Internet explorer with no Add - ons. Steps to open Internet with no mode of modules:

    a. click on start.

    (b) in the search box, type in Internet Explorer.

    c. Select Internet (no add-on mode).

    If you are not faced with the question, then the module may cause the error.

    You can read the following article and try the steps to activate the modules individually determine which Add - ons may be the cause of the problem.

    How to manage add-ons in Internet Explorer 9


    Method 3:

    You can also temporarily disable the third-party security software, firewalls installed on the system and check if the problem persists.

    Note: Be sure to enable the security software on the computer after checking.

    Method 4:
    I suggest you delete the contents of the Internet Explorer folder and see if that helps.

    How to remove the contents of the temporary Internet files folder

    http://support.Microsoft.com/kb/260897

    Note: Reset the Internet Explorer settings can reset security settings or privacy settings that you have added to the list of Trusted Sites. Reset the Internet Explorer settings can also reset parental control settings. We recommend that you note these sites before you use the reset Internet Explorer settings.

  • Can I download and install older versions of the apps?

    My computer is very old, it does not support the operating system that is necessary to support new applications. I need to download Lightroom 4. Can I do this through creative cloud?

    Yes.

    Open the application of cc desktop > apps > find additional applications > previous versions > lr install > 4.4

  • How to save install them all the updates that Windows Update downloads and installs automatically (when the automatic update is enabled).

    My automatic update of Windows 7 did a great job, whenever I discovered a new criticism / or useful update is available on the microsoft site / or any other tech site, I always find the update is alreay installed via Windows automatic update (thanks microsoft)... but I want to save all these (the installation program updates (, of course) that I can use to update all the other windows 7 running pc with no internet connection.

    is this possible?

    My automatic update of Windows 7 did a great job, whenever I discovered a new criticism / or useful update is available on the microsoft site / or any other tech site, I always find the update is alreay installed via Windows automatic update (thanks microsoft)... but I want to save all these (the installation program updates (, of course) that I can use to update all the other windows 7 running pc with no internet connection.

    is this possible?

    Updates automatically downloaded cannot be reused. Suggest you open the link "View update history" of the icon of the Windows Update control panel and write updates have been downloaded and installed.
    Then download and save them from the Microsoft Download Center .
    Just enter the number in the field to Search All Download Center and then click on the "magnifying glass" to start the search.
    You can also change the language and geographic location by clicking on the link edit in the top right of the page.
    MowGreen MVP Data Center Management - update of safety Consumer Services

  • How to download and store the file in the device

    I need to download and save a file to the server. Can any one go code me for this example.

    Example of solution download a file via the URL: http://supportforums.blackberry.com/t5/Cascades-Development/How-to-download-zip-file-And-also-open-e...
    It stores the file in your sandbox app directory. After that you can move anywhere.

Maybe you are looking for

  • The latest version stopped my work of theme of doppelganger of firefox 3.

    The latest 16 stopped my work of theme that can be confused with firefox 3. I'm partially blind. and the new version is useless. It is too small and too dark. How can I get a Dead Ringer for firefox 3 at the top of the screen?

  • Overclocking Nvidia GeForce on my G20-129

    I installed Coolbits 2.0 on my Qosmio G20, but don't see the new menu on the settings of the graphics card. With Rivatuner, the frequencies are blocced! Someone know how to overclock the graphics card? Thank you

  • Qosmio F50 internal mic not working not

    Hello The internal mic on my Qosmio F50 has suddenly stopped working. I tried to configure, but it doesn't seem to be picking up all the sounds. I have also tried reinstalling the sound and chipset drivers but had no luck. Help, please.

  • BlackBerry 9700 smartphones and compatible applications

    I found that some applications are not compatible with the 9700. If others have found this? If so, then why and when they become available? Thank you Lewis

  • Management cancels his subscription to E10

    Hi, new to Eloqua and we do not have an experienced administrator experienced team immediately.For the moment, we use only Eloqua for capture and processing wire and send contacts in CRM. Contacts have already begun to cancel the subscription in the