Добрый день, необходимо скачать объект картинкой на жесткий диск..
подгружаю картинку провожу манипуляции с картинкой а потом необходима сохранить её на жесткий диск.
Пока удалось добиться сохранение только путём скриншота...
Подскажите пожалуйста как можно решить проблему..

Код:
<fx:Declarations>
<utils:JavaScript xmlns:utils="com.abdulqabiz.utils.*">
<![CDATA[
function takeSnapshot(imgString, width, height) {
window.open ("data:image/png;base64," + imgString, "", "width=" + width + ",height=" + height + ",resizable=1");
}
]]>
</utils:JavaScript>
<mx:Rotate id="rotate" angleFrom="0" angleTo="90" duration="1" />
<s:DropShadowFilter id="myShadow"
alpha="{alphaSlider.value}"
distance="{distanceSlider.value}"
angle="{angleSlider.value}"
blurX="{blurXSlider.value}"
blurY="{blurYSlider.value}"
color="{colorPicker.selectedColor}"
hideObject="{hideObjectCheckBox.selected}"
inner="{innerCheckBox.selected}"
quality="{qualitySlider.value}"
strength="{strengthSlider.value}"
knockout="{knockoutCheckBox.selected}"
/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.adobe.images.JPGEncoder;
import mx.controls.Alert;
import mx.utils.Base64Encoder;
[Bindable]private var originalImage:String = "http://static.flickr.com/1036/1467561537_9ecbce04e1_o_d.jpg";
[Bindable]private var thumbImage:String = "http://static.flickr.com/1036/1467561537_8341210754_t_d.jpg";
private var fileRotation:Number = 0;
private function initApp():void
{
}
// Have to proxy the images from 3rd party sites without crossdomain.xml open
private function loadImages():void
{
orginalFile.source = originalImageText.text;
imageFile.source = thumbImageText.text;
}
/**
* The BitMapData used as the source for a Image control, but we
* could have easily have sent this to the server to save the
* rotation.
**/
private function outputImage():void
{
switch (fileRotation)
{
case 0:
case 360:
resultFile.source = new Bitmap (getBitmapData(orginalFile));
break;
case -90:
case 270:
resultFile.source = new Bitmap (rotateLeft(orginalFile));
break;
case 90:
case -270:
resultFile.source = new Bitmap (rotateRight(orginalFile));
break;
case 180:
case -180:
resultFile.source = new Bitmap(rotateInverse(orginalFile));
break;
default:
resultFile.source = new Bitmap (getBitmapData(orginalFile));
break;
}
}
/**
* Example from Doug McCune's blog. This works for Firefox only, but
* using JavaScript we can actually save out our BitMapData to the
* browser window. Check out Dougs full article for more information:
* http://dougmccune.com/blog/2007/06/03/save-a-snapshot-image-of-a-flex-app-without-a-server/
**/
private function saveImage():void
{
var b64encoder:Base64Encoder = new Base64Encoder();
switch (fileRotation)
{
case 0:
case 360:
b64encoder.encodeBytes(encodeJPG(getBitmapData(orginalFile)));
break;
case -90:
case 270:
b64encoder.encodeBytes(encodeJPG(rotateLeft(orginalFile)));
break;
case 90:
case -270:
b64encoder.encodeBytes(encodeJPG(rotateRight(orginalFile)));
break;
case 180:
case -180:
b64encoder.encodeBytes(encodeJPG(rotateInverse(orginalFile)));
break;
default:
b64encoder.encodeBytes(encodeJPG(getBitmapData(orginalFile)));
break;
}
ExternalInterface.call("takeSnapshot", b64encoder.flush(), orginalFile.content.width, orginalFile.content.height);
}
private function encodeJPG(bd:BitmapData):ByteArray
{
var jpgEncoder:JPGEncoder = new JPGEncoder();
var bytes:ByteArray = jpgEncoder.encode(bd);
return bytes;
}
private function getBitmapData(img:Image):BitmapData
{
var bd:BitmapData = new BitmapData(img.content.width, img.content.height);
bd.draw(img.content);
return bd;
}
private function getBitmapDataMatrix(img:Image, matrix:Matrix):BitmapData
{
var bd:BitmapData = new BitmapData(img.content.height, img.content.width);
bd.draw(img.content, matrix);
return bd;
}
private function rotateImageRight(img:Image):void
{
img.source = new Bitmap( rotateRight(img));
}
private function rotateImageLeft(img:Image):void
{
img.source = new Bitmap( rotateLeft(img) );
}
private function rotateLeft(img:Image):BitmapData
{
var matrix:Matrix = new Matrix();
matrix.rotate(-1*Math.PI/2);
matrix.ty = img.content.width;
var bd:BitmapData = getBitmapDataMatrix(img, matrix);
return bd;
}
private function rotateRight(img:Image):BitmapData
{
var matrix:Matrix = new Matrix();
matrix.rotate(Math.PI/2);
matrix.tx = img.content.height;
var bd:BitmapData = getBitmapDataMatrix(img, matrix);
return bd;
}
private function rotateInverse(img:Image):BitmapData
{
var matrix:Matrix = new Matrix();
matrix.rotate(Math.PI);
matrix.ty = img.content.height;
matrix.tx = img.content.width;
var bd:BitmapData = new BitmapData(img.content.width, img.content.height);
bd.draw(img.content, matrix);
return bd;
}
private function setRotation(rotate:Number):void
{
fileRotation = fileRotation + rotate;
if(fileRotation == 360)fileRotation = 0;
if(fileRotation == -360)fileRotation = 0;
}
]]>
</fx:Script>
<mx:Canvas width="100%" height="100%" left="0" top="0" backgroundColor="#ffffff">
<mx:VBox verticalAlign="middle" horizontalAlign="center" left="13" top="186" width="122" height="122" borderStyle="solid" backgroundColor="#c0c0c0">
<mx:Image visible="true" id="imageFile" horizontalAlign="center" verticalAlign="middle" />
</mx:VBox>
<mx:Button label="Output" click="outputImage()" x="255" y="327"/>
<mx:Button label="Download" click="saveImage()" x="165" y="327"/>
<mx:Button label="Left" click="rotateImageLeft(imageFile), setRotation(-90)" x="10" y="327" width="60"/>
<mx:Button label="Right" click="rotateImageRight(imageFile), setRotation(90)" x="74" y="327" width="60"/>
<mx:VBox verticalAlign="middle" horizontalAlign="center" x="180" y="188" width="120" height="120" borderStyle="solid" backgroundColor="#c0c0c0">
<mx:Image id="orginalFile" width="100" height="100" verticalAlign="middle" horizontalAlign="center"/>
</mx:VBox>
<mx:Image id="resultFile" x="392" y="188" />
<mx:Label x="29" y="160" text="Thumb Image" fontWeight="bold"/>
<mx:Label x="16" y="42" text="Thumb Source (you can use same source for both)" fontWeight="bold"/>
<mx:Label x="16" y="94" text="Original Source" fontWeight="bold"/>
<mx:TextInput x="16" y="62" width="491" id="thumbImageText" text="{thumbImage}"/>
<mx:Label x="172" y="162" text="Full Size Image (scaled)" fontWeight="bold"/>
<mx:Label x="392" y="162" text="Output Full Size Imge Rotated" fontWeight="bold"/>
<mx:Label x="10" y="10" text="Rotate Image BitMapData Example" fontWeight="bold" fontSize="15"/>
<mx:TextInput x="16" y="115" width="491" id="originalImageText" text="{originalImage}"/>
<mx:Button x="536" y="115" label="Load Images" click="loadImages()"/>
</mx:Canvas>