Asp.net uses a camera to take a photo

Source: Internet
Author: User

Flash files for video photos

Import it. Sephiroth. mloaderwindow
Import it. Sephiroth. printscreen

Mycam = camera. Get ();
Mycam. setmode (390,290, 10 );
My_video.attachvideo (mycam );
VaR Loader: mloaderwindow = This. createclassobject (mloaderwindow, "loader", 10, {_ x:-1000, _ y:-1000 })
// Loader. setstyle ("bordercolor", 0x006699)

VaR listener: Object = new object ();

Listener. onprogress = function (target: movieclip, loaded: Number, total: Number ){
VaR Perc = math. Round (loaded/total) * 100)
Loader. Label = "sending..." + Perc + "%"
Loader. value = Perc
}

Listener. oncomplete = function (target: movieclip, load_var: loadvars ){
Loader. Label = "sending ..."
Load_var.send ("makepic. aspx", "_ Self", "Post ")
Loader. Close ()
}

Function print_me (){
VaR mc_x = 15;
VaR mc_y = 15;
My_video.attachvideo (null );
Pn = new printscreen ();
Pn. addlistener (listener );
Pn. Print (_ root, 0, 0,390,290, mc_x, mc_y)
Loader. Label = "in output... 0%"
Loader. Open (true, true, true );
}

 

Asp.net:

Private bool createimage (string path)
{

Int W = 0;
Int h = 0;

Try
{
W = int. parse (request. Form ["width"]);
H = int. parse (request. Form ["height"]);
}
Catch (exception ee)
{
Response. Write (EE. Message );
Return false;
}

Bitmap NEWMAP = new Bitmap (W, H );
Int rows = 0;
Int Cols = 0;

Graphics Gp = graphics. fromimage (NEWMAP );
GP. Clear (color. White );
Imagecodecinfo myimagecodecinfo;
System. Drawing. imaging. encoder myencoder;
Encoderparameter myencoderparameter;
Encoderparameters myencoderparameters;
Myimagecodecinfo = imagecodecinfo. getimageencoders () [1];
Myencoder = system. Drawing. imaging. encoder. quality;
Myencoderparameters = new encoderparameters (1 );
Myencoderparameter = new encoderparameter (myencoder, 95l );
Myencoderparameters. Param [0] = myencoderparameter;

GP. compositingquality = compositingquality. highquality;
GP. smoothingmode = smoothingmode. highquality;
GP. interpolationmode = interpolationmode. highqualitybicubic;
GP. textrenderinghint = textrenderinghint. cleartypegridfit;
For (rows = 0; rows <NEWMAP. height; rows ++) // loop Image Height
{
String PX = request ["PX" + rows];
String [] c_row = px. Split (',');
For (Cols = 0; Cols <NEWMAP. width; Cols ++) // loop Image Width
{

String values = c_row [Cols];
If (values! = "" & Values! = NULL)
{
String hex = values;
While (Hex. length <6)
{// Prevent color loss
Hex = "0" + hex;
}

Int r = int. parse (Hex. substring (0, 2), system. Globalization. numberstyles. hexnumber );
Int G = int. parse (Hex. substring (2, 2), system. Globalization. numberstyles. hexnumber );
Int B = int. parse (Hex. substring (4, 2), system. Globalization. numberstyles. hexnumber );

NEWMAP. setpixel (cols, rows, color. fromargb (R, G, B ));

}
}
}

GP. drawimage (NEWMAP, 0, 0, W, H );
Path = server. mappath ("makepic. aspx") + "123.jpg ";
// Save the path. Modify the path here.
NEWMAP. Save (path, myimagecodecinfo, myencoderparameters );
Myencoderparameters. Dispose ();
GP. Dispose ();
NEWMAP. Dispose ();
Response. Redirect (PATH );
Return true;
}

I don't quite want to explain the flash source code from the power of the Alliance, so that it can be called in PHP. Here it is changed to calling in Asp.net.

 

Related Article

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.