Home > Article > Backend Development > flex+php online photo taking 1 [51 space]_PHP tutorial
Yesterday I used flex+php to make a small online photo taking thing, which can realize real-time online photo taking and updating of member avatars.
First let’s talk about the principle:
1. Display the camera content in the video. If you don’t understand this, please refer to the actionscript manual, which has detailed explanations and codes.
2. Define the BitmapData object ,
m_pictureBitmapData = new BitmapData(DEFAULT_CAMERA_WIDTH,DEFAULT_CAMERA_HEIGHT);
Then write the content of the video into the BitmapData object, m_pictureBitmapData.draw(video,new Matrix());
3. From left to right, From top to bottom, read the rgb value of BitmapData pixel by pixel. All rgb values are separated by "," and written into a string,
for(var i:int = 0; i < DEFAULT_CAMERA_WIDTH ; i++)
+= "," + m_pictureBitmapData.getPixel(i,j).toString();
{
🎜> ,pic_height,m_pictureData);//Use amfphp to save
4. Save those rgb on the server side Extract the value, draw points one pixel by pixel:
$img=imagecreatetruecolor($width,$height);
$m_tempPics=explode(',',$bitmap_data);
for ($i = 0; $i < $width; $i++)
$pic_argb =(int) $m_tempPics[$i * $height + $j];
imageset($img,$i,$j,$pic_argb);
}
pixel image jpeg($img,".. /../image/header/0.jpg");
imagedestroy($img);
return true;
5. The detailed source code is in the attachment, and the front is just some important reminder code. Well, you need to know amfphp and flex.
If there is anything unclear,
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",'historyUrl=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 should be placed here. '
+ 'This content requires the Adobe Flash Player. '
+ 'Get Flash';
document.write(alternateContent); // insert non-flash content
}
// -->