The previous code found that the original image proportion was a bit incorrect. If the customer was not satisfied, he checked the use of the parameters of these methods in Action Script and found that none of them could be adjusted, after checking on the Internet for a long time, I finally found a post posted by a master. I sent his URL and sent the code by the way:
URL:
Http://www.blueidea.com/tech/multimedia/2005/3116.asp
His code is:
1) the code before a proportional problem occurs is:
var my_video:Video;my_video._x=100;my_video._y=40;var my_cam:Camera = Camera.get();my_cam.setMode(180, 140, 10, true);my_video.attachVideo(my_cam);shutter.onRelease = function() { myBitmap = new flash.display.BitmapData(180, 240, true, 0); myBitmap.draw(my_video); var tempObj = _root.createEmptyMovieClip("photo", 100); tempObj._x = 300; tempObj._y = 40; tempObj.attachBitmap(myBitmap, 1, "always", true);};
2) After the amendment is:
var my_video:Video;my_video._x=100;my_video._y=40;var my_cam:Camera = Camera.get();my_cam.setMode(180, 140, 10, true);my_video.attachVideo(my_cam);shutter.onRelease = function() { myBitmap = new flash.display.BitmapData(160, 120, true, 0); myBitmap.draw(my_video); var tempObj = _root.createEmptyMovieClip("photo", 100); tempObj._x = 300; tempObj._y = 40; tempObj._width= 180; tempObj._height = 240; tempObj.attachBitmap(myBitmap, 1, "always", true);};
The modified code is as follows:
// Init variable cameraw = new number (180); camerah = new number (140); photow = new number (160); photoh = new number (120); var my_cam: camera = camera. get (); my_cam.setmode (cameraw, camerah, 10, true); 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 changecame RA (): void {my_cam = camera. get (outputs); my_cam.setmode (cameraw, camerah, 10, true); my_video.attachvideo (my_cam); camera_lbl.text = my_cam.name;} convert ("change", changecamera ); camera_lbl.setstyle ("fontsize", 9); cameras_cb.setstyle ("fontsize", 9); // 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 savecamera () {// 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 = photow; photopreview. _ Height = photoh; 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. TOST Ring (); // trace ("N:" + N. tostring (); color = lv. BM. getpixel (n, m ). 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; now_date = new date (); // now_date.getdate () // 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? Val = "+ now_date.gettime (), LV," Post "); // the behavior that is triggered when the page returns information that is, after page processing is complete. onload = function (SUCCESS) // If (LV. loaded = true) {If (SUCCESS) {geturl ("http: // localhost/captureandsignaturewebapp/pageb. aspx? Val = "+ now_date.gettime ()," _ blank "," Post "); // geturl (" javascript: Alert ('success ') "); geturl (" javascript: window. location. reload (); ") ;}/ * If (SUCCESS) {// jump to another page // geturl (" http: // localhost/captureandsignaturewebapp/pageb. aspx "," _ Self "); geturl (" http: // localhost/captureandsignaturewebapp/pageb. aspx? Passval = 1 "," _ blank "," Post ");} else {geturl (" javascript: Alert ('not SUCCESS ')");}*/}}
But I have a question: why do we need to set width and height to 160 and 120? I don't understand this, but I guess it is related to the ratio of the camera. I would like to ask the author in the URL, but you don't want to register.
In addition, if the trace in Action Script is removed, the speed will be affected.