There are three main steps to send the canvas as a snap to server.
1. First convert the canvas into BitmapData.
For ex: var resultBitmapData:BitmapData = new BitmapData(canvas.width,
canvas.height);
2. Then convert the bitmapdata using appropriate encoder(JPEGEncoder or
PNGEncoder) to ByteArray, since snap(canvas) will be send to server in the
form of byteArray
For ex: var m:Matrix = new Matrix();
resultBitmapData.draw(target, m);
//Set JPEG quality
var qualityValue:Number = 100;
//create the encoder with the appropriate quality
var myEncoder:JPEGEncoder = new JPEGEncoder(qualityValue);
//convert the BitmapData into ByteArray using JPEGEncoder
var bytearray:ByteArray = myEncoder.encode(resultBitmapData);
//add application/octet-stream header to send a bytearray
through POST
var header:URLRequestHeader = new URLRequestHeader
("Content-type","image/jpeg");
//create the URLRequest object and pass the name of the file to
create
var urlR:URLRequest = new
URLRequest(AppData.serverURL+"snap.php?name=snap.jpg");
//add the Content-type header to the URLRequest object
urlR.requestHeaders.push(header);
//assign data to POST buffer
urlR.method = URLRequestMethod.POST;
urlR.data = bytearray;
// load the data into the server
var imageloader:URLLoader = new URLLoader();
imageloader.load(urlR);
3. In Php, use a decoder to get the bytearry and write into the server.
--
Thanks,
Ganga
On Tue, Jun 2, 2009 at 11:47 AM, flex <[email protected]> wrote:
>
> hi all,
> i am using flex builder 3.0,
> i am doing 1 application where user can make drawing in canvas and
> can save it and store on server as a snap(image).
> please anybody tell me how can i read this canvas and send to server?
> thank you.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---