2
I am trying to save the contents of a Movieclip in an image, but when trying to save the image the following error occurs:
image with white space http://www.panrotas.com.br/v2/test.jpg
A white space appears on all images saved using the FileReference
together with the JPGEncoder
.
I believe the problem is related to JPGEncoder
, although I’m not sure that.
Follow the function I use to save the images:
private function fl_Salvar(event:MouseEvent)
{
try
{
var src:BitmapData = new BitmapData(imageViewer.width,imageViewer.height);
var mtx:Matrix = DisplayUtils.fitIntoRect(imageViewer.mcImage.getChildAt(0),rect,true,Alignment.MIDDLE,false);
src.draw(imageViewer,mtx,null,null,null,true);
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var imgStream:ByteArray = null;
imgStream = jpgEncoder.encode(src);
var file:FileReference = new FileReference();
file.addEventListener( IOErrorEvent.IO_ERROR, ioErrorHandler );
file.save( imgStream, "TESTE.jpg");
}
catch (ioe:IllegalOperationError)
{
trace("Operação Ilegal.");
}
catch (ae:ArgumentError)
{
trace("Argumento Inválido.");
}
catch (me:MemoryError)
{
trace("Memória Insuficiente.");
}
catch (error:Error)
{
trace("Erro ao tentar salvar imagem : "
+ " . Erro : " + error);
}
}
private function ioErrorHandler( event:IOErrorEvent ):void
{
trace("Handler de erro I/O: " + event);
}
I wonder if anyone knows what’s causing this blank area in the images?