Air application call camera to take pictures and keep photos in local folder

Source: Internet
Author: User
Tags addchild
Import Com.adobe.images.PNGEncoder;
Import Com.adobe.images.JPGEncoder;
Import Flash.filesystem.File;
Import Flash.filesystem.FileStream;
Import Flash.filesystem.FileMode;
Import Flash.media.Camera;
Import Flash.media.Video;
Import flash.events.MouseEvent;
Import Flash.display.BitmapData;

Import Flash.utils.ByteArray;  Security.showsettings (Securitypanel.camera);
Display Camera selection panel var cam:camera = Camera.getcamera ();                Cam.setmode (738, 499, 24);
Camera window size var video:video = new Video (738,499);
Video.attachcamera (CAM);
This.addchild (video);
video.x = 276;

VIDEO.Y = 104;

This.addchild (BTN);
Full screen stage.displaystate = stagedisplaystate.full_screen_interactive;

Btn.addeventlistener (Mouseevent.mouse_down, Savestill);

var count:int = 0;
	function Savestill (e:mouseevent): void{if (count >49) count = 0;  var Mtr:matrix = new Matrix (476/738,0,0,370/499,0,0);  Reduce the picture frame by proportional to the var bmd:bitmapdata = new BitmapData (476, 370);
	
	Finally saved into the picture size Bmd.draw (video,mtr); Save as JPG picture var jpg:jpgeNcoder = new Jpgencoder ();
	
	var ba:bytearray=jpg.encode (BMD);
	/* Save as PNG picture var Ba:bytearray = Pngencoder.encode (BMD);
	var file:file = File.desktopDirectory.resolvePath ("webcam" + count++ + ". png");
	var file:file = File.documentsDirectory.resolvePath ("G:\PHPnow\htdocs\phpgetpic\upload\webcam" + count++ + ". png"); * * var file:file = File.applicationStorageDirectory.resolvePath ("G:\\phpnow\\htdocs\\phpgetpic\\upload\\webcam" +
	count++ + ". jpg");
	var filestream:filestream = new FileStream ();
	Filestream.open (file, filemode.write);
	Filestream.writebytes (BA);
	
	Filestream.close ();
Socket broadcast out//SENDSTR ("webcam" + (count-1));
 }
With the release of the "PHP to obtain local image files and generate XML file output" combined with the socket can be a computer to take pictures, another computer shows the photos taken.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.