Flex + php online photo 1 [51 space]. Flex + php online photo taking yesterday I used flex + php to make an online photo taking dashboard, which enables real-time online photo taking and updating of member portraits. First, let's talk about the principle: 1. take a photo of camera content using flex + php online.
Yesterday, I used flex + php to create an online photo taking task, which enables real-time online photo taking and updating of member portraits.
First, let's talk about the principle:
1. display the content of camera in video. if you do not understand this, refer to the actionscript manual, which provides detailed explanations and code,
2. define the BitmapData object,
M_pictureBitmapData = new BitmapData (DEFAULT_CAMERA_WIDTH, DEFAULT_CAMERA_HEIGHT );
Then, write the video content into the BitmapData object, m_pictureBitmapData.draw (video, new Matrix ());
3. read BitmapData rgb values in one pixel and one pixel from left to right. all rgb values are separated by commas (,) and written into a string,
For (var I: int = 0; I <DEFAULT_CAMERA_WIDTH; I ++)
{
For (var j: int = 0; j <DEFAULT_CAMERA_HEIGHT; j ++)
{
If (m_pictureData.length> 0)
{
M_pictureData + = "," + m_pictureBitmapData.getPixel (I, j). toString ();
}
Else
{
M_pictureData = m_pictureBitmapData.getPixel (I, j). toString ();
}
}
}
Service. getOperation ("createjpeg"). send (pic_width, pic_height, m_pictureData); // save it with amfphp
4. extract the rgb values on the server and draw a pixel-to-pixel image:
$ Img = imagecreatetruecolor ($ width, $ height );
$ M_tempPics = explode (',', $ bitmap_data );
For ($ I = 0; $ I <$ width; $ I ++)
{
For ($ j = 0; $ j <$ height; $ j ++)
{
$ Pic_argb = (int) $ m_tempPics [$ I * $ height + $ j];
Imagesetpixel ($ img, $ I, $ j, $ pic_argb );
}
}
Imagejpeg ($ img, ".../image/header/0.jpg ");
Imagedestroy ($ img );
Return true;
5. the detailed source code is included in the attachment. The front is just some important code prompts. Well, you need to know about amfphp and flex.
What else is unclear,
Next let's take a look at the test.html file.
If (hasProductInstall &&! HasRequestedVersion ){
// MMdoctitle is the stored document. title value used by the installation process to close the window that started the process
// This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
// DO NOT MODIFY THE FOLLOWING FOUR LINES
// Location visited after installation is complete if installation is required
Var MMPlayerType = (isIE = true )? "ActiveX": "PlugIn ";
Var MMredirectURL = window. location;
Document. title = document. title. slice (0, 47) + "-Flash Player Installation ";
Var MMdoctitle = document. title;
AC_FL_RunContent (
"Src", "playerProductInstall ",
"FlashVars", "MMredirectURL =" + MMredirectURL + '& MMplayerType =' + MMPlayerType + '& MMdoctitle = "+ MMdoctitle + "",
"Width", "100% ",
"Height", "100% ",
"Align", "middle ",
"Id", "hphoto ",
"Quality", "high ",
"Bgcolor", "#869ca7 ",
"Name", "hphoto ",
"AllowScriptAccess", "sameDomain ",
"Type", "application/x-shockwave-flash ",
"Pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} Else if (hasRequestedVersion ){
// If we 've detected an acceptable version
// Embed the Flash Content SWF when all tests are passed
AC_FL_RunContent (
"Src", "hphoto ",
"Width", "100% ",
"Height", "100% ",
"Align", "middle ",
"Id", "hphoto ",
"Quality", "high ",
"Bgcolor", "#869ca7 ",
"Name", "hphoto ",
"Flashvars", 'historyurl1_history.htm % 3F & lconid = '+ lc_id + '',
"AllowScriptAccess", "sameDomain ",
"Type", "application/x-shockwave-flash ",
"Pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} Else {// flash is too old or we can't detect the plugin
Var alternateContent = 'alternate HTML content shoshould be placed here .'
+ 'This content requires the Adobe Flash Player .'
+ 'Http: // www.adobe.com/go/getflash/> Get Flash ';
Document. write (alternateContent); // insert non-flash content
}
// -->
Script
Id = "hphoto" width = "100%" height = "100%"
Codebase = "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
Width = "100%" height = "100%" name = "hphoto" align = "middle"
Play = "true"
Loop = "false"
Quality = "high"
AllowScriptAccess = "sameDomain"
Type = "application/x-shockwave-flash"
Pluginspage = "http://www.adobe.com/go/getflashplayer">
Vivo used flex + php yesterday to create an online photo task, which enables real-time online photo taking and updating of member portraits. First, let's talk about the principle: 1. set the content of camera...