Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-24-2009, 03:47 PM   #1
midimid
Senior Member
 
Join Date: Feb 2008
Posts: 128
Default Bulk Reading/Writing images stalls app

I'm looping through a bunch of images and writing them to the desktop from the web - its a long story, but basically, each file is checked if it exists locally, loaded from a URL if not, and then written to the desktop using JPGEncoder.

As far as I can tell, during the saving process, the app is stalling.

I have a simple MOUSE_MOVE function that keeps a sprite following the mouse. During the saving process, the sprite does NOT move.

Here's my save function. I'm careful to do nothing else during this function, and only continue after the end of it.

{edit} - I've learned through some extra tracing, that the spot its stopping at is jpgEncoder.encode(). Note that imageRawData.imageRawData.content.bitmapData is just coming straight from a Loader Class.

Why is the encoder so slow? Is there any other way to do this?

If I don't need a user to see these images themselves, do I even need to do this encode?

Code:
public function saveImage(imageRawData):void {
trace("SAVING IMAGE") var jpgEncoder:JPGEncoder = new JPGEncoder(85); var jpgStream:ByteArray = jpgEncoder.encode(imageRawData.imageRawData.content.bitmapData); var imageFile:File = imageRawData.image.localFile; var filestream:FileStream = new FileStream(); filestream.open(imageFile,FileMode.WRITE); filestream.writeBytes(jpgStream); filestream.close();
}
midimid is offline   Reply With Quote
Old 04-28-2009, 08:49 AM   #2
kukoc
Registered User
 
Join Date: Mar 2008
Location: Poland
Posts: 12
Default

its normal that image converting take some time becouse it needs a lot of CPU power, especjaly if jpg files have large resolution. for me better way is server side resizing before download and cache them on server hdd.

but when every time you need different resolution you need to do it just as you show.
you can try to move the jpg encoding to the different thread and make it asynchronic.

here is tutorial i googled:
http://blog.inspirit.ru/?p=201
google cache:
http://209.85.229.132/search?q=cache...ient=firefox-a
kukoc is offline   Reply With Quote
Old 04-28-2009, 12:16 PM   #3
midimid
Senior Member
 
Join Date: Feb 2008
Posts: 128
Default

Actually - found an excellent solution here by Jerion. Honestly I can deal with the delay in time, but what I could not deal with was the stalling of the app. Jerion's solution adds event listening, and fixes the issue.

Quote:
Originally Posted by kukoc View Post
its normal that image converting take some time becouse it needs a lot of CPU power, especjaly if jpg files have large resolution. for me better way is server side resizing before download and cache them on server hdd.

but when every time you need different resolution you need to do it just as you show.
you can try to move the jpg encoding to the different thread and make it asynchronic.

here is tutorial i googled:
http://blog.inspirit.ru/?p=201
google cache:
http://209.85.229.132/search?q=cache...ient=firefox-a
midimid 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
AS2 App Doesn't Display Dynamic Images Properly earthlie ActionScript 2.0 3 02-01-2009 05:35 PM
Scaling an Externally Loaded Flex app njward Flex 2, 3 & 4 1 05-15-2008 03:30 AM
Dynamic images to the scrollpane Flashchick ActionScript 1.0 (and below) 17 03-29-2004 10:54 AM
XML, dynamic images, scolling problems klip ActionScript 1.0 (and below) 0 08-24-2003 03:01 AM
Can't get dynamic images to show up instantly in Flash MX chuksted Other Flash General Questions 2 03-20-2003 06:49 AM


All times are GMT. The time now is 09:14 PM.

///
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.