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


PHP ImageColorClosest函数代码示例

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


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

示例1: 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

示例2: frame

 function frame($light_colour = "FFFFFF", $dark_colour = "000000", $mid_width = 4, $frame_colour = "")
 {
     $this->rw = $mid_width;
     $this->dh = $dark_colour;
     $this->lh = $light_colour;
     $this->frc = $frame_colour;
     $this->fr = $this->hex2rgb(substr($this->dh, 0, 2));
     $this->fg = $this->hex2rgb(substr($this->dh, 2, 2));
     $this->fb = $this->hex2rgb(substr($this->dh, 4, 2));
     $this->gr = $this->hex2rgb(substr($this->lh, 0, 2));
     $this->gg = $this->hex2rgb(substr($this->lh, 2, 2));
     $this->gb = $this->hex2rgb(substr($this->lh, 4, 2));
     $this->zen = @ImageColorClosest($this->t, $this->gr, $this->gg, $this->gb);
     $this->nad = @ImageColorClosest($this->t, $this->fr, $this->fg, $this->fb);
     $this->mid = $this->frc == "" ? @ImageColorClosest($this->t, ($this->gr + $this->fr) / 2, ($this->gg + $this->fg) / 2, ($this->gb + $this->fb) / 2) : ImageColorClosest($this->t, $this->hex2rgb(substr($this->frc, 0, 2)), $this->hex2rgb(substr($this->frc, 2, 2)), $this->hex2rgb(substr($this->frc, 4, 2)));
     @imageline($this->t, 0, 0, $this->q, 0, $this->zen);
     @imageline($this->t, 0, 0, 0, $this->r, $this->zen);
     @imageline($this->t, $this->q - 1, 0, $this->q - 1, $this->r, $this->nad);
     @imageline($this->t, 0, $this->r - 1, $this->q, $this->r - 1, $this->nad);
     @imageline($this->t, $this->rw + 1, $this->r - ($this->rw + 2), $this->q - ($this->rw + 2), $this->r - ($this->rw + 2), $this->zen);
     // base in
     @imageline($this->t, $this->q - ($this->rw + 2), $this->rw + 1, $this->q - ($this->rw + 2), $this->r - ($this->rw + 2), $this->zen);
     // right in
     @imageline($this->t, $this->rw + 1, $this->rw + 1, $this->q - ($this->rw + 1), $this->rw + 1, $this->nad);
     @imageline($this->t, $this->rw + 1, $this->rw + 1, $this->rw + 1, $this->r - ($this->rw + 1), $this->nad);
     for ($this->crw = 0; $this->crw < $this->rw; $this->crw++) {
         @imageline($this->t, $this->crw + 1, $this->crw + 1, $this->q - ($this->crw + 1), $this->crw + 1, $this->mid);
         // top
         @imageline($this->t, $this->crw + 1, $this->r - ($this->crw + 2), $this->q - ($this->crw + 1), $this->r - ($this->crw + 2), $this->mid);
         // base
         @imageline($this->t, $this->crw + 1, $this->crw + 1, $this->crw + 1, $this->r - ($this->crw + 1), $this->mid);
         //left
         @imageline($this->t, $this->q - ($this->crw + 2), $this->crw, $this->q - ($this->crw + 2), $this->r - ($this->crw + 1), $this->mid);
         // right
     }
 }
开发者ID:shophelfer,项目名称:shophelfer.com-shop,代码行数:36,代码来源:image_manipulator_GD2.php

示例3: _imageCopyResampledWorkaround2

 /**
  * alternative workaround function for bicubic resizing. works well for downsizing and upsizing. VERY VERY slow. taken from php.net comments
  *
  * @access private
  */
 function _imageCopyResampledWorkaround2(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
 {
     ImagePaletteCopy($dst_img, $src_img);
     $rX = $src_w / $dst_w;
     $rY = $src_h / $dst_h;
     $w = 0;
     for ($y = $dst_y; $y < $dst_h; $y++) {
         $ow = $w;
         $w = round(($y + 1) * $rY);
         $t = 0;
         for ($x = $dst_x; $x < $dst_w; $x++) {
             $r = $g = $b = 0;
             $a = 0;
             $ot = $t;
             $t = round(($x + 1) * $rX);
             for ($u = 0; $u < $w - $ow; $u++) {
                 for ($p = 0; $p < $t - $ot; $p++) {
                     $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $ot + $p, $ow + $u));
                     $r += $c['red'];
                     $g += $c['green'];
                     $b += $c['blue'];
                     $a++;
                 }
             }
             ImageSetPixel($dst_img, $x, $y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
         }
     }
 }
开发者ID:AntoxaZ,项目名称:chat,代码行数:33,代码来源:Image_Toolbox.class.php

示例4: ImageCopyResampleBicubic

 /**
  * @param $dst_img
  * @param $src_img
  * @param $dst_x
  * @param $dst_y
  * @param $src_x
  * @param $src_y
  * @param $dst_w
  * @param $dst_h
  * @param $src_w
  * @param $src_h
  */
 function ImageCopyResampleBicubic(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
 {
     $palsize = ImageColorsTotal($src_img);
     for ($i = 0; $i < $palsize; $i++) {
         // get palette.
         $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 = (int) ($scaleX / 2);
     $scaleY2 = (int) ($scaleY / 2);
     for ($j = $src_y; $j < $dst_h; $j++) {
         $sY = (int) ($j * $scaleY);
         $y13 = $sY + $scaleY2;
         for ($i = $src_x; $i < $dst_w; $i++) {
             $sX = (int) ($i * $scaleX);
             $x34 = $sX + $scaleX2;
             $color1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $sX, $y13));
             $color2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $sX, $sY));
             $color3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $x34, $y13));
             $color4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $x34, $sY));
             $red = ($color1['red'] + $color2['red'] + $color3['red'] + $color4['red']) / 4;
             $green = ($color1['green'] + $color2['green'] + $color3['green'] + $color4['green']) / 4;
             $blue = ($color1['blue'] + $color2['blue'] + $color3['blue'] + $color4['blue']) / 4;
             ImageSetPixel($dst_img, $i + $dst_x - $src_x, $j + $dst_y - $src_y, ImageColorClosest($dst_img, $red, $green, $blue));
         }
     }
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:41,代码来源:imagegallib.php

示例5: PlotPixelsGD

 function PlotPixelsGD(&$BMPdata, $truecolor = true)
 {
     $imagewidth = $BMPdata['header']['raw']['width'];
     $imageheight = $BMPdata['header']['raw']['height'];
     if ($truecolor) {
         $gd = @ImageCreateTrueColor($imagewidth, $imageheight);
     } else {
         $gd = @ImageCreate($imagewidth, $imageheight);
         if (!empty($BMPdata['palette'])) {
             // create GD palette from BMP palette
             foreach ($BMPdata['palette'] as $dummy => $color) {
                 list($r, $g, $b) = $this->IntColor2RGB($color);
                 ImageColorAllocate($gd, $r, $g, $b);
             }
         } else {
             // create 216-color websafe palette
             for ($r = 0x0; $r <= 0xff; $r += 0x33) {
                 for ($g = 0x0; $g <= 0xff; $g += 0x33) {
                     for ($b = 0x0; $b <= 0xff; $b += 0x33) {
                         ImageColorAllocate($gd, $r, $g, $b);
                     }
                 }
             }
         }
     }
     if (!is_resource($gd)) {
         return false;
     }
     foreach ($BMPdata['data'] as $row => $colarray) {
         @set_time_limit(30);
         foreach ($colarray as $col => $color) {
             list($red, $green, $blue) = $this->IntColor2RGB($color);
             if ($truecolor) {
                 $pixelcolor = ImageColorAllocate($gd, $red, $green, $blue);
             } else {
                 $pixelcolor = ImageColorClosest($gd, $red, $green, $blue);
             }
             ImageSetPixel($gd, $col, $row, $pixelcolor);
         }
     }
     return $gd;
 }
开发者ID:myindexlike,项目名称:MODX.snippets,代码行数:42,代码来源:phpthumb.bmp.php

示例6: imageCopyResampledBicubic

 public static function imageCopyResampledBicubic(&$dst_image, &$src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
 {
     // We should first cut the piece we are interested in from the source
     $src_img = ImageCreateTrueColor($src_w, $src_h);
     imagecopy($src_img, $src_image, 0, 0, $src_x, $src_y, $src_w, $src_h);
     // This one is used as temporary image
     $dst_img = ImageCreateTrueColor($dst_w, $dst_h);
     ImagePaletteCopy($dst_img, $src_img);
     $rX = $src_w / $dst_w;
     $rY = $src_h / $dst_h;
     $w = 0;
     for ($y = 0; $y < $dst_h; $y++) {
         $ow = $w;
         $w = round(($y + 1) * $rY);
         $t = 0;
         for ($x = 0; $x < $dst_w; $x++) {
             $r = $g = $b = 0;
             $a = 0;
             $ot = $t;
             $t = round(($x + 1) * $rX);
             for ($u = 0; $u < $w - $ow; $u++) {
                 for ($p = 0; $p < $t - $ot; $p++) {
                     $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $ot + $p, $ow + $u));
                     $r += $c['red'];
                     $g += $c['green'];
                     $b += $c['blue'];
                     $a++;
                 }
             }
             ImageSetPixel($dst_img, $x, $y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
         }
     }
     // Apply the temp image over the returned image and use the destination x,y coordinates
     imagecopy($dst_image, $dst_img, $dst_x, $dst_y, 0, 0, $dst_w, $dst_h);
     // We should return true since ImageCopyResampled/ImageCopyResized do it
     return true;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:37,代码来源:image.php

示例7: unifyColors

 /**
  * Unifies all colors given in the colArr color array to the first color in the array.
  *
  * @param resource $img Image resource
  * @param array $colArr Array containing RGB color arrays
  * @param bool $closest
  * @return int The index of the unified color
  */
 public function unifyColors(&$img, $colArr, $closest = false)
 {
     $retCol = -1;
     if (is_array($colArr) && !empty($colArr) && function_exists('imagepng') && function_exists('imagecreatefrompng')) {
         $firstCol = array_shift($colArr);
         $firstColArr = $this->convertColor($firstCol);
         $origName = $preName = $this->randomName() . '.png';
         $postName = $this->randomName() . '.png';
         $tmpImg = null;
         if (count($colArr) > 1) {
             $this->imageWrite($img, $preName);
             $firstCol = $this->hexColor($firstColArr);
             foreach ($colArr as $transparentColor) {
                 $transparentColor = $this->convertColor($transparentColor);
                 $transparentColor = $this->hexColor($transparentColor);
                 $cmd = '-fill "' . $firstCol . '" -opaque "' . $transparentColor . '"';
                 $this->imageMagickExec($preName, $postName, $cmd);
                 $preName = $postName;
             }
             $this->imageMagickExec($postName, $origName, '');
             if (@is_file($origName)) {
                 $tmpImg = $this->imageCreateFromFile($origName);
             }
         } else {
             $tmpImg = $img;
         }
         if ($tmpImg) {
             $img = $tmpImg;
             if ($closest) {
                 $retCol = ImageColorClosest($img, $firstColArr[0], $firstColArr[1], $firstColArr[2]);
             } else {
                 $retCol = ImageColorExact($img, $firstColArr[0], $firstColArr[1], $firstColArr[2]);
             }
         }
         // Unlink files from process
         if (!$this->dontUnlinkTempFiles) {
             if ($origName) {
                 @unlink($origName);
             }
             if ($postName) {
                 @unlink($postName);
             }
         }
     }
     return $retCol;
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:54,代码来源:GraphicalFunctions.php

示例8: ImageCopyResampleBicubic

 function ImageCopyResampleBicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
 {
     for ($i = 0; $i < imagecolorstotal($src_img); $i++) {
         $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 = $src_y; $j < $src_y + $dst_h; $j++) {
         $sY = $j * $scaleY;
         for ($i = $src_x; $i < $src_x + $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, $dst_x + $i - $src_x, $dst_y + $j - $src_y, $color);
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:logicalframe,代码行数:26,代码来源:GD.php

示例9: upgrade_profile_image

/**
 * Given a user id this function scales and crops the user images to remove
 * the one pixel black border.
 *
 * @global object
 * @param int $id
 * @param string $dir
 * @return boolean
 */
function upgrade_profile_image($id, $dir = 'users')
{
    global $CFG, $OUTPUT;
    $im = ImageCreateFromJPEG($CFG->dataroot . '/' . $dir . '/' . $id . '/f1.jpg');
    if (function_exists('ImageCreateTrueColor') and $CFG->gdversion >= 2) {
        $im1 = ImageCreateTrueColor(100, 100);
        $im2 = ImageCreateTrueColor(35, 35);
    } else {
        $im1 = ImageCreate(100, 100);
        $im2 = ImageCreate(35, 35);
    }
    if (function_exists('ImageCopyResampled') and $CFG->gdversion >= 2) {
        ImageCopyBicubic($im1, $im, 0, 0, 2, 2, 100, 100, 96, 96);
    } else {
        imagecopy($im1, $im, 0, 0, 0, 0, 100, 100);
        $c = ImageColorsForIndex($im1, ImageColorAt($im1, 2, 2));
        $color = ImageColorClosest($im1, $c['red'], $c['green'], $c['blue']);
        ImageSetPixel($im1, 0, 0, $color);
        $c = ImageColorsForIndex($im1, ImageColorAt($im1, 2, 97));
        $color = ImageColorClosest($im1, $c['red'], $c['green'], $c['blue']);
        ImageSetPixel($im1, 0, 99, $color);
        $c = ImageColorsForIndex($im1, ImageColorAt($im1, 97, 2));
        $color = ImageColorClosest($im1, $c['red'], $c['green'], $c['blue']);
        ImageSetPixel($im1, 99, 0, $color);
        $c = ImageColorsForIndex($im1, ImageColorAt($im1, 97, 97));
        $color = ImageColorClosest($im1, $c['red'], $c['green'], $c['blue']);
        ImageSetPixel($im1, 99, 99, $color);
        for ($x = 1; $x < 99; $x++) {
            $c1 = ImageColorsForIndex($im1, ImageColorAt($im, $x, 1));
            $color = ImageColorClosest($im, $c1['red'], $c1['green'], $c1['blue']);
            ImageSetPixel($im1, $x, 0, $color);
            $c2 = ImageColorsForIndex($im1, ImageColorAt($im1, $x, 98));
            $color = ImageColorClosest($im, $c2['red'], $c2['green'], $c2['blue']);
            ImageSetPixel($im1, $x, 99, $color);
        }
        for ($y = 1; $y < 99; $y++) {
            $c3 = ImageColorsForIndex($im1, ImageColorAt($im, 1, $y));
            $color = ImageColorClosest($im, $c3['red'], $c3['green'], $c3['blue']);
            ImageSetPixel($im1, 0, $y, $color);
            $c4 = ImageColorsForIndex($im1, ImageColorAt($im1, 98, $y));
            $color = ImageColorClosest($im, $c4['red'], $c4['green'], $c4['blue']);
            ImageSetPixel($im1, 99, $y, $color);
        }
    }
    ImageCopyBicubic($im2, $im, 0, 0, 2, 2, 35, 35, 96, 96);
    if (function_exists('ImageJpeg')) {
        if (ImageJpeg($im1, $CFG->dataroot . '/' . $dir . '/' . $id . '/f1.jpg', 90) and ImageJpeg($im2, $CFG->dataroot . '/' . $dir . '/' . $id . '/f2.jpg', 95)) {
            @chmod($CFG->dataroot . '/' . $dir . '/' . $id . '/f1.jpg', 0666);
            @chmod($CFG->dataroot . '/' . $dir . '/' . $id . '/f2.jpg', 0666);
            return 1;
        }
    } else {
        echo $OUTPUT->notification('PHP has not been configured to support JPEG images.  Please correct this.');
    }
    return 0;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:65,代码来源:gdlib.php

示例10: make


//.........这里部分代码省略.........
                                 $isStdWrapped = array();
                                 foreach ($conf['shadow.'] as $key => $value) {
                                     $parameter = rtrim($key, '.');
                                     if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
                                         $conf['shadow.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
                                         $isStdWrapped[$parameter] = 1;
                                     }
                                 }
                                 $this->makeShadow($this->im, $conf['shadow.'], $this->workArea, $conf);
                             }
                             if (is_array($conf['emboss.'])) {
                                 $isStdWrapped = array();
                                 foreach ($conf['emboss.'] as $key => $value) {
                                     $parameter = rtrim($key, '.');
                                     if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
                                         $conf['emboss.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
                                         $isStdWrapped[$parameter] = 1;
                                     }
                                 }
                                 $this->makeEmboss($this->im, $conf['emboss.'], $this->workArea, $conf);
                             }
                             if (is_array($conf['outline.'])) {
                                 $isStdWrapped = array();
                                 foreach ($conf['outline.'] as $key => $value) {
                                     $parameter = rtrim($key, '.');
                                     if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
                                         $conf['outline.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
                                         $isStdWrapped[$parameter] = 1;
                                     }
                                 }
                                 $this->makeOutline($this->im, $conf['outline.'], $this->workArea, $conf);
                             }
                             $conf['imgMap'] = 1;
                             $this->makeText($this->im, $conf, $this->workArea);
                         }
                         break;
                     case 'OUTLINE':
                         if ($this->setup[$conf['textObjNum']] == 'TEXT' && ($txtConf = $this->checkTextObj($this->setup[$conf['textObjNum'] . '.']))) {
                             $this->makeOutline($this->im, $conf, $this->workArea, $txtConf);
                         }
                         break;
                     case 'EMBOSS':
                         if ($this->setup[$conf['textObjNum']] == 'TEXT' && ($txtConf = $this->checkTextObj($this->setup[$conf['textObjNum'] . '.']))) {
                             $this->makeEmboss($this->im, $conf, $this->workArea, $txtConf);
                         }
                         break;
                     case 'SHADOW':
                         if ($this->setup[$conf['textObjNum']] == 'TEXT' && ($txtConf = $this->checkTextObj($this->setup[$conf['textObjNum'] . '.']))) {
                             $this->makeShadow($this->im, $conf, $this->workArea, $txtConf);
                         }
                         break;
                     case 'BOX':
                         $this->makeBox($this->im, $conf, $this->workArea);
                         break;
                     case 'EFFECT':
                         $this->makeEffect($this->im, $conf);
                         break;
                     case 'ADJUST':
                         $this->adjust($this->im, $conf);
                         break;
                     case 'CROP':
                         $this->crop($this->im, $conf);
                         break;
                     case 'SCALE':
                         $this->scale($this->im, $conf);
                         break;
                     case 'WORKAREA':
                         if ($conf['set']) {
                             // this sets the workArea
                             $this->setWorkArea($conf['set']);
                         }
                         if (isset($conf['clear'])) {
                             // This sets the current to the default;
                             $this->workArea = $this->defaultWorkArea;
                         }
                         break;
                     case 'ELLIPSE':
                         $this->makeEllipse($this->im, $conf, $this->workArea);
                         break;
                 }
             }
         }
     }
     // Preserve alpha transparency
     if (!$this->saveAlphaLayer) {
         if ($this->setup['transparentBackground']) {
             // Auto transparent background is set
             $Bcolor = ImageColorClosest($this->im, $BGcols[0], $BGcols[1], $BGcols[2]);
             imagecolortransparent($this->im, $Bcolor);
         } elseif (is_array($this->setup['transparentColor_array'])) {
             // Multiple transparent colors are set. This is done via the trick that all transparent colors get
             // converted to one color and then this one gets set as transparent as png/gif can just have one
             // transparent color.
             $Tcolor = $this->unifyColors($this->im, $this->setup['transparentColor_array'], (int) $this->setup['transparentColor.']['closest']);
             if ($Tcolor >= 0) {
                 imagecolortransparent($this->im, $Tcolor);
             }
         }
     }
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:101,代码来源:GifBuilder.php

示例11: frame

 public function frame($light_colour = "FFFFFF", $dark_colour = "000000", $mid_width = 4)
 {
     $this->rw = $mid_width;
     $this->dh = $dark_colour;
     $this->lh = $light_colour;
     $this->fr = $this->hex2rgb(substr($this->dh, 0, 2));
     $this->fg = $this->hex2rgb(substr($this->dh, 2, 2));
     $this->fb = $this->hex2rgb(substr($this->dh, 4, 2));
     $this->gr = $this->hex2rgb(substr($this->lh, 0, 2));
     $this->gg = $this->hex2rgb(substr($this->lh, 2, 2));
     $this->gb = $this->hex2rgb(substr($this->lh, 4, 2));
     $this->zen = ImageColorClosest($this->t, $this->gr, $this->gg, $this->gb);
     $this->nad = ImageColorClosest($this->t, $this->fr, $this->fg, $this->fb);
     $this->mid = ImageColorClosest($this->t, ($this->gr + $this->fr) / 2, ($this->gg + $this->fg) / 2, ($this->gb + $this->fb) / 2);
     imageline($this->t, 0, 0, $this->q, 0, $this->zen);
     imageline($this->t, 0, 0, 0, $this->r, $this->zen);
     imageline($this->t, $this->q - 1, 0, $this->q - 1, $this->r, $this->nad);
     imageline($this->t, 0, $this->r - 1, $this->q, $this->r - 1, $this->nad);
     imageline($this->t, $this->rw + 1, $this->r - ($this->rw + 2), $this->q - ($this->rw + 2), $this->r - ($this->rw + 2), $this->zen);
     // base in
     imageline($this->t, $this->q - ($this->rw + 2), $this->rw + 1, $this->q - ($this->rw + 2), $this->r - ($this->rw + 2), $this->zen);
     // right in
     imageline($this->t, $this->rw + 1, $this->rw + 1, $this->q - ($this->rw + 1), $this->rw + 1, $this->nad);
     imageline($this->t, $this->rw + 1, $this->rw + 1, $this->rw + 1, $this->r - ($this->rw + 1), $this->nad);
     for ($this->crw = 0; $this->crw < $this->rw; $this->crw++) {
         imageline($this->t, $this->crw + 1, $this->crw + 1, $this->q - ($this->crw + 1), $this->crw + 1, $this->mid);
         // top
         imageline($this->t, $this->crw + 1, $this->r - ($this->crw + 2), $this->q - ($this->crw + 1), $this->r - ($this->crw + 2), $this->mid);
         // base
         imageline($this->t, $this->crw + 1, $this->crw + 1, $this->crw + 1, $this->r - ($this->crw + 1), $this->mid);
         //left
         imageline($this->t, $this->q - ($this->crw + 2), $this->crw, $this->q - ($this->crw + 2), $this->r - ($this->crw + 1), $this->mid);
         // right
     }
     $this->efecto[] = "frame";
 }
开发者ID:pablius,项目名称:oob-n1,代码行数:36,代码来源:OOB_imagehandling.php

示例12: ImageResize

 function ImageResize(&$src, $x, $y)
 {
     $dst = imagecreatetruecolor($x, $y);
     $pals = ImageColorsTotal($src);
     for ($i = 0; $i < $pals; $i++) {
         $colors = ImageColorsForIndex($src, $i);
         ImageColorAllocate($dst, $colors['red'], $colors['green'], $colors['blue']);
     }
     $scX = (imagesx($src) - 1) / $x;
     $scY = (imagesy($src) - 1) / $y;
     $scX2 = intval($scX / 2);
     $scY2 = intval($scY / 2);
     for ($j = 0; $j < $y; $j++) {
         $sY = intval($j * $scY);
         $y13 = $sY + $scY2;
         for ($i = 0; $i < $x; $i++) {
             $sX = intval($i * $scX);
             $x34 = $sX + $scX2;
             $c1 = ImageColorsForIndex($src, ImageColorAt($src, $sX, $y13));
             $c2 = ImageColorsForIndex($src, ImageColorAt($src, $sX, $sY));
             $c3 = ImageColorsForIndex($src, ImageColorAt($src, $x34, $y13));
             $c4 = ImageColorsForIndex($src, ImageColorAt($src, $x34, $sY));
             $r = ($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) / 4;
             $g = ($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) / 4;
             $b = ($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) / 4;
             ImageSetPixel($dst, $i, $j, ImageColorClosest($dst, $r, $g, $b));
         }
     }
     return $dst;
 }
开发者ID:kent62001,项目名称:NTPU_Club_Gallery,代码行数:30,代码来源:admin_function.php

示例13: ImageResize

 /**
  * resizes an image using several different techniques:
  *
  * PHP's own ImageCopyResamplated
  * Bi-linear filter (slower, but better quality than ImageCopyResampled)
  * Bi-Cubic filter (slowest, but offers the best quality)
  * PHP's own ImageCopyResized (fastest one, but offers no antialising or filter)
  *
  */
 function ImageResize($dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $resample = GD_RESIZER_NO_SMOOTHING_MODE)
 {
     $pxls = intval($src_w / $dst_w) - 1;
     if ($resample == GD_RESIZER_PHP_IMAGECOPYRESAMPLED) {
         imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
     } elseif ($resample == GD_RESIZER_BILINEAR_MODE) {
         //slow but better quality
         ImageTrueColorToPalette($src_img, false, 256);
         ImagePaletteCopy($dst_img, $src_img);
         $rX = $src_w / $dst_w;
         $rY = $src_h / $dst_h;
         $nY = 0;
         for ($y = $src_y; $y < $dst_h; $y++) {
             $oY = $nY;
             $nY = intval(($y + 1) * $rY + 0.5);
             $nX = 0;
             for ($x = $src_x; $x < $dst_w; $x++) {
                 $r = $g = $b = $a = 0;
                 $oX = $nX;
                 $nX = intval(($x + 1) * $rX + 0.5);
                 $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $nX, $nY));
                 $r += $c['red'];
                 $g += $c['green'];
                 $b += $c['blue'];
                 $a++;
                 $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $nX - $pxls, $nY - $pxls));
                 $r += $c['red'];
                 $g += $c['green'];
                 $b += $c['blue'];
                 $a++;
                 //you can add more pixels here! eg "$nX, $nY-$pxls" or "$nX-$pxls, $nY"
                 ImageSetPixel($dst_img, $x + $dst_x - $src_x, $y + $dst_y - $src_y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
             }
         }
     } elseif ($resample == GD_RESIZER_BICUBIC_MODE) {
         // veeeeeery slow but better quality
         ImagePaletteCopy($dst_img, $src_img);
         $rX = $src_w / $dst_w;
         $rY = $src_h / $dst_h;
         $nY = 0;
         for ($y = $src_y; $y < $dst_h; $y++) {
             $oY = $nY;
             $nY = intval(($y + 1) * $rY + 0.5);
             $nX = 0;
             for ($x = $src_x; $x < $dst_w; $x++) {
                 $r = $g = $b = $a = 0;
                 $oX = $nX;
                 $nX = intval(($x + 1) * $rX + 0.5);
                 for ($i = $nY; --$i >= $oY;) {
                     for ($j = $nX; --$j >= $oX;) {
                         $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $j, $i));
                         $r += $c['red'];
                         $g += $c['green'];
                         $b += $c['blue'];
                         $a++;
                     }
                 }
                 ImageSetPixel($dst_img, $x + $dst_x - $src_x, $y + $dst_y - $src_y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
             }
         }
     } else {
         $dst_w++;
         $dst_h++;
         //->no black border
         imagecopyresized($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
     }
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:76,代码来源:gallerygdresizer.class.php

示例14: resampleBicubic

 /**
  * Resample the image 
  * http://www.php.net/manual/en/function.imagecopyresized.php
  */
 protected function resampleBicubic(&$dst, &$src, $dstx, $dsty, $srcx, $srcy, $w, $h, $zoomX, $zoomY = '')
 {
     if (!$zoomY) {
         $zoomY = $zoomX;
     }
     $palsize = ImageColorsTotal($src);
     for ($i = 0; $i < $palsize; $i++) {
         $colors = ImageColorsForIndex($src, $i);
         ImageColorAllocate($dst, $colors['red'], $colors['green'], $colors['blue']);
     }
     $zoomX2 = (int) ($zoomX / 2);
     $zoomY2 = (int) ($zoomY / 2);
     $dstX = imagesx($dst);
     $dstY = imagesy($dst);
     $srcX = imagesx($src);
     $srcY = imagesy($src);
     for ($j = 0; $j < $h - $dsty; $j++) {
         $sY = (int) ($j * $zoomY) + $srcy;
         $y13 = $sY + $zoomY2;
         $dY = $j + $dsty;
         if ($sY >= $srcY or $dY >= $dstY or $y13 >= $srcY) {
             break 1;
         }
         for ($i = 0; $i < $w - $dstx; $i++) {
             $sX = (int) ($i * $zoomX) + $srcx;
             $x34 = $sX + $zoomX2;
             $dX = $i + $dstx;
             if ($sX >= $srcX or $dX >= $dstX or $x34 >= $srcX) {
                 break 1;
             }
             $c1 = ImageColorsForIndex($src, ImageColorAt($src, $sX, $y13));
             $c2 = ImageColorsForIndex($src, ImageColorAt($src, $sX, $sY));
             $c3 = ImageColorsForIndex($src, ImageColorAt($src, $x34, $y13));
             $c4 = ImageColorsForIndex($src, ImageColorAt($src, $x34, $sY));
             $r = ($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) / 4;
             $g = ($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) / 4;
             $b = ($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) / 4;
             ImageSetPixel($dst, $dX, $dY, ImageColorClosest($dst, $r, $g, $b));
         }
     }
 }
开发者ID:burbuja,项目名称:pluf,代码行数:45,代码来源:Thumbnail.php

示例15: ImageCopyResampleBicubic

 /**
  * function imageCopyResampleBicubic (
  *		pointer &$dst_img,
  *		pointer &$src_img,
  *		intval $dst_x,
  *		intval $dst_y,
  *		intval $src_x,
  *		intval $src_y,
  *		intval $dst_w,
  *		intval $dst_h,
  *		intval $src_w,
  *		intval $src_h)
  *
  * Realiza un remuestreo bicúbico cuando se crea una copia reducida a partir
  * de otra imagen para mejorar visiblemente la calidad
  */
 function ImageCopyResampleBicubic(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
 {
     /**
      * port to PHP by John Jensen July 10 2001 (updated June 13, 2002 by tim@smoothdeity.com) --
      * original code (in C, for the PHP GD Module) by jernberg@fairytale.se
      * Taken out of http://www.php.net/manual/en/function.imagecopyresized.php
      */
     $scaleX = ($src_w - 1) / $dst_w;
     $scaleY = ($src_h - 1) / $dst_h;
     $scaleX2 = (int) ($scaleX / 2);
     $scaleY2 = (int) ($scaleY / 2);
     $dstSizeX = imagesx($dst_img);
     $dstSizeY = imagesy($dst_img);
     $srcSizeX = imagesx($src_img);
     $srcSizeY = imagesy($src_img);
     for ($j = 0; $j < $dst_h - $dst_y; $j++) {
         $sY = (int) ($j * $scaleY) + $src_y;
         $y13 = $sY + $scaleY2;
         $dY = $j + $dst_y;
         if ($sY > $srcSizeY or $dY > $dstSizeY) {
             break 1;
         }
         for ($i = 0; $i < $dst_w - $dst_x; $i++) {
             $sX = (int) ($i * $scaleX) + $src_x;
             $x34 = $sX + $scaleX2;
             $dX = $i + $dst_x;
             if ($sX > $srcSizeX or $dX > $dstSizeX) {
                 break 1;
             }
             $color1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $sX, $y13));
             $color2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $sX, $sY));
             $color3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $x34, $y13));
             $color4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $x34, $sY));
             $red = ($color1['red'] + $color2['red'] + $color3['red'] + $color4['red']) / 4;
             $green = ($color1['green'] + $color2['green'] + $color3['green'] + $color4['green']) / 4;
             $blue = ($color1['blue'] + $color2['blue'] + $color3['blue'] + $color4['blue']) / 4;
             ImageSetPixel($dst_img, $dX, $dY, ImageColorClosest($dst_img, $red, $green, $blue));
         }
     }
 }
开发者ID:JoseCOCA,项目名称:baudprint,代码行数:56,代码来源:class_imaxes.php


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