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

php中文网
发布: 2016-07-20 11:05:15
原创
1073人浏览过

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

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号