import flash.net.*; import flash.display.*; var hostName:String = "http://localhost:3195/fluorine/"; var gatewayUrl:String = hostName+"Gateway.aspx"; var bpd:BitmapData = new BitmapData(mc.width, mc.height); bpd.draw(mc); var dat:ByteArray = PNGEncoder.encode(bpd); var nc:NetConnection = new NetConnection(); nc.connect(gatewayUrl); nc.call("testamf.SendImage",new Responder(onResult,onFault),dat); function onResult(re:Object) { trace("成功!"); } function onFault(re:Object) { trace("失败"); } |
public void SendImage(ByteArray byteArray) { uint length = byteArray.Length; byte[] bytes = new byte[length]; byteArray.ReadBytes( bytes, 0, length); MemoryStream ms = new MemoryStream(bytes); Image img = Bitmap.FromStream(ms); Bitmap bmp = new Bitmap(img); //To save the image to a file MemoryStream tempStream = new MemoryStream(); bmp.Save(tempStream,System.Drawing.Imaging.ImageFormat.Png); FileStream fs = new FileStream(System.Web.HttpContext.Current.Server.MapPath("test.png"), FileMode.Create); tempStream.WriteTo(fs); tempStream.Close(); fs.Close(); } |
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |