Recently the project needs a photo function, search on the Internet for a long time there are no good solutions, some people provide, but not all, here I choose to post my Reference URL (http://www.aspstat.com/69 ), I integrated some other code and made one with flash8. the Code is as follows:
VaR my_cam: Camera = camera. get (); var my_video: Video; my_video.attachvideo (my_cam); var camera_lbl: MX. controls. label; var cameras_cb: MX. controls. comboBox; camera_lbl.text = my_cam.name; cameras_cb.dataprovider = camera. names; function changecamera (): void {my_cam = camera. get (cameras_cb.selectedindex); my_video.attachvideo (my_cam); camera_lbl.text = my_cam.name;} cameras_cb.addeventlistener ("change", Chang Ecamera); camera_lbl.setstyle ("fontsize", 9); cameras_cb.setstyle ("fontsize", 9); // init variable photow = new number (50 ); photoh = new number (50); my_cam.setmode (photow, photoh, 10, true); // This object is used to send data to a webpage through get or post var LV: loadvars; lv = new loadvars (); btnsavepic. onrelease = function () {savecamera (); // geturl ("http: // localhost/captureandsignaturewebapp/pageb. aspx "," _ blank "," get ");} function savecame RA () {// create a bitmapdate object and obtain the image information on the video LV. bm = new flash. display. bitmapdata (photow, photoh, true, 0); LV. BM. draw (my_video); // photopreview is a movie clip instance in the scenario. It is used to output bitmapdate to achieve photopreview. attachbitmap (LV. BM, 1); photopreview. _ width = 50; photopreview. _ Height = 50; trace (LV. BM. height); trace (LV. BM. width); // geturl ("http://www.macromedia.com", "_ blank", "get");} btnupload. onrelease = function () {sendpic ();} Btn1.onrelease = function () {sendpic2 ();} function sendpic2 () {geturl ("http: // localhost/captureandsignaturewebapp/pageb. aspx? AA = AABB "," _ blank "," get ");} function sendpic () {// loading. _ visible = true; // geturl ("http: // localhost/captureandsignaturewebapp/pageb. aspx? AA = AABB "," _ blank "," get "); // read the pixel information in the rectangle range of the image and connect it as a string begin I = lv. BM. height; trace ("I:" + I. tostring (); j = lv. BM. width; trace ("J:" + J. tostring (); // trace ("A:" + I. tostring (); // trace ("B:" + J. tostring (); rgb_array = ""; for (var m = I-1; m> = 0; m --) // For (y = 10-1; y> = 0; y --) {trace (rgb_array); For (VAR n = 0; n <j; n ++) // For (x = 0; x <10; X ++) {trace ("M:" + M. tostring () ); Trace ("N:" + N. tostring (); color = lv. BM. getpixel (m, n ). tostring (16); trace (color); trace (rgb_array); rgb_array = rgb_array + (color + ",");} // end of for // trace (rgb_array);} // end of for LV. height = I; LV. width = J; LV. rgb_array = rgb_array; camera_lbl.text = rgb_array; geturl ("http: // localhost/captureandsignaturewebapp/pageb. aspx? Passval = 1 "," _ blank "," Post "); // read the pixel information of the image's rectangle range and connect it as a string. End // geturl (" javascript: alert ('step _ 1') "); // the URL of the page to be processed. form ["name"] obtains the value, for example, request. form ["rgb_array"] // LV. sendandload ("http: // localhost/captureandsignaturewebapp/pageb. aspx ", LV," Post "); // behavior triggered when the page returns information that is, after page processing is complete/* lv. onload = function (SUCCESS) {If (SUCCESS) {// jump to another page geturl ("http: // localhost/captureandsignaturewebapp/pageb. aspx "," _ Self ");} else {geturl (" javascript: Alert ('not SUCCESS ')");}}*/}
The source code of Asp.net is as follows:
Using system; using system. data; using system. configuration; using system. collections; using system. web; using system. web. security; using system. web. ui; using system. web. UI. webcontrols; using system. web. UI. webcontrols. webparts; using system. web. UI. htmlcontrols; using system. drawing; namespace captureandsignaturewebapp {public partial class pageb: system. web. UI. page {protected void page_load (Object sender, E Ventargs e) {// string [] rgbarray = new string [] {request. form ["rgb_array"]}; // This. drawimagefromflashuploader (240,140, rgbarray ). save ("images/1.bmp"); // This. image1.imageurl = "images/1.bmp";} protected override void onpreinit (eventargs e) {base. onpreinit (E); string Ss = ""; if (request. form. count> 0) {// Ss = request. querystring ["passval"]; SS = request. form ["rgb_array"]; this. label1.text = SS; string [] rgbarray = ss. split (New char [] {','}); this. drawimagefromflashuploader (50, 50, rgbarray ). save (@ "E:/work/ODMS/SCAAs/technical difficulties/captureandsignaturewebapp/images/1.bmp"); // This. image1.imageurl = @"~ E:/work/ODMS/SCAAs/technical difficulties/captureandsignaturewebapp/images/1.bmp "; this. img1.src = @ "images/1.bmp" ;}} public system. drawing. bitmap drawimagefromflashuploader (INT width, int height, string [] rgbarray) {system. drawing. bitmap Bm = new system. drawing. bitmap (width, height, system. drawing. imaging. pixelformat. format32bpprgb); int Pos = 0; For (INT I = BM. height-1; I> = 0; I --) {for (Int J = 0; j <BM. width; j ++) {BM. setpixel (J, I, system. drawing. color. fromargb (Int. parse (rgbarray [POS], system. globalization. numberstyles. hexnumber); POS ++ ;}} return BM ;}}}I hope this post will help you. I just want to package and upload it.
If there are tags or buttons in the Action Script to implement multiple languages, you can define a javascript variable on the page where the flash C # is loaded, such
VaR flashbtnsavetext = '<% = This. getlabel ("com_confirm") %> ';
It can be directly referenced in the root of Action Script.