midimid
04-24-2009, 04:47 PM
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?
public function saveImage(imageRawData):void {
trace("SAVING IMAGE")
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var jpgStream:ByteArray = jpgEncoder.encode(imageRawData.imageRawData.conten t.bitmapData);
var imageFile:File = imageRawData.image.localFile;
var filestream:FileStream = new FileStream();
filestream.open(imageFile,FileMode.WRITE);
filestream.writeBytes(jpgStream);
filestream.close();
}
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?
public function saveImage(imageRawData):void {
trace("SAVING IMAGE")
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var jpgStream:ByteArray = jpgEncoder.encode(imageRawData.imageRawData.conten t.bitmapData);
var imageFile:File = imageRawData.image.localFile;
var filestream:FileStream = new FileStream();
filestream.open(imageFile,FileMode.WRITE);
filestream.writeBytes(jpgStream);
filestream.close();
}