Avatar

Level 1
You've probably already worked this one out but I thought I
would post my solution - not elegant but it works



I spent two days trying to find an asp.net solution in VB.net
to no avail so here goes:




Actionscript:



var bitMD:BitmapData = new BitmapData(this.width,this.height)

bitMD.draw(this);



var _PNG:ByteArray = PNGEncoder.encode(bitMD);





var U:URLRequest = new URLRequest

U.method = URLRequestMethod.POST

U.data = _PNG;


U.contentType="application/octet-stream";

U.url = "
http://localhost/CARTO/image.aspx";

var UR:URLLoader = new URLLoader

UR.dataFormat = URLLoaderDataFormat.TEXT

UR.load(U);






ASP.NET



Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim b() As Byte = Request.BinaryRead(Request.TotalBytes)







Dim ms As MemoryStream = New MemoryStream(b)



Dim img As System.Drawing.Image = Bitmap.FromStream(ms)

Dim bmp As Bitmap = New Bitmap(img)





Dim tempStream As New MemoryStream()

bmp.Save(tempStream, System.Drawing.Imaging.ImageFormat.Png)

Dim fs As New
FileStream(System.Web.HttpContext.Current.Server.MapPath("test.png"),
FileMode.Create)

tempStream.WriteTo(fs)

tempStream.Close()

fs.Close()



End Sub