当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageSetPixel函数代码示例

本文整理汇总了PHP中ImageSetPixel函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageSetPixel函数的具体用法?PHP ImageSetPixel怎么用?PHP ImageSetPixel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ImageSetPixel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: UnsharpMask

function UnsharpMask($img, $amount, $radius, $threshold)
{
    ////////////////////////////////////////////////////////////////////////////////////////////////
    ////
    ////                  p h p U n s h a r p M a s k
    ////
    ////        Unsharp mask algorithm by Torstein H�nsi 2003.
    ////                 thoensi_at_netcom_dot_no.
    ////                   Please leave this notice.
    ////
    ///////////////////////////////////////////////////////////////////////////////////////////////
    if ($amount > 500) {
        $amount = 500;
    }
    $amount = $amount * 0.016;
    if ($radius > 50) {
        $radius = 50;
    }
    $radius = $radius * 2;
    if ($threshold > 255) {
        $threshold = 255;
    }
    $radius = abs(round($radius));
    // Only integers make sense.
    if ($radius == 0) {
        return $img;
        imagedestroy($img);
        break;
    }
    $w = imagesx($img);
    $h = imagesy($img);
    $imgCanvas = imagecreatetruecolor($w, $h);
    $imgCanvas2 = imagecreatetruecolor($w, $h);
    $imgBlur = imagecreatetruecolor($w, $h);
    $imgBlur2 = imagecreatetruecolor($w, $h);
    imagecopy($imgCanvas, $img, 0, 0, 0, 0, $w, $h);
    imagecopy($imgCanvas2, $img, 0, 0, 0, 0, $w, $h);
    for ($i = 0; $i < $radius; $i++) {
        imagecopy($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1);
        // up left
        imagecopymerge($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50);
        // down right
        imagecopymerge($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333);
        // down left
        imagecopymerge($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25);
        // up right
        imagecopymerge($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333);
        // left
        imagecopymerge($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25);
        // right
        imagecopymerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20);
        // up
        imagecopymerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667);
        // down
        imagecopymerge($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50);
        // center
        imagecopy($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h);
        imagecopy($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h);
        imagecopymerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
        imagecopymerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
        imagecopymerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
        imagecopymerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
        imagecopymerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
        imagecopymerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20);
        imagecopymerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667);
        imagecopymerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
        imagecopy($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h);
    }
    for ($x = 0; $x < $w; $x++) {
        // each row
        for ($y = 0; $y < $h; $y++) {
            // each pixel
            $rgbOrig = ImageColorAt($imgCanvas2, $x, $y);
            $rOrig = $rgbOrig >> 16 & 0xff;
            $gOrig = $rgbOrig >> 8 & 0xff;
            $bOrig = $rgbOrig & 0xff;
            $rgbBlur = ImageColorAt($imgCanvas, $x, $y);
            $rBlur = $rgbBlur >> 16 & 0xff;
            $gBlur = $rgbBlur >> 8 & 0xff;
            $bBlur = $rgbBlur & 0xff;
            $rNew = abs($rOrig - $rBlur) >= $threshold ? max(0, min(255, $amount * ($rOrig - $rBlur) + $rOrig)) : $rOrig;
            $gNew = abs($gOrig - $gBlur) >= $threshold ? max(0, min(255, $amount * ($gOrig - $gBlur) + $gOrig)) : $gOrig;
            $bNew = abs($bOrig - $bBlur) >= $threshold ? max(0, min(255, $amount * ($bOrig - $bBlur) + $bOrig)) : $bOrig;
            if ($rOrig != $rNew || $gOrig != $gNew || $bOrig != $bNew) {
                $pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
                ImageSetPixel($img, $x, $y, $pixCol);
            }
        }
    }
    imagedestroy($imgCanvas);
    imagedestroy($imgCanvas2);
    imagedestroy($imgBlur);
    imagedestroy($imgBlur2);
    return $img;
}
开发者ID:stephenjschaefer,项目名称:APlusPhotography,代码行数:95,代码来源:picmgmt.inc.php

示例2: image

 private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4)
 {
     $h = count($frame);
     $w = strlen($frame[0]);
     $imgW = $w + 2 * $outerFrame;
     $imgH = $h + 2 * $outerFrame;
     $base_image = imagecreatetruecolor($imgW, $imgH);
     $col[0] = ImageColorAllocate($base_image, 255, 0, 255);
     $col[1] = ImageColorAllocate($base_image, 0, 0, 0);
     imagecolortransparent($base_image, $col[0]);
     imagealphablending($base_image, true);
     imagesavealpha($base_image, true);
     //        imagefill($base_image, 0, 0, $col[0]);
     imagefill($base_image, 0, 0, 0x7fff0000);
     for ($y = 0; $y < $h; $y++) {
         for ($x = 0; $x < $w; $x++) {
             if ($frame[$y][$x] == '1') {
                 ImageSetPixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
             }
         }
     }
     $target_image = ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
     ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
     ImageDestroy($base_image);
     return $target_image;
 }
开发者ID:aplitax,项目名称:PHPQRCode,代码行数:26,代码来源:QRimage.php

示例3: image

 private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $back_color = 0xffffff, $fore_color = 0x0)
 {
     $h = count($frame);
     $w = strlen($frame[0]);
     $imgW = $w + 2 * $outerFrame;
     $imgH = $h + 2 * $outerFrame;
     $base_image = ImageCreate($imgW, $imgH);
     // convert a hexadecimal color code into decimal eps format (green = 0 1 0, blue = 0 0 1, ...)
     $r1 = round(($fore_color & 0xff0000) >> 16, 5);
     $b1 = round(($fore_color & 0xff00) >> 8, 5);
     $g1 = round($fore_color & 0xff, 5);
     // convert a hexadecimal color code into decimal eps format (green = 0 1 0, blue = 0 0 1, ...)
     $r2 = round(($back_color & 0xff0000) >> 16, 5);
     $b2 = round(($back_color & 0xff00) >> 8, 5);
     $g2 = round($back_color & 0xff, 5);
     $col[0] = ImageColorAllocate($base_image, $r2, $b2, $g2);
     $col[1] = ImageColorAllocate($base_image, $r1, $b1, $g1);
     imagefill($base_image, 0, 0, $col[0]);
     for ($y = 0; $y < $h; $y++) {
         for ($x = 0; $x < $w; $x++) {
             if ($frame[$y][$x] == '1') {
                 ImageSetPixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
             }
         }
     }
     $target_image = ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
     ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
     ImageDestroy($base_image);
     return $target_image;
 }
开发者ID:RKathees,项目名称:is-connectors,代码行数:30,代码来源:qrimage.php

示例4: image

 private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $wh = false)
 {
     $h = count($frame);
     $w = strlen($frame[0]);
     $imgW = $w + 2 * $outerFrame;
     $imgH = $h + 2 * $outerFrame;
     $base_image = ImageCreate($imgW, $imgH);
     $col[0] = ImageColorAllocate($base_image, 255, 255, 255);
     $col[1] = ImageColorAllocate($base_image, 0, 0, 0);
     imagefill($base_image, 0, 0, $col[0]);
     for ($y = 0; $y < $h; $y++) {
         for ($x = 0; $x < $w; $x++) {
             if ($frame[$y][$x] == '1') {
                 ImageSetPixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
             }
         }
     }
     $www = $imgW * $pixelPerPoint;
     $hhh = $imgH * $pixelPerPoint;
     if (is_array($wh)) {
         $www = $wh[0];
         $hhh = $wh[1];
     }
     $target_image = ImageCreate($www, $hhh);
     ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $www, $hhh, $imgW, $imgH);
     ImageDestroy($base_image);
     return $target_image;
 }
开发者ID:codingoneapp,项目名称:codingone,代码行数:28,代码来源:qrimage.php

示例5: ImageCopyBicubic

/**
 *
 * long description
 * @global object
 * @param object $dst_img
 * @param object $src_img
 * @param int $dst_x
 * @param int $dst_y
 * @param int $src_x
 * @param int $src_y
 * @param int $dst_w
 * @param int $dst_h
 * @param int $src_w
 * @param int $src_h
 * @return bool
 * @todo Finish documenting this function
 */
function ImageCopyBicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
{
    global $CFG;
    if (function_exists('ImageCopyResampled') and $CFG->gdversion >= 2) {
        return ImageCopyResampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
    }
    $totalcolors = imagecolorstotal($src_img);
    for ($i = 0; $i < $totalcolors; $i++) {
        if ($colors = ImageColorsForIndex($src_img, $i)) {
            ImageColorAllocate($dst_img, $colors['red'], $colors['green'], $colors['blue']);
        }
    }
    $scaleX = ($src_w - 1) / $dst_w;
    $scaleY = ($src_h - 1) / $dst_h;
    $scaleX2 = $scaleX / 2.0;
    $scaleY2 = $scaleY / 2.0;
    for ($j = 0; $j < $dst_h; $j++) {
        $sY = $j * $scaleY;
        for ($i = 0; $i < $dst_w; $i++) {
            $sX = $i * $scaleX;
            $c1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int) $sX, (int) $sY + $scaleY2));
            $c2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int) $sX, (int) $sY));
            $c3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int) $sX + $scaleX2, (int) $sY + $scaleY2));
            $c4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int) $sX + $scaleX2, (int) $sY));
            $red = (int) (($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) / 4);
            $green = (int) (($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) / 4);
            $blue = (int) (($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) / 4);
            $color = ImageColorClosest($dst_img, $red, $green, $blue);
            ImageSetPixel($dst_img, $i + $dst_x, $j + $dst_y, $color);
        }
    }
}
开发者ID:vuchannguyen,项目名称:web,代码行数:49,代码来源:gdlib.php

示例6: display

 /**
 * $IMG_WIDTH = 100; //图像宽度
 		$IMG_HEIGHT = 23; //图像高度
 		$SESSION_VDCODE = ''; //Session变量名称
 * $operator =  '+-'; //运算符
 */
 public static function display($IMG_WIDTH = 70, $IMG_HEIGHT = 25, $SESSION_VDCODE = 'vdcode', $operator = '+')
 {
     $session_id = session_id();
     if (empty($session_id)) {
         @session_start();
     }
     $code = array();
     $num1 = $code[] = mt_rand(1, 9);
     $code[] = '+';
     //{mt_rand(0,1)};
     $num2 = $code[] = mt_rand(1, 9);
     $codestr = implode('', $code);
     //eval("\$result = ".implode('',$code).";");
     $code[] = '=';
     $_SESSION[$SESSION_VDCODE] = (int) $num1 + (int) $num2;
     $img = ImageCreate($IMG_WIDTH, $IMG_HEIGHT);
     ImageColorAllocate($img, mt_rand(230, 250), mt_rand(230, 250), mt_rand(230, 250));
     $color = ImageColorAllocate($img, 0, 0, 0);
     $offset = 0;
     foreach ($code as $char) {
         $offset += 15;
         $txtcolor = ImageColorAllocate($img, mt_rand(0, 255), mt_rand(0, 150), mt_rand(0, 255));
         ImageChar($img, mt_rand(3, 5), $offset, mt_rand(1, 5), $char, $txtcolor);
     }
     for ($i = 0; $i < 100; $i++) {
         $pxcolor = ImageColorAllocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         ImageSetPixel($img, mt_rand(0, $IMG_WIDTH), mt_rand(0, $IMG_HEIGHT), $pxcolor);
     }
     header('Content-type: image/png');
     ImagePng($img);
     exit;
 }
开发者ID:ahmatjan,项目名称:Scene-Editor-for-mobile,代码行数:38,代码来源:NumberCaptcha.php

示例7: image

 private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $color = array())
 {
     $h = count($frame);
     $w = strlen($frame[0]);
     $imgW = $w + 2 * $outerFrame;
     $imgH = $h + 2 * $outerFrame;
     $base_image = ImageCreate($imgW, $imgH);
     $col[0] = ImageColorAllocate($base_image, 255, 255, 255);
     if ($color) {
         $col[1] = ImageColorAllocate($base_image, $color[0], $color[1], $color[2]);
     } else {
         $col[1] = ImageColorAllocate($base_image, 0, 0, 0);
     }
     imagefill($base_image, 0, 0, $col[0]);
     for ($y = 0; $y < $h; $y++) {
         for ($x = 0; $x < $w; $x++) {
             if ($frame[$y][$x] == '1') {
                 ImageSetPixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
             }
         }
     }
     $target_image = ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
     ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
     ImageDestroy($base_image);
     return $target_image;
 }
开发者ID:barricade86,项目名称:raui,代码行数:26,代码来源:qrimage.php

示例8: ApplyMask

function ApplyMask(&$image, $mask)
{
    // Create copy of mask as mask may not be the same size as image
    $mask_resized = ImageCreateTrueColor(ImageSX($image), ImageSY($image));
    ImageCopyResampled($mask_resized, $mask, 0, 0, 0, 0, ImageSX($image), ImageSY($image), ImageSX($mask), ImageSY($mask));
    // Create working temp
    $mask_blendtemp = ImageCreateTrueColor(ImageSX($image), ImageSY($image));
    $color_background = ImageColorAllocate($mask_blendtemp, 0, 0, 0);
    ImageFilledRectangle($mask_blendtemp, 0, 0, ImageSX($mask_blendtemp), ImageSY($mask_blendtemp), $color_background);
    // switch off single color alph and switch on full alpha channel
    ImageAlphaBlending($mask_blendtemp, false);
    ImageSaveAlpha($mask_blendtemp, true);
    // loop the entire image and set pixels, this will be slow for large images
    for ($x = 0; $x < ImageSX($image); $x++) {
        for ($y = 0; $y < ImageSY($image); $y++) {
            $RealPixel = GetPixelColor($image, $x, $y);
            $MaskPixel = GrayscalePixel(GetPixelColor($mask_resized, $x, $y));
            $MaskAlpha = 127 - Floor($MaskPixel['red'] / 2) * (1 - $RealPixel['alpha'] / 127);
            $newcolor = ImageColorAllocateAlpha($mask_blendtemp, $RealPixel['red'], $RealPixel['green'], $RealPixel['blue'], $MaskAlpha);
            ImageSetPixel($mask_blendtemp, $x, $y, $newcolor);
        }
    }
    // don't need the mask copy anymore
    ImageDestroy($mask_resized);
    // switch off single color alph and switch on full alpha channel
    ImageAlphaBlending($image, false);
    ImageSaveAlpha($image, true);
    // replace the image with the blended temp
    ImageCopy($image, $mask_blendtemp, 0, 0, 0, 0, ImageSX($mask_blendtemp), ImageSY($mask_blendtemp));
    ImageDestroy($mask_blendtemp);
}
开发者ID:vinorodrigues,项目名称:wpts-favicons,代码行数:31,代码来源:fakeapple.php

示例9: generateImage

 function generateImage($token)
 {
     $iFont = 5;
     // Font ID
     $iSpacing = 2;
     // Spacing between characters
     $iDisplacement = 5;
     // Vertical chracter displacement
     // Establish font metric and image size
     $iCharWidth = ImageFontWidth($iFont);
     $iCharHeight = ImageFontHeight($iFont);
     $iWidth = strlen($token) * ($iCharWidth + $iSpacing);
     $iHeight = $iCharHeight + 2 * $iDisplacement;
     // Create the image
     $pic = ImageCreate($iWidth, $iHeight);
     // Allocate a background and foreground colour
     $col = array('white' => ImageColorAllocate($pic, 255, 255, 255), 'blue' => ImageColorAllocate($pic, 45, 45, 100), 'green' => ImageColorAllocate($pic, 45, 100, 45), 'red' => ImageColorAllocate($pic, 100, 45, 45), 'purple' => ImageColorAllocate($pic, 100, 45, 100), 'grey' => ImageColorAllocate($pic, 225, 225, 225), 'grey2' => ImageColorAllocate($pic, 200, 200, 200));
     for ($x = 0; $x < $iWidth; $x += 2) {
         for ($y = 0; $y < $iHeight; $y += 2) {
             ImageSetPixel($pic, $x, $y, $col['grey']);
         }
     }
     $iX = 1;
     for ($i = 0; $i < strlen($token); $i++) {
         ImageChar($pic, $iFont - 1, $iX, $iDisplacement - rand(-$iDisplacement, $iDisplacement), $token[$i], $col['grey2']);
         $iX += $iCharWidth + $iSpacing;
     }
     $iX = 2;
     $c = array('blue', 'green', 'red', 'purple');
     for ($i = 0; $i < strlen($token); $i++) {
         $colour = $c[rand(0, count($c) - 1)];
         ImageChar($pic, $iFont, $iX, $iDisplacement - rand(-$iDisplacement, $iDisplacement), $token[$i], $col[$colour]);
         $iX += $iCharWidth + $iSpacing;
     }
     for ($x = 1; $x < $iWidth; $x += 4) {
         for ($y = 1; $y < $iHeight; $y += 4) {
             ImageSetPixel($pic, $x, $y, $col['white']);
         }
     }
     // Draw some lines
     for ($i = 0; $i < 4; $i++) {
         ImageLine($pic, rand(0, $iWidth / 2), rand(0, $iHeight / 2), rand($iWidth / 2, $iWidth), rand($iHeight / 2, $iHeight), $col['white']);
     }
     ob_start();
     if (function_exists('imagejpeg')) {
         ImageJPEG($pic);
     } elseif (function_exists('imagepng')) {
         ImagePNG($pic);
     } else {
         ob_end_clean();
         return false;
     }
     $data = ob_get_contents();
     ob_end_clean();
     ImageDestroy($pic);
     return $data;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:57,代码来源:Turing.php

示例10: show_gd_img

function show_gd_img($content = "")
{
    $content = '  ' . preg_replace("/(\\w)/", "\\1 ", $content) . ' ';
    $gd_version = 2;
    @header("Content-Type: image/jpeg");
    $tmp_x = 140;
    $tmp_y = 20;
    $image_x = 210;
    $image_y = 65;
    $circles = 3;
    if ($gd_version == 1) {
        $tmp = imagecreate($tmp_x, $tmp_y);
        $im = imagecreate($image_x, $image_y);
    } else {
        $tmp = imagecreatetruecolor($tmp_x, $tmp_y);
        $im = imagecreatetruecolor($image_x, $image_y);
    }
    $white = ImageColorAllocate($tmp, 255, 255, 255);
    $black = ImageColorAllocate($tmp, 0, 0, 0);
    $grey = ImageColorAllocate($tmp, 210, 210, 210);
    imagefill($tmp, 0, 0, $white);
    for ($i = 1; $i <= $circles; $i++) {
        $values = array(0 => rand(0, $tmp_x - 10), 1 => rand(0, $tmp_y - 3), 2 => rand(0, $tmp_x - 10), 3 => rand(0, $tmp_y - 3), 4 => rand(0, $tmp_x - 10), 5 => rand(0, $tmp_y - 3), 6 => rand(0, $tmp_x - 10), 7 => rand(0, $tmp_y - 3), 8 => rand(0, $tmp_x - 10), 9 => rand(0, $tmp_y - 3), 10 => rand(0, $tmp_x - 10), 11 => rand(0, $tmp_y - 3));
        $randomcolor = imagecolorallocate($tmp, rand(100, 255), rand(100, 255), rand(100, 255));
        imagefilledpolygon($tmp, $values, 6, $randomcolor);
    }
    imagestring($tmp, 5, 0, 2, $content, $black);
    //-----------------------------------------
    // Distort by resizing
    //-----------------------------------------
    imagecopyresized($im, $tmp, 0, 0, 0, 0, $image_x, $image_y, $tmp_x, $tmp_y);
    imagedestroy($tmp);
    $white = ImageColorAllocate($im, 255, 255, 255);
    $black = ImageColorAllocate($im, 0, 0, 0);
    $grey = ImageColorAllocate($im, 100, 100, 100);
    $random_pixels = $image_x * $image_y / 10;
    for ($i = 0; $i < $random_pixels; $i++) {
        ImageSetPixel($im, rand(0, $image_x), rand(0, $image_y), $black);
    }
    $no_x_lines = ($image_x - 1) / 5;
    for ($i = 0; $i <= $no_x_lines; $i++) {
        // X lines
        ImageLine($im, $i * $no_x_lines, 0, $i * $no_x_lines, $image_y, $grey);
        // Diag lines
        ImageLine($im, $i * $no_x_lines, 0, $i * $no_x_lines + $no_x_lines, $image_y, $grey);
    }
    $no_y_lines = ($image_y - 1) / 5;
    for ($i = 0; $i <= $no_y_lines; $i++) {
        ImageLine($im, 0, $i * $no_y_lines, $image_x, $i * $no_y_lines, $grey);
    }
    ImageJPEG($im);
    ImageDestroy($im);
    exit;
}
开发者ID:CHEZDESIGN,项目名称:mytorrent,代码行数:54,代码来源:GD_Security_image.php

示例11: IndexAction

 function IndexAction()
 {
     $str = "23456789ABCDEFGHJKMNPQRSTUVWXYZ";
     $code_str = str_shuffle($str);
     $code = str_split(substr($code_str, 0, 4));
     $_SESSION['VerifyCode'] = strtolower(implode('', $code));
     $width = 115;
     $height = 29;
     $im = ImageCreate($width, $height);
     // 创建图形
     ImageColorAllocate($im, 255, 255, 255);
     // 填充背景颜色为白色
     // 用淡色给图形添加杂色
     for ($i = 0; $i < 100; $i++) {
         $pxcolor = ImageColorAllocate($im, 230, 104, 66);
         ImageSetPixel($im, mt_rand(0, $width), mt_rand(0, $height), $pxcolor);
     }
     // 用深色调绘制边框
     $bordercolor = ImageColorAllocate($im, 255, 255, 255);
     ImageRectangle($im, 0, 0, $width - 1, $height - 1, $bordercolor);
     $offset = rand(10, 30);
     $font = array('View/font/UniversityRomanStd.otf');
     foreach ($code as $char) {
         $textcolor = ImageColorAllocate($im, 230, 104, 106);
         shuffle($font);
         imagettftext($im, 22, rand(-20, 40), $offset, 26, $textcolor, $font[0], $char);
         $offset += $width / 5 - rand(0, 2);
     }
     $code_str = str_shuffle($str);
     $code = str_split(substr($code_str, 0, 5));
     // 干扰字符
     $offset = rand(10, 30);
     foreach ($code as $char) {
         $textcolor = ImageColorAllocate($im, 230, 104, 66);
         shuffle($font);
         imagettftext($im, 8, rand(-20, 40), $offset, 26, $textcolor, $font[0], $char);
         $offset += rand(5, 10);
     }
     // 禁止缓存
     header("pragma:no-cache\r\n");
     header("Cache-Control:no-cache\r\n");
     header("Expires:0\r\n");
     if (ImageTypes() & IMG_PNG) {
         header('Content-Type:image/png');
         ImagePNG($im);
     } elseif (ImageTypes() & IMG_JPEG) {
         header('Content-Type:image/jpeg');
         ImageJPEG($im);
     } else {
         header('Content-Type:image/gif');
         ImageGif($im);
     }
 }
开发者ID:logdns,项目名称:amh-4.2,代码行数:53,代码来源:VerifyCode.php

示例12: image_resize_sepia

function image_resize_sepia(&$src_im, $quality = 60)
{
    $src_x = ceil(imagesx($src_im));
    $src_y = ceil(imagesy($src_im));
    $dst_x = $src_x;
    $dst_y = $src_y;
    $dst_im = ImageCreateTrueColor($dst_x, $dst_y);
    // Benötigt PHP > 4.3.2
    if (function_exists('imageantialias')) {
        imageantialias($dst_im, TRUE);
    }
    ImageCopyResampled($dst_im, $src_im, 0, 0, 0, 0, $dst_x, $dst_y, $src_x, $src_y);
    // Change style of image pixelwise
    for ($y = 0; $y < $dst_y; $y++) {
        for ($x = 0; $x < $dst_x; $x++) {
            $col = ImageColorAt($dst_im, $x, $y);
            $r = ($col & 0xff0000) >> 16;
            $g = ($col & 0xff00) >> 8;
            $b = $col & 0xff;
            $grey = (min($r, $g, $b) + max($r, $g, $b)) / 2;
            // Boost  colors
            $boost = 1.2;
            $boostborder = 250;
            for ($i = 0; $i < 25; $i++) {
                if ($grey > $boostborder) {
                    $grey = $grey * $boost;
                    break;
                }
                $boost -= 0.01;
                $boostborder -= 10;
            }
            // Set sepia palette
            $r = $grey * 1.01;
            $g = $grey * 0.98;
            $b = $grey * 0.9;
            // Correct max values
            $r = $r > 255 ? 255 : $r;
            $g = $g > 255 ? 255 : $g;
            $b = $b > 255 ? 255 : $b;
            $col = ImageColorAllocate($dst_im, $r, $g, $b);
            ImageSetPixel($dst_im, $x, $y, $col);
        }
    }
    $src_im = $dst_im;
}
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:45,代码来源:filter.sepia.inc.php

示例13: createRainGraph

 public function createRainGraph($hrf_list)
 {
     $image = imagecreate($this->x_size, $this->y_size);
     $color[0] = imagecolorallocate($image, 250, 250, 250);
     //$no_data_color
     $color[1] = imagecolorallocate($image, 255, 200, 0);
     //$sun_color
     $color[2] = imagecolorallocate($image, 156, 156, 255);
     //$low_rain_color
     $color[3] = imagecolorallocate($image, 0, 0, 255);
     //$moderate_rain_color
     $color[4] = imagecolorallocate($image, 0, 0, 128);
     //$heavy_rain_color
     foreach ($hrf_list as $hrf) {
         $date = DateTime::createFromFormat('Ymd', $hrf->getDate());
         $x = date('z', $date->format('U')) - 1;
         $y = $this->y_size - (60 * $hrf->getHour() + $hrf->getMinutes()) / 5 - 1;
         ImageSetPixel($image, $x, $y, $color[$hrf->getValues()[0]]);
     }
     imagepng($image, dirname(__FILE__) . "/../../year_rain_graph.png");
 }
开发者ID:nviel,项目名称:rain_quality,代码行数:21,代码来源:RainGraphService.php

示例14: image

 private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $QR_COLOR, $QR_COLORBG)
 {
     $h = count($frame);
     $w = strlen(trim($frame[0]));
     $imgW = $w + 2 * $outerFrame;
     $imgH = $h + 2 * $outerFrame;
     $base_image = ImageCreate($imgW, $imgH);
     $col[0] = ImageColorAllocate($base_image, $QR_COLORBG["R"], $QR_COLORBG["G"], $QR_COLORBG["B"]);
     $col[1] = ImageColorAllocate($base_image, $QR_COLOR["R"], $QR_COLOR["G"], $QR_COLOR["B"]);
     imagefill($base_image, 0, 0, $col[0]);
     for ($y = 0; $y < $h; $y++) {
         for ($x = 0; $x < $w; $x++) {
             if ($frame[$y][$x] == '1') {
                 ImageSetPixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
             }
         }
     }
     $target_image = ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
     ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
     ImageDestroy($base_image);
     return $target_image;
 }
开发者ID:nProfessor,项目名称:Mytb,代码行数:22,代码来源:qrimage.php

示例15: make

 public static function make()
 {
     $sessionvar = 'vdcode';
     //Session变量名称
     $width = 150;
     //图像宽度
     $height = 20;
     //图像高度
     $ans = mt_rand(0, 9);
     $p1 = mt_rand(1, 9);
     if ($p1 <= $ans) {
         $p2 = $ans - $p1;
         $operator = '+';
     } else {
         $p2 = $p1 - $ans;
         $operator = '-';
     }
     $code = array();
     $code[] = $p1;
     $code[] = $operator;
     $code[] = $p2;
     $code[] = '=';
     $code[] = $ans;
     $_SESSION[$sessionvar] = $ans;
     $img = ImageCreate($width, $height);
     ImageColorAllocate($img, mt_rand(230, 250), mt_rand(230, 250), mt_rand(230, 250));
     $color = ImageColorAllocate($img, 0, 0, 0);
     $offset = 0;
     foreach ($code as $char) {
         $offset += 20;
         $txtcolor = ImageColorAllocate($img, mt_rand(0, 255), mt_rand(0, 150), mt_rand(0, 255));
         ImageChar($img, mt_rand(3, 5), $offset, mt_rand(3, 5), $char, $txtcolor);
     }
     for ($i = 0; $i < 100; $i++) {
         $pxcolor = ImageColorAllocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         ImageSetPixel($img, mt_rand(0, $width), mt_rand(0, $height), $pxcolor);
     }
     return ImagePng($img);
 }
开发者ID:hyfjjjj,项目名称:HHA-Web,代码行数:39,代码来源:Utils.php


注:本文中的ImageSetPixel函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。