Not yet rated
Tags:

Problem

Is it possible capture images and video with quality in a web application or just in Air?

Solution

If your talking about creating an image based on video, then yes you can.

Detailed explanation

Using AS3CoreLib you can use a movieclip or a video object (for example) and create an image (jpg or png) based on them.

It turns out that AS3CoreLib has been moved to gitHub (http://github.com/mikechambers/as3corelib)

In your project add the ActionScript so you have access to everything.
Import the JPG Encoder:


import com.adobe.images.JPGEncoder;

Use the BitmapData class to create an image based on your movieClip or video Sprite.

var myJPG:BitmapData = new BitmapData(myVideo.width,myVideo.height);
    myJPG.draw(myVideo);

Now we create the JPG from the bitmap data
You can also add how much compression you want to add to the image:

var jpgEncode:
JPGEncoder = new JPGEncoder(85);
var jpgStream:ByteArray = 
jpgEncode
.encode(
myJPG
);

Extra bonus to save the image on the users desktop (no call to the server needed)

var fileRef:FileReference = new FileReference();
    fileRef.save(jpgStream,"myFile.jpg");

This should ask you were you want to save your files. 
File names are totaly up to you baed on what your doing.




+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes