欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

flex+php在线拍照一[51空间]_PHP教程

程序员文章站 2022-06-14 13:06:32
...

flex+php在线拍照

昨天用flex+php做了一个在线拍照的小东东,可以实现会员头像的实时在线拍照更新。
首先来讲一讲原理:
1、将camera的内容显示在video中,这个不懂的参考actionscript的手册,里面有详细的讲解以及代码,
2、定义一下BitmapData对象,
m_pictureBitmapData = new BitmapData(DEFAULT_CAMERA_WIDTH,DEFAULT_CAMERA_HEIGHT);
然后将video的内容写进BitmapData对象里, m_pictureBitmapData.draw(video,new Matrix());
3、从左到右,从上到下,一个像素一个像素的读取BitmapData的rgb值,所有的rgb值用","分开,写进一个字符串里,
for(var i:int = 0; i {
for(var j:int = 0; 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);//用amfphp进行保存
4、在服务端就把那些rgb值提取出来,一个像素一个像素的画点:
$img=imagecreatetruecolor($width,$height);
$m_tempPics=explode(',',$bitmap_data);
for ($i = 0; $i {
for ($j = 0; $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、详细的源码在附件里面,前面只是些重要提示代码。嗯,要懂得amfphp,还有flex。
还有什么不清楚的,

下面来看看 test.html文件

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
}
// -->