截屏问题
要截取屏幕中的一块地方 
用什么能实现? 其中我找了个php+js的,但那只是正对一个图片的截取图片,php那边在正对这张图片进行截取。
而这里是多张图片镶嵌起来,在上面需要截图。谁有没好的方式和办法,给我提示下哟?
function Create(){        var p = ic.Url,
        x = ic.Drag.offsetLeft,
        y = ic.Drag.offsetTop,
        w = ic.Drag.offsetWidth,
        h = ic.Drag.offsetHeight,
        pw = ic.Width,
        ph = ic.Height;
        var url="ImgCropper.php?p=" + p + "&x=" + x + "&y=" + y + "&w=" + w + "&h=" + h + "&pw=" + pw + "&ph=" + ph + "&" + Math.random();
        document.getElementById("apDiv1").innerHTML+=url+"</br>";
        
        $("imgCreat").src = "ImgCropper.php?p=" + p + "&x=" + x + "&y=" + y + "&w=" + w + "&h=" + h + "&pw=" + pw + "&ph=" + ph + "&" + Math.random();
}
ImgCropper.phpheader("Content-type:image/jpeg");          
                
                         $Pic = $_GET["p"];
       // $PointX =$x;
        //$PointY = $y;
       // $CutWidth =$w;
       // $CutHeight =$h;
           
        $PicWidth =$_GET["pw"];
        $PicHeight =$_GET["ph"];
                $x =$_GET["x"];
                $y =$_GET["y"];
                $w =$_GET["w"];
                $h =$_GET["h"];
                $im=imagecreatefromjpeg($Pic);
                
                $Width=imagesx($im);
                $Height=imagesy($im);
                //echo $Width."---".$Height;die();
                $PointX=$x*$Width/$PicWidth;
                $CutWidth=$w*$Width/$PicWidth;
                $PointY=$y * $Height/$PicHeight;
                $CutHeight=$h*$Height/$PicHeight;
       // $newimg = imagecreatetruecolor($CutWidth,$CutHeight);
                 //imagecopy($newimg,$im,0,0,$PointX,$PointY,$CutWidth,$CutHeight);
                  $newimg = imagecreatetruecolor($w,$h);
        imagecopyresampled($newimg, $im, 0, 0,$PointX,$PointY,$w,$h,$CutWidth,$CutHeight);
        ImageJpeg ($newimg,"a.jpg",100);
          ImageJpeg ($newimg);
           
            ImageDestroy ($im);

解决方案 »

  1.   

    如果是服务器端截屏,php 就可以完成:http://cn2.php.net/manual/en/function.imagegrabscreen.php
    如果是客户端截屏,那只能用 activex 这样的客户端插件完成。你的这段代码实际上是用 js 获得鼠标在图片上的定位,然后将数值传递到 php,由 gd 库等扩展处理图片。这跟截屏是完全不同的概念。
      

  2.   

    客户端难imagegrabscreen函数只有在Windows的主机下才有效
      

  3.   

    客户端使用(Firefox:插件)、(IE:ActiveX)。服务端还没见过。
      

  4.   

    楼主的代码只是对一个图片文件进行操作,与客户端屏幕无关。
    客户端截屏只能靠 ActiveX 或者 Applet 了。
      

  5.   

    客户端要装ActiveX控件的,看看163邮箱是怎么做的。