解决方案 »

  1.   

    //header("Content-type: image/png");
    $url = 'http://avatar.csdn.net/9/4/5/1_kenshako.jpg';
    $im = imagecreatefromjpeg($url);
    imagemask($im, 10, 20, 60, 40, 8);
    imagepng($im);
    imagedestroy($im);/**
    马赛克:void imagemask ( resource image, int x1, int y1, int x2, int y2, int deep)
    imagemask() 把坐标 x1,y1 到 x2,y2(图像左上角为 0, 0)的矩形区域加上马赛克。
    deep为模糊程度,数字越大越模糊。
    **/
    /**
     * GD image mask
     *
     * @edit www.jbxue.com
     */
    function imagemask($im, $x1, $y1, $w, $h, $deep) {
        $x2 = min(imagesx($im), $x1 + $w);
        $y2 = min(imagesy($im), $y1 + $h);
        for($x = $x1; $x < $x2; $x += $deep) {
            for ($y = $y1; $y < $y2; $y += $deep) {
                $color = ImageColorAt ($im, $x + round($deep / 2), $y + round($deep / 2));
                imagefilledrectangle ($im, $x, $y, $x + $deep, $y + $deep, $color);
            }
        }
    }
      

  2.   

    直接用你提供的例子成功。function imagemask(&$im, $x1, $y1, $x2, $y2, $deep)
    {
        for($x = $x1; $x < $x2; $x += $deep)
        {
            for ($y = $y1; $y < $y2; $y += $deep)
            {
                $color = ImageColorAt ($im, $x + round($deep / 2), $y + round($deep / 2));
                imagefilledrectangle ($im, $x, $y, $x + $deep, $y + $deep, $color);
            }
        }
    }header("Content-type: image/png");
    $im = imagecreatefromjpeg("http://avatar.csdn.net/B/D/B/1_fdipzone.jpg");
    imagemask($im, 57, 60, 103, 80, 8);
    imagepng($im);
    imagedestroy($im);
      

  3.   

    GOOD  
    4# 5# 都GOOD