开发者

saving webcam image to a website

开发者 https://www.devze.com 2023-02-05 20:01 出处:网络
How can i save a webcam screenshot to a website? I know you can save it to your hard drive using: var browseFileReference = new FileReference();

How can i save a webcam screenshot to a website?

I know you can save it to your hard drive using:

var browseFileReference = new FileReference();
        browseFileReference.save(video);

But how would 开发者_StackOverflowi go about it to save this image to a website, lets say flickr or facebook or something.

Any help?


You should have a look at existing AS3 library.

Flickr : http://code.google.com/p/as3flickrlib/

Facebook : http://www.adobe.com/devnet/facebook.html


The basic steps are, generate the bitmap data for the region you want, use one of the F/OSS libraries to generate PNG or JPEG data, base64 the data, and then generate a URLRequest with the encoded image as POST data, which can hen be handled server side. I would have to dig through projects to find the proper classes I have to do this to show a real example, but this is actually really simple. Each of the steps I outline can be implemented in a few lines of code using existing libraries.


You can save the screenshot of the webcam as ByteArray. Make sure you have the JPGEncoder class (from the as3corelib).

        // bitmapdata
        var btmData:BitmapData = new BitmapData(video.width, video.height);
        btmData.draw(video);

        // make jpg
        var jpgEncoder:JPGEncoder = new JPGEncoder(90);
        var jpgBytes:ByteArray = jpgEncoder.encode(btmData);

Now, you can use the as3flickrlib to connect with Flickr. Danny Patterson wrote a nice article to upload a ByteArray to Flickr with this library, see http://blog.dannypatterson.net/2009/08/upload-bytearray-to-flickr/

Edit: I would first try to upload it to Facebook, that is much easier than uploading an image to Flickr.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号