This content has been marked as final. Show 4 replies
var snapshot:BitmapData = new BitmapData(canvas.width, canvas.height, true);
var encBytes:ByteArray = PNGEncoder.encode(snapshot);
// Now you got a byte array.
Hope this help
Note : You will need PNGEncoder from flexlib project.
Sweet, that'll get me to a byte array. What I really need, esp. now, is getting to asp.net. You can also use capture UIComponent. http://www.tricedesigns.com/tricedesigns_home/blog/2006/09/flex-2-bitmapdata-tricks-and.ht ml I like this better. It'll let me set the canvas size first through variables(canvas creation), then just capture the canvas a lot easier. Thank you hohohuhu.
Need some good asp.net'ers now. I believe my server allows coldFusion also, so if we had to go that route to get em to the server I GUESS that'd be ok ;)
Also now that we just captured as a png, we don't have to do any formatting on the asp.net side. Just capture and save. When I was looking up sending form vars from flash to asp.net I was finding all kinds of POST and LoadVars examples. Now for some reason I'm not finding any for asp.net. PHP out tha wahzoo though.
Yet again, any help would be freakin awesome.
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:
var bitMD:BitmapData = new BitmapData(this.width,this.height)
var _PNG:ByteArray = PNGEncoder.encode(bitMD);
var U:URLRequest = new URLRequest
U.method = URLRequestMethod.POST
U.data = _PNG;
U.url = " http://localhost/CARTO/image.aspx";
var UR:URLLoader = new URLLoader
UR.dataFormat = URLLoaderDataFormat.TEXT
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()
Dim fs As New FileStream(System.Web.HttpContext.Current.Server.MapPath("test.png"), FileMode.Create)
That's exactly what I was having trouble with. Reading out of the memory stream was what I was skipping over. Thank you Jon