• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imagecolorclosest函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: imagecopybicubic

/**
 * Copies a rectangular portion of the source image to another rectangle in the destination image
 *
 * This function calls imagecopyresampled() if it is available and GD version is 2 at least.
 * Otherwise it reimplements the same behaviour. See the PHP manual page for more info.
 *
 * @link http://php.net/manual/en/function.imagecopyresampled.php
 * @param resource $dst_img the destination GD image resource
 * @param resource $src_img the source GD image resource
 * @param int $dst_x vthe X coordinate of the upper left corner in the destination image
 * @param int $dst_y the Y coordinate of the upper left corner in the destination image
 * @param int $src_x the X coordinate of the upper left corner in the source image
 * @param int $src_y the Y coordinate of the upper left corner in the source image
 * @param int $dst_w the width of the destination rectangle
 * @param int $dst_h the height of the destination rectangle
 * @param int $src_w the width of the source rectangle
 * @param int $src_h the height of the source rectangle
 * @return bool tru on success, false otherwise
 */
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:JP-Git,项目名称:moodle,代码行数:51,代码来源:gdlib.php


示例2: generate

 public function generate()
 {
     $findColor = Image_Image::hexColorToArrayColor($this->find);
     $replaceColor = Image_Image::hexColorToArrayColor($this->replace);
     $index = imagecolorclosest($this->_owner->image, $findColor['red'], $findColor['green'], $findColor['blue']);
     //find
     imagecolorset($this->_owner->image, $index, $replaceColor['red'], $replaceColor['green'], $replaceColor['blue']);
     //replace
     unset($index);
     return true;
 }
开发者ID:joogoo,项目名称:php5-image,代码行数:11,代码来源:Colorize.php


示例3: compare

 public static function compare($max_colors, $filename)
 {
     $tally = array();
     // size image to something managable (256 x 256)
     $image_data = getimagesize($filename);
     // if small image then use its current size
     if ($image_data[0] < self::$resize_dim && $image_data[1] < self::$resize_dim) {
         $image = self::createImage($filename, $image_data[2]);
         $width = $image_data[0];
         $height = $image_data[1];
     } else {
         $res = self::createResizedImage($filename, $image_data[0], $image_data[1], $image_data[2]);
         if ($res == false) {
             print "[failed on resize]";
             return false;
         } else {
             $image = $res[0];
             $width = $res[1];
             $height = $res[2];
         }
     }
     // create the comparison palette
     self::createComparisonPalette();
     // loop through x axis
     for ($x = 0; $x < $width; $x++) {
         // loop through y axis
         for ($y = 0; $y < $height; $y++) {
             // compare to find colest match and tally
             list($red, $green, $blue) = self::getRGBFromPixel($image, $x, $y);
             $index = imagecolorclosest(self::$comp_palette, $red, $green, $blue);
             @($tally[$index] = @$tally[$index] + 1);
         }
     }
     // sort the tally results
     arsort($tally);
     $ret_array = array();
     $i = 0;
     $threshold = $width * $height * (self::$threshold_filter / 100);
     // build the return array of the top results
     foreach ($tally as $index => $count) {
         // make sure the count is high enough to be considered significant
         if ($count >= $threshold) {
             $ret_array[self::$swatch_index[$index]] = $count;
             $i++;
         } else {
             break;
         }
         if ($i >= $max_colors) {
             break;
         }
     }
     return $ret_array;
 }
开发者ID:hoalangoc,项目名称:ftf,代码行数:53,代码来源:ColorCompare.php


示例4: toPngColor

 public function toPngColor($img)
 {
     $color = imagecolorexact($img, $this->red, $this->green, $this->blue);
     if ($color == -1) {
         if (imagecolorstotal($img) >= 255) {
             $color = imagecolorclosest($img, $this->red, $this->green, $this->blue);
         } else {
             $color = imagecolorallocate($img, $this->red, $this->green, $this->blue);
         }
     }
     return $color;
 }
开发者ID:eXcomm,项目名称:3D-PHP-Class,代码行数:12,代码来源:Color.class.php


示例5: _get_image_color

 function _get_image_color($im, $r, $g, $b)
 {
     $c = imagecolorexact($im, $r, $g, $b);
     if ($c != -1) {
         return $c;
     }
     $c = imagecolorallocate($im, $r, $g, $b);
     if ($c != -1) {
         return $c;
     }
     return imagecolorclosest($im, $r, $g, $b);
 }
开发者ID:villos,项目名称:tree_admin,代码行数:12,代码来源:Watermark.php


示例6: applyFilter

 /**
  * Applies the filter to the resource
  *
  * @param ImageResource $aResource
  */
 public function applyFilter(ImageResource $aResource)
 {
     $dest = $aResource->getResource();
     if (imageistruecolor($dest)) {
         imagetruecolortopalette($dest, false, 256);
     }
     foreach ($this->search as $search) {
         $searchRgb = new Color($search);
         $index = imagecolorclosest($aResource->getResource(), $searchRgb->getRed(), $searchRgb->getGreen(), $searchRgb->getBlue());
         // get White COlor
         imagecolorset($aResource->getResource(), $index, $this->replace->getRed(), $this->replace->getGreen(), $this->replace->getBlue());
         // SET NEW COLOR
     }
     $aResource->setResource($dest);
 }
开发者ID:elgervb,项目名称:imagemanipulation,代码行数:20,代码来源:ImageFilterReplaceColor.php


示例7: createcolor

 /**
  * Insert a color to the palet or return the color if the color exist
  *
  * @param image $pic the picture where we work on it
  * @param int $c1 red part of the color
  * @param int $c2 green part of the color
  * @param int $c3 blue part of the color
  * @return color the color that we want
  */
 public static function createcolor($pic, $c1, $c2, $c3)
 {
     //get color from palette
     $color = imagecolorexact($pic, $c1, $c2, $c3);
     if ($color == -1) {
         //color does not exist...
         //test if we have used up palette
         if (imagecolorstotal($pic) >= 255) {
             //palette used up; pick closest assigned color
             $color = imagecolorclosest($pic, $c1, $c2, $c3);
         } else {
             //palette NOT used up; assign new color
             $color = imagecolorallocate($pic, $c1, $c2, $c3);
         }
     }
     return $color;
 }
开发者ID:jonathan-vallet,项目名称:craftanat,代码行数:26,代码来源:ColorTool.class.php


示例8: typo3_distortString

function typo3_distortString($img, $text, $tcolor, $bcolor, $angle, $diffx, $diffy, $xpos, $ypos, $letterSpacing, $bold, $fontSize, $fontFile, $useTTF = 0)
{
    // When no TTF get's used.
    $charx = 20;
    $chary = 20;
    $osx = 5;
    $osy = 0;
    $fg = imagecolorallocate($img, $tcolor[0], $tcolor[1], $tcolor[2]);
    $bg = imagecolorallocate($img, $bcolor[0], $bcolor[1], $bcolor[2]);
    for ($x = 0; $x < strlen($text); $x++) {
        $c = substr($text, $x, 1);
        $da = rand(0, $angle * 2) - $angle;
        $dx = intval(rand(0, $diffx * 2) - $diffx);
        $dy = intval(rand(0, $diffy * 2) - $diffy);
        if ($useTTF) {
            $ret = imagettftext($img, $fontSize, $da, $xpos + $dx, $ypos + $dy + $fontSize, $fg, $fontFile, $c);
            if ($bold) {
                $ret = imagettftext($img, $fontSize, $da, $xpos + $dx + 1, $ypos + $dy + $fontSize, $fg, $fontFile, $c);
                $ret = imagettftext($img, $fontSize, $da, $xpos + $dx + 1, $ypos + $dy + $fontSize + 1, $fg, $fontFile, $c);
                $ret = imagettftext($img, $fontSize, $da, $xpos + $dx, $ypos + $dy + $fontSize + 1, $fg, $fontFile, $c);
            }
            $xpos += $ret[2] - $ret[0];
        } else {
            $tmpi = imagecreate($charx, $chary);
            $back = imagecolorallocate($tmpi, $bcolor[0], $bcolor[1], $bcolor[2]);
            $fcol = imagecolorallocate($tmpi, $tcolor[0], $tcolor[1], $tcolor[2]);
            imagefill($tmpi, 0, 0, $back);
            imagestring($tmpi, 5, $osx, $osy, $c, $fcol);
            $rot = imagerotate($tmpi, $da, $back);
            $rback = imagecolorclosest($rot, $bcolor[0], $bcolor[1], $bcolor[2]);
            imagecolortransparent($rot, $rback);
            imagecopymerge($img, $rot, $xpos + $dx, $ypos + $dy, 0, 0, 20, 20, 100);
        }
        $xpos += $letterSpacing;
    }
}
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:36,代码来源:captcha.php


示例9: _a_set_pixel

function _a_set_pixel($im, $x, $y, $filled, $fgcolors)
{
    $rgb = imagecolorat($im, $x, $y);
    $r = $rgb >> 16 & 0xff;
    $g = $rgb >> 8 & 0xff;
    $b = $rgb & 0xff;
    $red = round($r + ($fgcolors['red'] - $r) * $filled);
    $green = round($g + ($fgcolors['green'] - $g) * $filled);
    $blue = round($b + ($fgcolors['blue'] - $b) * $filled);
    imagesetpixel($im, $x, $y, imagecolorclosest($im, $red, $green, $blue));
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:11,代码来源:img.php


示例10: makeThumbWatermark

 function makeThumbWatermark($width = 128, $height = 128)
 {
     $this->fileCheck();
     $image_info = $this->getInfo($this->src_image_name);
     if (!$image_info) {
         return false;
     }
     $src_image_type = $image_info["type"];
     $img = $this->createImage($src_image_type, $this->src_image_name);
     if (!$img) {
         return false;
     }
     $width = $width == 0 ? $image_info["width"] : $width;
     $height = $height == 0 ? $image_info["height"] : $height;
     $width = $width > $image_info["width"] ? $image_info["width"] : $width;
     $height = $height > $image_info["height"] ? $image_info["height"] : $height;
     $srcW = $image_info["width"];
     $srcH = $image_info["height"];
     if ($srcH * $width > $srcW * $height) {
         $width = round($srcW * $height / $srcH);
     } else {
         $height = round($srcH * $width / $srcW);
     }
     //*
     $src_image = @imagecreatetruecolor($width, $height);
     $white = @imagecolorallocate($src_image, 0xff, 0xff, 0xff);
     @imagecolortransparent($src_image, $white);
     @imagefilltoborder($src_image, 0, 0, $white, $white);
     if ($src_image) {
         ImageCopyResampled($src_image, $img, 0, 0, 0, 0, $width, $height, $image_info["width"], $image_info["height"]);
     } else {
         $src_image = imagecreate($width, $height);
         ImageCopyResized($src_image, $img, 0, 0, 0, 0, $width, $height, $image_info["width"], $image_info["height"]);
     }
     $src_image_w = ImageSX($src_image);
     $src_image_h = ImageSY($src_image);
     if ($this->wm_image_name) {
         $wm_image_info = $this->getInfo($this->wm_image_name);
         if (!$wm_image_info) {
             return false;
         }
         $wm_image_type = $wm_image_info["type"];
         $wm_image = $this->createImage($wm_image_type, $this->wm_image_name);
         $wm_image_w = ImageSX($wm_image);
         $wm_image_h = ImageSY($wm_image);
         $temp_wm_image = $this->getPos($src_image_w, $src_image_h, $this->wm_image_pos, $wm_image);
         if ($this->emboss && function_exists("imagefilter")) {
             imagefilter($wm_image, IMG_FILTER_EMBOSS);
             $bgcolor = imagecolorclosest($wm_image, 0x7f, 0x7f, 0x7f);
             imagecolortransparent($wm_image, $bgcolor);
         }
         if (function_exists("ImageAlphaBlending") && IMAGETYPE_PNG == $wm_image_info['type']) {
             ImageAlphaBlending($src_image, true);
         }
         $wm_image_x = $temp_wm_image["dest_x"];
         $wm_image_y = $temp_wm_image["dest_y"];
         if (IMAGETYPE_PNG == $wm_image_info['type']) {
             imageCopy($src_image, $wm_image, $wm_image_x, $wm_image_y, 0, 0, $wm_image_w, $wm_image_h);
         } else {
             imageCopyMerge($src_image, $wm_image, $wm_image_x, $wm_image_y, 0, 0, $wm_image_w, $wm_image_h, $this->wm_image_transition);
         }
     }
     if ($this->wm_text) {
         $this->wm_text = $this->wm_text;
         $temp_wm_text = $this->getPos($src_image_w, $src_image_h, $this->wm_image_pos);
         $wm_text_x = $temp_wm_text["dest_x"];
         $wm_text_y = $temp_wm_text["dest_y"];
         if (preg_match("/([a-f0-9][a-f0-9])([a-f0-9][a-f0-9])([a-f0-9][a-f0-9])/i", $this->wm_text_color, $color)) {
             $red = hexdec($color[1]);
             $green = hexdec($color[2]);
             $blue = hexdec($color[3]);
             $wm_text_color = imagecolorallocate($src_image, $red, $green, $blue);
         } else {
             $wm_text_color = imagecolorallocate($src_image, 255, 255, 255);
         }
         imagettftext($src_image, $this->wm_text_size, $this->wm_angle, $wm_text_x, $wm_text_y, $wm_text_color, $this->wm_text_font, $this->wm_text);
     }
     if ($this->save_file) {
         switch ($src_image_type) {
             case 1:
                 if ($this->gif_enable) {
                     $src_img = ImageGIF($src_image, $this->save_file);
                 } else {
                     $src_img = ImagePNG($src_image, $this->save_file);
                 }
                 break;
             case 2:
                 $src_img = ImageJPEG($src_image, $this->save_file, $this->jpeg_quality);
                 break;
             case 3:
                 $src_img = ImagePNG($src_image, $this->save_file);
                 break;
             default:
                 $src_img = ImageJPEG($src_image, $this->save_file, $this->jpeg_quality);
                 break;
         }
     } else {
         switch ($src_image_type) {
             case 1:
                 if ($this->gif_enable) {
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:MyShop,代码行数:101,代码来源:mdl.gdimage.php


示例11: imagecreatefrombmp

 function imagecreatefrombmp($filename)
 {
     global $gd2;
     $fp = fopen($filename, 'rb');
     $errors = error_reporting(0);
     $header = unpack('vtype/Vsize/Vreserved/Voffset', fread($fp, 14));
     $info = unpack('Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vcolorimportant', fread($fp, 40));
     if ($header['type'] != 0x4d42) {
         false;
     }
     if ($gd2) {
         $dst_img = imagecreatetruecolor($info['width'], $info['height']);
     } else {
         $dst_img = imagecreate($info['width'], $info['height']);
     }
     $palette_size = $header['offset'] - 54;
     $info['ncolor'] = $palette_size / 4;
     $palette = array();
     $palettedata = fread($fp, $palette_size);
     $n = 0;
     for ($j = 0; $j < $palette_size; $j++) {
         $b = ord($palettedata[$j++]);
         $g = ord($palettedata[$j++]);
         $r = ord($palettedata[$j++]);
         $palette[$n++] = imagecolorallocate($dst_img, $r, $g, $b);
     }
     $scan_line_size = $info['bits'] * $info['width'] + 7 >> 3;
     $scan_line_align = $scan_line_size & 3 ? 4 - ($scan_line_size & 3) : 0;
     for ($y = 0, $l = $info['height'] - 1; $y < $info['height']; $y++, $l--) {
         fseek($fp, $header['offset'] + ($scan_line_size + $scan_line_align) * $l);
         $scan_line = fread($fp, $scan_line_size);
         if (strlen($scan_line) < $scan_line_size) {
             continue;
         }
         if ($info['bits'] == 32) {
             $x = 0;
             for ($j = 0; $j < $scan_line_size; $x++) {
                 $b = ord($scan_line[$j++]);
                 $g = ord($scan_line[$j++]);
                 $r = ord($scan_line[$j++]);
                 $j++;
                 $color = imagecolorexact($dst_img, $r, $g, $b);
                 if ($color == -1) {
                     $color = imagecolorallocate($dst_img, $r, $g, $b);
                     // Gah!  Out of colors?  Stupid GD 1... try anyhow.
                     if ($color == -1) {
                         $color = imagecolorclosest($dst_img, $r, $g, $b);
                     }
                 }
                 imagesetpixel($dst_img, $x, $y, $color);
             }
         } elseif ($info['bits'] == 24) {
             $x = 0;
             for ($j = 0; $j < $scan_line_size; $x++) {
                 $b = ord($scan_line[$j++]);
                 $g = ord($scan_line[$j++]);
                 $r = ord($scan_line[$j++]);
                 $color = imagecolorexact($dst_img, $r, $g, $b);
                 if ($color == -1) {
                     $color = imagecolorallocate($dst_img, $r, $g, $b);
                     // Gah!  Out of colors?  Stupid GD 1... try anyhow.
                     if ($color == -1) {
                         $color = imagecolorclosest($dst_img, $r, $g, $b);
                     }
                 }
                 imagesetpixel($dst_img, $x, $y, $color);
             }
         } elseif ($info['bits'] == 16) {
             $x = 0;
             for ($j = 0; $j < $scan_line_size; $x++) {
                 $b1 = ord($scan_line[$j++]);
                 $b2 = ord($scan_line[$j++]);
                 $word = $b2 * 256 + $b1;
                 $b = ($word & 31) * 255 / 31;
                 $g = ($word >> 5 & 31) * 255 / 31;
                 $r = ($word >> 10 & 31) * 255 / 31;
                 // Scale the image colors up properly.
                 $color = imagecolorexact($dst_img, $r, $g, $b);
                 if ($color == -1) {
                     $color = imagecolorallocate($dst_img, $r, $g, $b);
                     // Gah!  Out of colors?  Stupid GD 1... try anyhow.
                     if ($color == -1) {
                         $color = imagecolorclosest($dst_img, $r, $g, $b);
                     }
                 }
                 imagesetpixel($dst_img, $x, $y, $color);
             }
         } elseif ($info['bits'] == 8) {
             $x = 0;
             for ($j = 0; $j < $scan_line_size; $x++) {
                 imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line[$j++])]);
             }
         } elseif ($info['bits'] == 4) {
             $x = 0;
             for ($j = 0; $j < $scan_line_size; $x++) {
                 $byte = ord($scan_line[$j++]);
                 imagesetpixel($dst_img, $x, $y, $palette[(int) ($byte / 16)]);
                 if (++$x < $info['width']) {
                     imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]);
                 }
//.........这里部分代码省略.........
开发者ID:valek0972,项目名称:hackits,代码行数:101,代码来源:Subs-Graphics.php


示例12: imgFolder

function imgFolder()
{
    $a = array(18, 24, 38, 24, 43, 29, 76, 29, 76, 70, 18, 70);
    if (function_exists('imagecreatetruecolor')) {
        $img = imagecreatetruecolor(94, 94);
        $black = imagecolorclosest($img, 0, 0, 0);
        $yellow = imagecolorclosest($img, 250, 240, 0);
        $white = imagecolorclosest($img, 255, 255, 255);
    } else {
        $img = imagecreate(94, 94);
        $black = imagecolorallocate($img, 0, 0, 0);
        $yellow = imagecolorallocate($img, 250, 240, 0);
        $white = imagecolorallocate($img, 255, 255, 255);
    }
    imagefilledrectangle($img, 0, 0, 94, 94, $white);
    if (function_exists('imagesetthickness')) {
        imagesetthickness($img, 1);
    }
    imagefilledpolygon($img, $a, 6, $yellow);
    imagepolygon($img, $a, 6, $black);
    imageline($img, 40, 32, 76, 32, $black);
    imageline($img, 18, 34, 34, 34, $black);
    imageline($img, 34, 34, 40, 32, $black);
    return $img;
}
开发者ID:smokku,项目名称:ThAutoIndex,代码行数:25,代码来源:thautoindex.php


示例13: imagesetpixel

        $height = $height > MAX_SCENE_HEIGHT ? MAX_SCENE_HEIGHT : $height;
        $height = $height < MIN_SCENE_HEIGHT ? MIN_SCENE_HEIGHT : $height;
        $feature_z = MAX_DEPTH - $height * (MAX_DEPTH - MIN_DEPTH) / 256;
        $sep = (int) ((double) (EYE_SEP * $feature_z) / ($feature_z + OBS_DIST));
        $left_px = (int) $x - $sep / 2;
        $right_px = (int) $x + $sep / 2;
        if ($left_px >= 0 && $right_px < $img_width) {
            if (!isset($buffer[$left_px][$y])) {
                $buffer[$left_px][$y] = $colors[rand(1, 255)];
            }
            $buffer[$right_px][$y] = $buffer[$left_px][$y];
        }
    }
    for ($x = 0; $x < $img_width; $x++) {
        if (!isset($buffer[$x][$y])) {
            $buffer[$x][$y] = $colors[rand(1, 255)];
        }
    }
}
/* Output PNG File */
for ($y = 0; $y < $img_height; $y++) {
    for ($x = 0; $x < $img_width; $x++) {
        imagesetpixel($stereo_img, $x, $y, $buffer[$x][$y]);
    }
}
header("Content-type:  image/png");
$black = imagecolorclosest($stereo_img, 0, 0, 0);
$white = imagecolorclosest($stereo_img, 0xff, 0xff, 0xff);
imagefilledrectangle($stereo_img, 0, $img_height - 20, $img_width, $img_height, $black);
imagestring($stereo_img, 1, 5, $img_height - 10, "Made at http://www.coggeshall.org/stereogram.php", $white);
imagepng($stereo_img);
开发者ID:SandyS1,项目名称:presentations,代码行数:31,代码来源:stereogram_create.php


示例14: ellipse

 public function ellipse($bg_colour = "FFFFFF")
 {
     $this->bgc = $bg_colour;
     $this->br = $this->hex2rgb(substr($this->bgc, 0, 2));
     $this->bg = $this->hex2rgb(substr($this->bgc, 2, 2));
     $this->bb = $this->hex2rgb(substr($this->bgc, 4, 2));
     $this->dot = imagecreate(6, 6);
     $this->dot_base = imagecolorallocate($this->dot, $this->br, $this->bg, $this->bb);
     $this->zenitha = imagecolorclosest($this->t, $this->br, $this->bg, $this->bb);
     for ($this->rad = 0; $this->rad < 6.3; $this->rad += 0.005) {
         $this->xpos = floor($this->q + sin($this->rad) * $this->q) / 2;
         $this->ypos = floor($this->r + cos($this->rad) * $this->r) / 2;
         $this->xto = 0;
         if ($this->xpos >= $this->q / 2) {
             $this->xto = $this->q;
         }
         imagecopymerge($this->t, $this->dot, $this->xpos - 3, $this->ypos - 3, 0, 0, 6, 6, 30);
         imagecopymerge($this->t, $this->dot, $this->xpos - 2, $this->ypos - 2, 0, 0, 4, 4, 30);
         imagecopymerge($this->t, $this->dot, $this->xpos - 1, $this->ypos - 1, 0, 0, 2, 2, 30);
         imageline($this->t, $this->xpos, $this->ypos, $this->xto, $this->ypos, $this->zenitha);
     }
     imagedestroy($this->dot);
     $this->efecto[] = "ellipse";
 }
开发者ID:pablius,项目名称:oob-n1,代码行数:24,代码来源:OOB_imagehandling.php


示例15: getClosestColor

 /**
  * Returns closest color index that matches the given RGB value. Uses
  * PHP's imagecolorclosest()
  *
  * @param mixed $R Red or RGBA array
  */
 function getClosestColor($R, $G = null, $B = null)
 {
     if (is_array($R)) {
         return imagecolorclosest($this->handle, $R['red'], $R['green'], $R['blue']);
     } else {
         return imagecolorclosest($this->handle, $R, $G, $B);
     }
 }
开发者ID:trabisdementia,项目名称:xuups,代码行数:14,代码来源:Image.class.php


示例16: text_watermark

 /**
  * Watermark - Text Version
  *
  * @return  bool
  */
 public function text_watermark()
 {
     if (!($src_img = $this->image_create_gd())) {
         return FALSE;
     }
     if ($this->wm_use_truetype === TRUE && !file_exists($this->wm_font_path)) {
         $this->set_error('imglib_missing_font');
         return FALSE;
     }
     // Fetch source image properties
     $this->get_image_properties();
     // Reverse the vertical offset
     // When the image is positioned at the bottom
     // we don't want the vertical offset to push it
     // further down. We want the reverse, so we'll
     // invert the offset. Note: The horizontal
     // offset flips itself automatically
     if ($this->wm_vrt_alignment === 'B') {
         $this->wm_vrt_offset = $this->wm_vrt_offset * -1;
     }
     if ($this->wm_hor_alignment === 'R') {
         $this->wm_hor_offset = $this->wm_hor_offset * -1;
     }
     // Set font width and height
     // These are calculated differently depending on
     // whether we are using the true type font or not
     if ($this->wm_use_truetype === TRUE) {
         if (empty($this->wm_font_size)) {
             $this->wm_font_size = 17;
         }
         if (function_exists('imagettfbbox')) {
             $temp = imagettfbbox($this->wm_font_size, 0, $this->wm_font_path, $this->wm_text);
             $temp = $temp[2] - $temp[0];
             $fontwidth = $temp / strlen($this->wm_text);
         } else {
             $fontwidth = $this->wm_font_size - $this->wm_font_size / 4;
         }
         $fontheight = $this->wm_font_size;
         $this->wm_vrt_offset += $this->wm_font_size;
     } else {
         $fontwidth = imagefontwidth($this->wm_font_size);
         $fontheight = imagefontheight($this->wm_font_size);
     }
     // Set base X and Y axis values
     $x_axis = $this->wm_hor_offset + $this->wm_padding;
     $y_axis = $this->wm_vrt_offset + $this->wm_padding;
     if ($this->wm_use_drop_shadow === FALSE) {
         $this->wm_shadow_distance = 0;
     }
     $this->wm_vrt_alignment = strtoupper($this->wm_vrt_alignment[0]);
     $this->wm_hor_alignment = strtoupper($this->wm_hor_alignment[0]);
     // Set vertical alignment
     if ($this->wm_vrt_alignment === 'M') {
         $y_axis += $this->orig_height / 2 + $fontheight / 2;
     } elseif ($this->wm_vrt_alignment === 'B') {
         $y_axis += $this->orig_height - $fontheight - $this->wm_shadow_distance - $fontheight / 2;
     }
     // Set horizontal alignment
     if ($this->wm_hor_alignment === 'R') {
         $x_axis += $this->orig_width - $fontwidth * strlen($this->wm_text) - $this->wm_shadow_distance;
     } elseif ($this->wm_hor_alignment === 'C') {
         $x_axis += floor(($this->orig_width - $fontwidth * strlen($this->wm_text)) / 2);
     }
     if ($this->wm_use_drop_shadow) {
         // Offset from text
         $x_shad = $x_axis + $this->wm_shadow_distance;
         $y_shad = $y_axis + $this->wm_shadow_distance;
         /* Set RGB values for shadow
          *
          * First character is #, so we don't really need it.
          * Get the rest of the string and split it into 2-length
          * hex values:
          */
         $drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2);
         $drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[1]), hexdec($drp_color[2]));
         // Add the shadow to the source image
         if ($this->wm_use_truetype) {
             imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text);
         } else {
             imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color);
         }
     }
     /* Set RGB values for text
      *
      * First character is #, so we don't really need it.
      * Get the rest of the string and split it into 2-length
      * hex values:
      */
     $txt_color = str_split(substr($this->wm_font_color, 1, 6), 2);
     $txt_color = imagecolorclosest($src_img, hexdec($txt_color[0]), hexdec($txt_color[1]), hexdec($txt_color[2]));
     // Add the text to the source image
     if ($this->wm_use_truetype) {
         imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text);
     } else {
         imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color);
//.........这里部分代码省略.........
开发者ID:pdkhuong,项目名称:VideoFW,代码行数:101,代码来源:Image_lib.php


示例17: imagettftexttexture

function imagettftexttexture(&$im, &$textureim, $size, $angle, $x, $y, $fontfile, $text)
{
    $width = imagesx($im);
    // Get the width of the image
    $height = imagesy($im);
    // Get the height of the image
    $buffer = imagecreate($width, $height);
    // Create the buffer image
    $tile_w = imagesx($textureim);
    // Get the width of the texture image
    $tile_h = imagesy($textureim);
    // Get the height of the texture image
    $fits_x = (int) ($im_w / $tile_w);
    // Find out how many times it fits horizontally
    $fits_y = (int) ($im_h / $tile_h);
    // Find out how many times it fits vertically
    for ($i = 0; $i <= $fits_x; $i++) {
        // Loop through every time (and another, for extra space) it fits horizontally
        $x = (int) ($tile_w * $i);
        // Change the X location based on where in the loop it is
        for ($i2 = 0; $i2 <= $fits_y; $i2++) {
            // Loop through every time it fits vertically
            $y = (int) ($tile_h * $i2);
            // Change the Y location
            $copy = imagecopy($im, $textureim, $x, $y, 0, 0, $tile_w, $tile_h);
            // Copy the image to the X,Y location
        }
    }
    $pink = imagecolorclosest($im, 255, 0, 255);
    // Create magic pink, a color commonly used for masks
    $trans = imagecolortransparent($im, $pink);
    // Make magic pink the transparent color
    imagettftext($im, $size, $angle, $x, $y, -$pink, $fontfile, $text);
    // Draw text over magic pink without aliasing
    imagecopy($buffer, $im, 0, 0, 0, 0, $width, $height);
    // Copy the main image onto the buffer
    imagecopy($im, $buffer, 0, 0, 0, 0, $width, $height);
    // Copy the buffer back onto the main image
    imagedestroy($buffer);
    // Destroy the buffer
}
开发者ID:dennesabing,项目名称:zivsluck,代码行数:41,代码来源:CreateText.php


示例18: getClosestColorIndex

 /**
  * @param       int             red 0-255
  * @param       int             green 0-255
  * @param       int             blue 0-255
  * @return      int             internal color index
  */
 public function getClosestColorIndex($red, $green, $blue)
 {
     // TODO issue with gif and limited color rang
     if (!is_null($this->imageResource)) {
         return imagecolorclosest($this->imageResource, (int) $red, (int) $green, (int) $blue);
     }
     return false;
 }
开发者ID:naucon,项目名称:image,代码行数:14,代码来源:ImageWriter.php


示例19: imagecreatefrombmp

 /**
  * It is set only if it doesn't already exist (for forwards compatiblity.)
  *
  * - It only supports uncompressed bitmaps.
  * - It only supports standard windows bitmaps (no os/2 varients)
  * - Returns an image identifier representing the bitmap image
  * obtained from the given filename.
  *
  * @package Graphics
  * @param string $filename
  * @return resource
  */
 function imagecreatefrombmp($filename)
 {
     global $gd2;
     $fp = fopen($filename, 'rb');
     $errors = error_reporting(0);
     // Unpack the general information about the Bitmap Image File, first 14 Bytes
     $header = unpack('vtype/Vsize/Vreserved/Voffset', fread($fp, 14));
     // Upack the DIB header, it stores detailed information about the bitmap image the pixel format, 40 Bytes long
     $info = unpack('Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vcolorimportant', fread($fp, 40));
     // Not a standard bitmap, bail out
     if ($header['type'] != 0x4d42) {
         return false;
     }
     // Create our image canvas with the given WxH
     if ($gd2) {
         $dst_img = imagecreatetruecolor($info['width'], $info['height']);
     } else {
         $dst_img = imagecreate($info['width'], $info['height']);
     }
     // Color bitCounts 1,4,8 have palette information we use
     if ($info['bits'] == 1 || $info['bits'] == 4 || $info['bits'] == 8) {
         $palette_size = $header['offset'] - 54;
         // Read the palette data
         $palettedata = fread($fp, $palette_size);
         // Create the rgb color array
         $palette = array();
         $n = 0;
         for ($j = 0; $j < $palette_size; $j++) {
             $b = ord($palettedata[$j++]);
             $g = ord($palettedata[$j++]);
             $r = ord($palettedata[$j++]);
             $palette[$n++] = imagecolorallocate($dst_img, $r, $g, $b);
         }
     }
     $scan_line_size = $info['bits'] * $info['width'] + 7 >> 3;
     $scan_line_align = $scan_line_size & 3 ? 4 - ($scan_line_size & 3) : 0;
     for ($y = 0, $l = $info['height'] - 1; $y < $info['height']; $y++, $l--) {
         fseek($fp, $header['offset'] + ($scan_line_size + $scan_line_align) * $l);
         $scan_line = fread($fp, $scan_line_size);
         if (strlen($scan_line) < $scan_line_size) {
             continue;
         }
         // 32 bits per pixel
         if ($info['bits'] == 32) {
             $x = 0;
             for ($j = 0; $j < $scan_line_size; $x++) {
                 $b = ord($scan_line[$j++]);
                 $g = ord($scan_line[$j++]);
                 $r = ord($scan_line[$j++]);
                 $j++;
                 $color = imagecolorexact($dst_img, $r, $g, $b);
                 if ($color == -1) {
                     $color = imagecolorallocate($dst_img, $r, $g, $b);
                     // Gah!  Out of colors?  Stupid GD 1... try anyhow.
                     if ($color == -1) {
                         $color = imagecolorclosest($dst_img, $r, $g, $b);
                     }
                 }
                 imagesetpixel($dst_img, $x, $y, $color);
             }
         } elseif ($info['bits'] == 24) {
             $x = 0;
             for ($j = 0; $j < $scan_line_size; $x++) {
                 $b = ord($scan_line[$j++]);
                 $g = ord($scan_line[$j++]);
                 $r = ord($scan_line[$j++]);
                 $color = imagecolorexact($dst_img, $r, $g, $b);
                 if ($color == -1) {
                     $color = imagecolorallocate($dst_img, $r, $g, $b);
                     // Gah!  Out of colors?  Stupid GD 1... try anyhow.
                     if ($color == -1) {
                         $color = imagecolorclosest($dst_img, $r, $g, $b);
                     }
                 }
                 imagesetpixel($dst_img, $x, $y, $color);
             }
         } elseif ($info['bits'] == 16) {
             $x = 0;
             for ($j = 0; $j < $scan_line_size; $x++) {
                 $b1 = ord($scan_line[$j++]);
                 $b2 = ord($scan_line[$j++]);
                 $word = $b2 * 256 + $b1;
                 $b = ($word & 31) * 255 / 31;
                 $g = ($word >> 5 & 31) * 255 / 31;
                 $r = ($word >> 10 & 31) * 255 / 31;
                 // Scale the image colors up properly.
                 $color = imagecolorexact($dst_img, $r, $g, $b);
                 if ($color == -1) {
//.........这里部分代码省略.........
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:Graphics.subs.php


示例20: generate_image

 /**
  * Generates the actual heatmap.
  */
 private function generate_image($data)
 {
     require_once 'gd-rg.php';
     $time = microtime(1);
     $this->logg('Started at ' . $time);
     // Find the maximum value from the given data.
     $max_data_value = 1;
     foreach ($data as $row) {
         if (isset($row[2]) && $max_data_value < $row[2]) {
             $max_data_value = $row[2];
         }
     }
     $this->logg('Done sorting data at ' . (microtime(1) - $time));
     // Create the heatmap image.
     $im = imagecreatetruecolor($this->get_config('width'), $this->get_config('height'));
     $white = imagecolorallocate($im, 255, 255, 255);
     imagefill($im, 0, 0, $white);
     imagealphablending($im, true);
     imagesavealpha($im, true);
     // Create a separate spot image for each value to be shown, with different
     // amounts of black. Having 25 separate shades of colour looks like a decent
     // number.
     $spots = array();
     for ($i = 0; $i < $this->config['noc']; $i++) {
         // The gradient lib doesn't like too small values for $alpha_end, so we use
         // $noc for that, which happens to work well.
         $alpha_end = $this->map($i, 0, $this->config['noc'] - 1, $this->config['noc'], 255);
         $temp = new gd_gradient_alpha($this->config['r'], $this->config['r'], 'ellipse', '#000', 0x0, $alpha_end, 0);
         $spot = $temp->get_image();
         imagealphablending($spot, true);
         imagesavealpha($spot, true);
         $spots[$i] = $spot;
     }
     $this->logg('Created ' . count($spots) . ' spots at ' . (microtime(1) - $time));
     // Go through the data, and add appropriate spot images to the heatmap
     / 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagecolorclosestalpha函数代码示例发布时间:2022-05-15
下一篇:
PHP imagecolorat函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap