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


PHP ImageColorSet函数代码示例

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


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

示例1: ImprovedImageRotate

 public static function ImprovedImageRotate(&$gdimg_source, $rotate_angle = 0, $config_background_hexcolor = 'FFFFFF', $bg = null, &$phpThumbObject)
 {
     while ($rotate_angle < 0) {
         $rotate_angle += 360;
     }
     $rotate_angle = $rotate_angle % 360;
     if ($rotate_angle != 0) {
         $background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_source, $config_background_hexcolor);
         if (phpthumb_functions::gd_version() >= 2 && !$bg && $rotate_angle % 90) {
             //$this->DebugMessage('Using alpha rotate', __FILE__, __LINE__);
             if ($gdimg_rotate_mask = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg_source), ImageSY($gdimg_source))) {
                 for ($i = 0; $i <= 255; $i++) {
                     $color_mask[$i] = ImageColorAllocate($gdimg_rotate_mask, $i, $i, $i);
                 }
                 ImageFilledRectangle($gdimg_rotate_mask, 0, 0, ImageSX($gdimg_rotate_mask), ImageSY($gdimg_rotate_mask), $color_mask[255]);
                 $imageX = ImageSX($gdimg_source);
                 $imageY = ImageSY($gdimg_source);
                 for ($x = 0; $x < $imageX; $x++) {
                     for ($y = 0; $y < $imageY; $y++) {
                         $pixelcolor = phpthumb_functions::GetPixelColor($gdimg_source, $x, $y);
                         ImageSetPixel($gdimg_rotate_mask, $x, $y, $color_mask[255 - round($pixelcolor['alpha'] * 255 / 127)]);
                     }
                 }
                 $gdimg_rotate_mask = ImageRotate($gdimg_rotate_mask, $rotate_angle, $color_mask[0]);
                 $gdimg_source = ImageRotate($gdimg_source, $rotate_angle, $background_color);
                 ImageAlphaBlending($gdimg_source, false);
                 ImageSaveAlpha($gdimg_source, true);
                 //$this->is_alpha = true;
                 $phpThumbFilters = new phpthumb_filters();
                 //$phpThumbFilters->phpThumbObject = $this;
                 $phpThumbFilters->phpThumbObject = $phpThumbObject;
                 $phpThumbFilters->ApplyMask($gdimg_rotate_mask, $gdimg_source);
                 ImageDestroy($gdimg_rotate_mask);
             } else {
                 //$this->DebugMessage('ImageCreateFunction() failed', __FILE__, __LINE__);
             }
         } else {
             if (phpthumb_functions::gd_version() < 2) {
                 //$this->DebugMessage('Using non-alpha rotate because gd_version is "'.phpthumb_functions::gd_version().'"', __FILE__, __LINE__);
             } elseif ($bg) {
                 //$this->DebugMessage('Using non-alpha rotate because $this->bg is "'.$bg.'"', __FILE__, __LINE__);
             } elseif ($rotate_angle % 90) {
                 //$this->DebugMessage('Using non-alpha rotate because ($rotate_angle % 90) = "'.($rotate_angle % 90).'"', __FILE__, __LINE__);
             } else {
                 //$this->DebugMessage('Using non-alpha rotate because $this->thumbnailFormat is "'.$this->thumbnailFormat.'"', __FILE__, __LINE__);
             }
             if (ImageColorTransparent($gdimg_source) >= 0) {
                 // ImageRotate() forgets all about an image's transparency and sets the transparent color to black
                 // To compensate, flood-fill the transparent color of the source image with the specified background color first
                 // then rotate and the colors should match
                 if (!function_exists('ImageIsTrueColor') || !ImageIsTrueColor($gdimg_source)) {
                     // convert paletted image to true-color before rotating to prevent nasty aliasing artifacts
                     //$this->source_width  = ImageSX($gdimg_source);
                     //$this->source_height = ImageSY($gdimg_source);
                     $gdimg_newsrc = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg_source), ImageSY($gdimg_source));
                     $background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $config_background_hexcolor);
                     ImageFilledRectangle($gdimg_newsrc, 0, 0, ImageSX($gdimg_source), ImageSY($gdimg_source), phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $config_background_hexcolor));
                     ImageCopy($gdimg_newsrc, $gdimg_source, 0, 0, 0, 0, ImageSX($gdimg_source), ImageSY($gdimg_source));
                     ImageDestroy($gdimg_source);
                     unset($gdimg_source);
                     $gdimg_source = $gdimg_newsrc;
                     unset($gdimg_newsrc);
                 } else {
                     ImageColorSet($gdimg_source, ImageColorTransparent($gdimg_source), hexdec(substr($config_background_hexcolor, 0, 2)), hexdec(substr($config_background_hexcolor, 2, 2)), hexdec(substr($config_background_hexcolor, 4, 2)));
                     ImageColorTransparent($gdimg_source, -1);
                 }
             }
             $gdimg_source = ImageRotate($gdimg_source, $rotate_angle, $background_color);
         }
     }
     return true;
 }
开发者ID:exside,项目名称:phpThumb,代码行数:72,代码来源:phpthumb.filters.php

示例2: inputLevels

 /**
  * Apply input levels to input image pointer (increasing contrast)
  *
  * @param resource $im GDlib Image Pointer
  * @param int $low The "low" value (close to 0)
  * @param int $high The "high" value (close to 255)
  * @return void
  */
 public function inputLevels(&$im, $low, $high)
 {
     if ($low < $high) {
         $low = MathUtility::forceIntegerInRange($low, 0, 255);
         $high = MathUtility::forceIntegerInRange($high, 0, 255);
         $delta = $high - $low;
         $totalCols = ImageColorsTotal($im);
         for ($c = 0; $c < $totalCols; $c++) {
             $cols = ImageColorsForIndex($im, $c);
             $cols['red'] = MathUtility::forceIntegerInRange(($cols['red'] - $low) / $delta * 255, 0, 255);
             $cols['green'] = MathUtility::forceIntegerInRange(($cols['green'] - $low) / $delta * 255, 0, 255);
             $cols['blue'] = MathUtility::forceIntegerInRange(($cols['blue'] - $low) / $delta * 255, 0, 255);
             ImageColorSet($im, $c, $cols['red'], $cols['green'], $cols['blue']);
         }
     }
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:24,代码来源:GraphicalFunctions.php

示例3: makeIcon

 /**
  * Creates the icon file for the function getIcon()
  *
  * @param string $iconfile Original unprocessed Icon file, relative path to PATH_typo3
  * @param string $mode Mode string, eg. "deleted" or "futuretiming" determining how the icon will look
  * @param integer $user The number of the fe_group record uid if applicable
  * @param boolean $protectSection Flag determines if the protected-section icon should be applied.
  * @param string $absFile Absolute path to file from which to create the icon.
  * @param string $iconFileName_stateTagged The filename that this icon should have had, basically [icon base name]_[flags].[extension] - used for part of temporary filename
  * @return string Filename relative to PATH_typo3
  * @access private
  */
 public static function makeIcon($iconfile, $mode, $user, $protectSection, $absFile, $iconFileName_stateTagged)
 {
     $iconFileName = 'icon_' . GeneralUtility::shortMD5($iconfile . '|' . $mode . '|-' . $user . '|' . $protectSection) . '_' . $iconFileName_stateTagged . '.' . ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'] ? 'png' : 'gif');
     $mainpath = '../typo3temp/' . $iconFileName;
     $path = PATH_site . 'typo3temp/' . $iconFileName;
     if (file_exists(PATH_typo3 . 'icons/' . $iconFileName)) {
         // Returns if found in typo3/icons/
         return 'icons/' . $iconFileName;
     } elseif (file_exists($path)) {
         // Returns if found in ../typo3temp/icons/
         return $mainpath;
     } else {
         // Makes icon:
         if (file_exists($absFile)) {
             if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
                 // Create image pointer, if possible
                 $im = self::imagecreatefrom($absFile);
                 if ($im < 0) {
                     return $iconfile;
                 }
                 // Converting to gray scale, dimming the icon:
                 if ($mode == 'disabled' or $mode != 'futuretiming' && $mode != 'no_icon_found' && !(!$mode && $user)) {
                     $totalImageColors = ImageColorsTotal($im);
                     for ($c = 0; $c < $totalImageColors; $c++) {
                         $cols = ImageColorsForIndex($im, $c);
                         $newcol = round(($cols['red'] + $cols['green'] + $cols['blue']) / 3);
                         $lighten = $mode == 'disabled' ? 2.5 : 2;
                         $newcol = round(255 - (255 - $newcol) / $lighten);
                         ImageColorSet($im, $c, $newcol, $newcol, $newcol);
                     }
                 }
                 // Applying user icon, if there are access control on the item:
                 if ($user) {
                     if ($user < 100) {
                         // Apply user number only if lower than 100
                         $black = ImageColorAllocate($im, 0, 0, 0);
                         imagefilledrectangle($im, 0, 0, $user > 10 ? 9 : 5, 8, $black);
                         $white = ImageColorAllocate($im, 255, 255, 255);
                         imagestring($im, 1, 1, 1, $user, $white);
                     }
                     $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_group.gif');
                     if ($ol_im < 0) {
                         return $iconfile;
                     }
                     self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
                 }
                 // Applying overlay based on mode:
                 if ($mode) {
                     unset($ol_im);
                     switch ($mode) {
                         case 'deleted':
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_deleted.gif');
                             break;
                         case 'futuretiming':
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_timing.gif');
                             break;
                         case 'timing':
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_timing.gif');
                             break;
                         case 'hiddentiming':
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_hidden_timing.gif');
                             break;
                         case 'no_icon_found':
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_no_icon_found.gif');
                             break;
                         case 'disabled':
                             // is already greyed - nothing more
                             $ol_im = 0;
                             break;
                         case 'hidden':
                         default:
                             $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_hidden.gif');
                     }
                     if ($ol_im < 0) {
                         return $iconfile;
                     }
                     if ($ol_im) {
                         self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
                     }
                 }
                 // Protect-section icon:
                 if ($protectSection) {
                     $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_sub5.gif');
                     if ($ol_im < 0) {
                         return $iconfile;
                     }
                     self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
                 }
//.........这里部分代码省略.........
开发者ID:khanhdeux,项目名称:typo3test,代码行数:101,代码来源:IconUtility.php

示例4: Rotate


//.........这里部分代码省略.........
                                         $rotate_angle = 180;
                                         break;
                                     case 6:
                                         $rotate_angle = 270;
                                         break;
                                     case 8:
                                         $rotate_angle = 90;
                                         break;
                                     default:
                                         $this->DebugMessage('EXIF auto-rotate failed because unknown $exif_data[Orientation] "' . @$exif_data['Orientation'] . '"', __FILE__, __LINE__);
                                         return false;
                                         break;
                                 }
                                 $this->DebugMessage('EXIF auto-rotate set to ' . $rotate_angle . ' degrees ($exif_data[Orientation] = "' . @$exif_data['Orientation'] . '")', __FILE__, __LINE__);
                             } else {
                                 $this->DebugMessage('failed: exif_read_data(' . $this->sourceFilename . ')', __FILE__, __LINE__);
                                 return false;
                             }
                         } else {
                             $this->DebugMessage('!function_exists(exif_read_data)', __FILE__, __LINE__);
                             return false;
                         }
                     } else {
                         $this->DebugMessage('Cannot auto-rotate from EXIF data because $this->sourceFilename is empty', __FILE__, __LINE__);
                         return false;
                     }
                 } else {
                     $this->DebugMessage('Cannot auto-rotate from EXIF data because PHP is less than v4.2.0 (' . phpversion() . ')', __FILE__, __LINE__);
                     return false;
                 }
             } elseif ($this->ar == 'l' && $this->source_height > $this->source_width) {
                 $rotate_angle = 270;
             } elseif ($this->ar == 'L' && $this->source_height > $this->source_width) {
                 $rotate_angle = 90;
             } elseif ($this->ar == 'p' && $this->source_width > $this->source_height) {
                 $rotate_angle = 90;
             } elseif ($this->ar == 'P' && $this->source_width > $this->source_height) {
                 $rotate_angle = 270;
             }
         }
         while ($rotate_angle < 0) {
             $rotate_angle += 360;
         }
         $rotate_angle = $rotate_angle % 360;
         if ($rotate_angle != 0) {
             $background_color = phpthumb_functions::ImageHexColorAllocate($this->gdimg_source, $this->config_background_hexcolor);
             if (phpthumb_functions::gd_version() >= 2 && $this->thumbnailFormat == 'png' && !$this->bg && $rotate_angle % 90) {
                 if ($gdimg_rotate_mask = phpthumb_functions::ImageCreateFunction(ImageSX($this->gdimg_source), ImageSY($this->gdimg_source))) {
                     $this->gdimg_source = ImageRotate($this->gdimg_source, $rotate_angle, $background_color);
                     $color_mask_opaque = ImageColorAllocate($gdimg_rotate_mask, 0xff, 0xff, 0xff);
                     $color_mask_transparent = ImageColorAllocate($gdimg_rotate_mask, 0x0, 0x0, 0x0);
                     ImageFilledRectangle($gdimg_rotate_mask, 0, 0, ImageSX($gdimg_rotate_mask), ImageSY($gdimg_rotate_mask), $color_mask_opaque);
                     $gdimg_rotate_mask = ImageRotate($gdimg_rotate_mask, $rotate_angle, $color_mask_transparent);
                     ImageAlphaBlending($this->gdimg_source, false);
                     if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=')) {
                         ImageSaveAlpha($this->gdimg_source, true);
                     }
                     $this->is_alpha = true;
                     phpthumb_filters::ApplyMask($gdimg_rotate_mask, $this->gdimg_source);
                     ImageDestroy($gdimg_rotate_mask);
                     $this->source_width = ImageSX($this->gdimg_source);
                     $this->source_height = ImageSY($this->gdimg_source);
                 } else {
                     $this->DebugMessage('ImageCreateFromStringReplacement() failed for "' . $MaskFilename . '"', __FILE__, __LINE__);
                 }
             } else {
                 if (phpthumb_functions::gd_version() >= 2) {
                     $this->DebugMessage('Using non-alpha rotate because gd_version is "' . phpthumb_functions::gd_version() . '"', __FILE__, __LINE__);
                 } else {
                     $this->DebugMessage('Using non-alpha rotate because $this->thumbnailFormat is "' . $this->thumbnailFormat . '"', __FILE__, __LINE__);
                 }
                 if (ImageColorTransparent($this->gdimg_source) >= 0) {
                     // ImageRotate() forgets all about an image's transparency and sets the transparent color to black
                     // To compensate, flood-fill the transparent color of the source image with the specified background color first
                     // then rotate and the colors should match
                     if (!function_exists('ImageIsTrueColor') || !ImageIsTrueColor($this->gdimg_source)) {
                         // convert paletted image to true-color before rotating to prevent nasty aliasing artifacts
                         $this->source_width = ImageSX($this->gdimg_source);
                         $this->source_height = ImageSY($this->gdimg_source);
                         $gdimg_newsrc = phpthumb_functions::ImageCreateFunction($this->source_width, $this->source_height);
                         $background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $this->config_background_hexcolor);
                         ImageFilledRectangle($gdimg_newsrc, 0, 0, $this->source_width, $this->source_height, phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $this->config_background_hexcolor));
                         ImageCopy($gdimg_newsrc, $this->gdimg_source, 0, 0, 0, 0, $this->source_width, $this->source_height);
                         ImageDestroy($this->gdimg_source);
                         unset($this->gdimg_source);
                         $this->gdimg_source = $gdimg_newsrc;
                         unset($gdimg_newsrc);
                     } else {
                         ImageColorSet($this->gdimg_source, ImageColorTransparent($this->gdimg_source), hexdec(substr($this->config_background_hexcolor, 0, 2)), hexdec(substr($this->config_background_hexcolor, 2, 2)), hexdec(substr($this->config_background_hexcolor, 4, 2)));
                         ImageColorTransparent($this->gdimg_source, -1);
                     }
                 }
                 $this->gdimg_source = ImageRotate($this->gdimg_source, $rotate_angle, $background_color);
                 $this->source_width = ImageSX($this->gdimg_source);
                 $this->source_height = ImageSY($this->gdimg_source);
             }
         }
     }
     return true;
 }
开发者ID:alanhaggai,项目名称:plogger,代码行数:101,代码来源:phpthumb.class.php

示例5: Rotate

 function Rotate()
 {
     if (!function_exists('ImageRotate')) {
         return false;
     }
     if (!empty($this->ra) || !empty($this->ar)) {
         $this->config_background_hexcolor = !empty($this->bg) ? $this->bg : $this->config_background_hexcolor;
         if (!eregi('^[0-9A-F]{6}$', $this->config_background_hexcolor)) {
             $this->ErrorImage('Invalid hex color string "' . $this->config_background_hexcolor . '" for parameter "bg"');
         }
         $rotate_angle = 0;
         if (!empty($this->ra)) {
             $rotate_angle = floatval($this->ra);
         } else {
             if ($this->ar == 'l' && $this->source_height > $this->source_width) {
                 $rotate_angle = 270;
             } elseif ($this->ar == 'L' && $this->source_height > $this->source_width) {
                 $rotate_angle = 90;
             } elseif ($this->ar == 'p' && $this->source_width > $this->source_height) {
                 $rotate_angle = 90;
             } elseif ($this->ar == 'P' && $this->source_width > $this->source_height) {
                 $rotate_angle = 270;
             }
         }
         while ($rotate_angle < 0) {
             $rotate_angle += 360;
         }
         $rotate_angle = $rotate_angle % 360;
         if ($rotate_angle != 0) {
             if (ImageColorTransparent($this->gdimg_source) >= 0) {
                 // ImageRotate() forgets all about an image's transparency and sets the transparent color to black
                 // To compensate, flood-fill the transparent color of the source image with the specified background color first
                 // then rotate and the colors should match
                 if (!function_exists('ImageIsTrueColor') || !ImageIsTrueColor($this->gdimg_source)) {
                     // convert paletted image to true-color before rotating to prevent nasty aliasing artifacts
                     $this->source_width = ImageSX($this->gdimg_source);
                     $this->source_height = ImageSY($this->gdimg_source);
                     $gdimg_newsrc = $this->ImageCreateFunction($this->source_width, $this->source_height);
                     $background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $this->config_background_hexcolor);
                     ImageFilledRectangle($gdimg_newsrc, 0, 0, $this->source_width, $this->source_height, phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $this->config_background_hexcolor));
                     ImageCopy($gdimg_newsrc, $this->gdimg_source, 0, 0, 0, 0, $this->source_width, $this->source_height);
                     ImageDestroy($this->gdimg_source);
                     unset($this->gdimg_source);
                     $this->gdimg_source = $gdimg_newsrc;
                     unset($gdimg_newsrc);
                 } else {
                     ImageColorSet($this->gdimg_source, ImageColorTransparent($this->gdimg_source), hexdec(substr($this->config_background_hexcolor, 0, 2)), hexdec(substr($this->config_background_hexcolor, 2, 2)), hexdec(substr($this->config_background_hexcolor, 4, 2)));
                     ImageColorTransparent($this->gdimg_source, -1);
                 }
             }
             $background_color = phpthumb_functions::ImageHexColorAllocate($this->gdimg_source, $this->config_background_hexcolor);
             $this->gdimg_source = ImageRotate($this->gdimg_source, $rotate_angle, $background_color);
             $this->source_width = ImageSX($this->gdimg_source);
             $this->source_height = ImageSY($this->gdimg_source);
         }
     }
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:58,代码来源:phpthumb.class.php

示例6: inputLevels

 /**
  * Apply input levels to input image pointer (increasing contrast)
  *
  * @param integer $im GDlib Image Pointer
  * @param integer $low The "low" value (close to 0)
  * @param integer $high The "high" value (close to 255)
  * @param boolean $swap If swap, then low and high are swapped. (Useful for negated masks...)
  * @return void
  * @todo Define visibility
  */
 public function inputLevels(&$im, $low, $high, $swap = '')
 {
     if ($low < $high) {
         $low = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($low, 0, 255);
         $high = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($high, 0, 255);
         if ($swap) {
             $temp = $low;
             $low = 255 - $high;
             $high = 255 - $temp;
         }
         $delta = $high - $low;
         $totalCols = ImageColorsTotal($im);
         for ($c = 0; $c < $totalCols; $c++) {
             $cols = ImageColorsForIndex($im, $c);
             $cols['red'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($cols['red'] - $low) / $delta * 255, 0, 255);
             $cols['green'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($cols['green'] - $low) / $delta * 255, 0, 255);
             $cols['blue'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($cols['blue'] - $low) / $delta * 255, 0, 255);
             ImageColorSet($im, $c, $cols['red'], $cols['green'], $cols['blue']);
         }
     }
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:31,代码来源:GraphicalFunctions.php

示例7: inputLevels

 /**
  * Apply input levels to input image pointer (increasing contrast)
  *
  * @param	integer		GDlib Image Pointer
  * @param	integer		The "low" value (close to 0)
  * @param	integer		The "high" value (close to 255)
  * @param	boolean		If swap, then low and high are swapped. (Useful for negated masks...)
  * @return	void
  */
 function inputLevels(&$im, $low, $high, $swap = '')
 {
     if ($low < $high) {
         $low = t3lib_div::intInRange($low, 0, 255);
         $high = t3lib_div::intInRange($high, 0, 255);
         if ($swap) {
             $temp = $low;
             $low = 255 - $high;
             $high = 255 - $temp;
         }
         $delta = $high - $low;
         $totalCols = ImageColorsTotal($im);
         for ($c = 0; $c < $totalCols; $c++) {
             $cols = ImageColorsForIndex($im, $c);
             $cols['red'] = t3lib_div::intInRange(($cols['red'] - $low) / $delta * 255, 0, 255);
             $cols['green'] = t3lib_div::intInRange(($cols['green'] - $low) / $delta * 255, 0, 255);
             $cols['blue'] = t3lib_div::intInRange(($cols['blue'] - $low) / $delta * 255, 0, 255);
             ImageColorSet($im, $c, $cols['red'], $cols['green'], $cols['blue']);
         }
     }
 }
开发者ID:NaveedWebdeveloper,项目名称:Test,代码行数:30,代码来源:class.t3lib_stdgraphic.php

示例8: fontc

function fontc($r1, $g1, $b1, $r2, $g2, $b2, $r3, $g3, $b3)
{
    $font = ImageCreateFromPNG('images/rpg/font.png');
    ImageColorTransparent($font, 1);
    ImageColorSet($font, 6, $r1, $g1, $b1);
    ImageColorSet($font, 5, ($r1 * 2 + $r2) / 3, ($g1 * 2 + $g2) / 3, ($b1 * 2 + $b2) / 3);
    ImageColorSet($font, 4, ($r1 + $r2 * 2) / 3, ($g1 + $g2 * 2) / 3, ($b1 + $b2 * 2) / 3);
    ImageColorSet($font, 3, $r2, $g2, $b2);
    ImageColorSet($font, 0, $r3, $g3, $b3);
    return $font;
}
开发者ID:StapleButter,项目名称:jul,代码行数:11,代码来源:status.php

示例9: build_sw

 public function build_sw($imgn, $watermark, $logo_pagarm)
 {
     $watermark = $this->resizeImage($watermark, 60, 80, 'test', 'jpg');
     imagetruecolortopalette($watermark, false, 256);
     $white = imagecolorexact($watermark, 252, 254, 252);
     $tmp = imagerotate($watermark, $logo_pagarm[0], $white);
     if ($tmp) {
         $watermark = imagerotate($watermark, $logo_pagarm[0], $white);
         imagetruecolortopalette($watermark, false, 256);
         $white = imagecolorexact($watermark, 252, 254, 252);
         imagedestroy($tmp);
     } else {
         $white = $this->imagegetcolor($watermark, 252, 254, 252);
         $watermark = imagerotate($watermark, $logo_pagarm[0], $white);
         imagetruecolortopalette($watermark, false, 256);
         $white = $this->imagegetcolor($watermark, 252, 254, 252);
     }
     imagecolortransparent($watermark, $white);
     ImageColorSet($watermark, $white, 0, 0, 0);
     $w_x = imagesx($watermark);
     $w_y = imagesy($watermark);
     imagecopymerge($imgn, $watermark, $logo_pagarm[1], $logo_pagarm[2], 0, 0, $w_x, $w_y, 100);
     //imagegif($imgn,WWW_ROOT.'img'.DS.'ytmpfile.gif');
     return $imgn;
     //imagepng($watermark,WWW_ROOT.'img'.DS.'xtmpfile.png');
 }
开发者ID:hobbysh,项目名称:seevia-opensource,代码行数:26,代码来源:img_set2.php

示例10: render_global


//.........这里部分代码省略.........
        }
        //dump all entries into $systems.
        unset($systems[count($systems) - 1]);
        //remove a surplus entry
    }
    //process stars
    foreach ($systems as $star) {
        if (!empty($star['links'])) {
            //don't link all systems to 1 automatically.
            $star_links = array_map("plus_one", explode(',', $star['links']));
            $star_id = $star['num'] + 1;
            foreach ($star_links as $link) {
                //make star links
                if ($link < 1) {
                    continue 1;
                }
                $other_star = $systems[$link - 1];
                //set other_star to the link destination.
                imageline($im, $star['x_loc'] + $offset_x, $star['y_loc'] + $offset_y, $other_star['x_loc'] + $offset_x, $other_star['y_loc'] + $offset_y, $color_sl);
            }
        }
        if (!empty($star['wormhole'])) {
            //Wormhole Manipulation
            $other_star = $systems[$star['wormhole'] - 1];
            if ($other_star['wormhole'] == $star_id) {
                //two way
                imageline($im, $star['x_loc'] + $offset_x, $star['y_loc'] + $offset_y, $other_star['x_loc'] + $offset_x, $other_star['y_loc'] + $offset_y, $worm_2way_color);
            } else {
                //one way
                imageline($im, $star['x_loc'] + $offset_x, $star['y_loc'] + $offset_y, $other_star['x_loc'] + $offset_x, $other_star['y_loc'] + $offset_y, $worm_1way_color);
            }
        }
    }
    $central_star = 0;
    //hack to take into account arrays start with 0.
    foreach ($systems as $star) {
        //place the star itself. This is done after the lines, so the text comes on top.
        $off = array(-5, 4);
        //offset of text from star location
        if ($star['num'] == $central_star) {
            imagecopy($im, $earthIm, $star['x_loc'] + $offset_x + $earthPos[0], $star['y_loc'] + $offset_y + $earthPos[1], 0, 0, $earthDim[0], $earthDim[1]);
        } else {
            imagecopy($im, $starIm, $star['x_loc'] + $offset_x + $starPos[0], $star['y_loc'] + $offset_y + $starPos[1], 0, 0, $starDim[0], $starDim[1]);
        }
        //only show warp numbers if admin wants them.
        if ($uv_show_warp_numbers == 1) {
            if ($central_star === $star['num']) {
                $off = array(-5, 9);
                //write the star number under the star
                imagestring($im, $UNI['num_size'] + 2, $star['x_loc'] + $offset_x + $off[0], $star['y_loc'] + $offset_y + $off[1], $star['num'] + 1, $color_st);
            } else {
                imagestring($im, $UNI['num_size'], $star['x_loc'] + $offset_x + $off[0], $star['y_loc'] + $offset_y + $off[1], $star['num'] + 1, $color_st);
            }
        }
    }
    //for just a preview we can quit while we're ahead.
    if (isset($preview)) {
        Header("Content-type: image/png");
        ImagePng($im);
        ImageDestroy($im);
        exit;
    }
    //Draw title centered on the horizontal
    imagestring($im, 5, $size_x / 2 - 80, 5, "Universal Star Map", $color_l);
    //Create buffer image
    $bb_im = imagecreatetruecolor($UNI['size_x'] + $UNI['localmapwidth'], $UNI['size_y'] + $UNI['localmapheight']);
    ImageColorAllocate($im, $UNI['bg_color'][0], $UNI['bg_color'][1], $UNI['bg_color'][2]);
    ImageCopy($bb_im, $im, $UNI['localmapwidth'] / 2, $UNI['localmapheight'] / 2, $offset_x, $offset_y, $size_x, $size_y);
    //Create printable map
    $p_im = imagecreatetruecolor($size_x, $size_y);
    ImageColorAllocate($p_im, $UNI['print_bg_color'][0], $UNI['print_bg_color'][1], $UNI['print_bg_color'][2]);
    ImageCopy($p_im, $im, 0, 0, 0, 0, $size_x, $size_y);
    //Replace colors
    $index = ImageColorExact($p_im, $UNI['bg_color'][0], $UNI['bg_color'][1], $UNI['bg_color'][2]);
    ImageColorSet($p_im, $index, $UNI['print_bg_color'][0], $UNI['print_bg_color'][1], $UNI['print_bg_color'][2]);
    $index = ImageColorExact($p_im, $UNI['link_color'][0], $UNI['link_color'][1], $UNI['link_color'][2]);
    ImageColorSet($p_im, $index, $UNI['print_link_color'][0], $UNI['print_link_color'][1], $UNI['print_link_color'][2]);
    $index = ImageColorExact($p_im, $UNI['num_color'][0], $UNI['num_color'][1], $UNI['num_color'][2]);
    ImageColorSet($p_im, $index, $UNI['print_num_color'][0], $UNI['print_num_color'][1], $UNI['print_num_color'][2]);
    $index = ImageColorExact($p_im, $UNI['num_color3'][0], $UNI['num_color3'][1], $UNI['num_color3'][2]);
    ImageColorSet($p_im, $index, $UNI['print_num_color'][0], $UNI['print_num_color'][1], $UNI['print_num_color'][2]);
    $index = ImageColorExact($p_im, $UNI['star_color'][0], $UNI['star_color'][1], $UNI['star_color'][2]);
    ImageColorSet($p_im, $index, $UNI['print_star_color'][0], $UNI['print_star_color'][1], $UNI['print_star_color'][2]);
    //Draw new label
    ImageFilledRectangle($p_im, 0, 0, $size_x, $UNI['map_border'], ImageColorExact($p_im, $UNI['print_bg_color'][0], $UNI['print_bg_color'][1], $UNI['print_bg_color'][2]));
    imagestring($p_im, 5, $size_x / 2 - 80, 5, "Printable Star Map", ImageColorExact($p_im, $UNI['print_label_color'][0], $UNI['print_label_color'][1], $UNI['print_label_color'][2]));
    //get random filename. primarily for it re-genning maps.
    if (empty($random_filename)) {
        db("select random_filename from se_games where db_name = '{$game_id}'");
        $temp_filename = dbr(1);
        $random_filename = $temp_filename['random_filename'];
    }
    //Save map and finish
    ImagePng($im, "{$directories['images']}/{$game_id}_maps/sm_full_{$random_filename}.png");
    ImageDestroy($im);
    ImagePng($bb_im, "{$directories['images']}/{$game_id}_maps/bb_full_{$random_filename}.png");
    ImageDestroy($bb_im);
    ImagePng($p_im, "{$directories['images']}/{$game_id}_maps/psm_full_{$random_filename}.png");
    ImageDestroy($p_im);
}
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:101,代码来源:build_universe.php

示例11: traiter_image


//.........这里部分代码省略.........
                $dest_ratio = $dest_height / $height_orig;
                $wo = $dest_width / $dest_ratio;
                $delta_x = ($width_orig - $wo) / 2;
                $width_orig = $wo;
                $next_height = $dest_height;
            } else {
                if ($exact != IMAGE_REDIM_BORDURE) {
                    $dest_height = $next_height;
                }
            }
        }
    }
    if ($exact == IMAGE_REDIM_BORDURE) {
        $border_width = intval(($dest_width - $next_width) / 2);
        $border_height = intval(($dest_height - $next_height) / 2);
    }
    $image_new = imagecreatetruecolor($dest_width, $dest_height);
    switch ($type) {
        case IMAGETYPE_GIF:
            $image_orig = imagecreatefromgif($nomorig);
            break;
        case IMAGETYPE_JPEG:
        default:
            $image_orig = imagecreatefromjpeg($nomorig);
            break;
        case IMAGETYPE_PNG:
            $image_orig = imagecreatefrompng($nomorig);
            break;
    }
    // Preparer la couleur de fond (pour bordures, transparence, miroir)
    if ($couleurfond == '') {
        $couleurfond = 'ffffff';
    }
    $fondrgb = hex2RGB($couleurfond);
    // Définir la couleur de fond générale
    $bgcolor = imagecolorallocate($image_new, $fondrgb['red'], $fondrgb['green'], $fondrgb['blue']);
    // Préserver la transparence des gifs et png
    if ($type != IMAGETYPE_JPEG) {
        $trnprt_indx = imagecolortransparent($image_orig);
        // If we have a specific transparent color
        if ($trnprt_indx >= 0) {
            // Get the original image's transparent color's RGB values
            $trnprt_color = imagecolorsforindex($image_orig, $trnprt_indx);
            // Allocate the same color in the new image resource
            $trnprt_indx = imagecolorallocate($image_new, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
            // Completely fill the background of the new image with allocated color.
            imagefill($image_new, 0, 0, $trnprt_indx);
            // Set the background color for new image to transparent
            imagecolortransparent($image_new, $trnprt_indx);
        } else {
            // Turn off transparency blending (temporarily)
            imagealphablending($image_new, false);
            // Create a new transparent color for image
            $color = imagecolorallocatealpha($image_new, 0, 0, 0, 127);
            // Completely fill the background of the new image with allocated color.
            imagefill($image_new, 0, 0, $color);
            // Restore transparency blending
            imagesavealpha($image_new, true);
            // Remplir avec la couleur de fond
            imagefill($image_new, 0, 0, $bgcolor);
        }
    } else {
        // Remplir avec la couleur de fond
        imagefill($image_new, 0, 0, $bgcolor);
    }
    if ($opacite != "") {
        $opac_img = imagecreatetruecolor($width_orig, $height_orig);
        imagefill($opac_img, 0, 0, $bgcolor);
        imagecopymerge($opac_img, $image_orig, 0, 0, 0, 0, $width_orig, $height_orig, $opacite);
        $image_orig = $opac_img;
    }
    // Redimensionnement, avec ajout éventuel de bordures.
    imagecopyresampled($image_new, $image_orig, $border_width, $border_height, $delta_x, $delta_y, $next_width, $next_height, $width_orig, $height_orig);
    // Noir et blanc
    if ($nb != "") {
        imagetruecolortopalette($image_new, false, 256);
        $total = ImageColorsTotal($image_new);
        for ($i = 0; $i < $total; $i++) {
            $old = ImageColorsForIndex($image_new, $i);
            $commongrey = (int) (($old['red'] + $old['green'] + $old['blue']) / 3);
            ImageColorSet($image_new, $i, $commongrey, $commongrey, $commongrey);
        }
    }
    if ($miroir != "") {
        $mh = intval($miroir) == 1 ? 50 : intval($miroir);
        $largeur = imagesx($image_new);
        $hauteur = imagesy($image_new);
        $temporaireUn = imagecreatetruecolor($largeur, $mh);
        $temporaireDeux = imagecreatetruecolor($largeur, $mh);
        $resultat = imagecreatetruecolor($largeur, $hauteur + $mh);
        imagefill($resultat, 1, 1, $bgcolor);
        imagefill($temporaireDeux, 1, 1, $bgcolor);
        imagecopy($resultat, $image_new, 0, 0, 0, 0, $largeur, $hauteur);
        imagecopy($temporaireUn, $image_new, 0, 0, 0, $hauteur - $mh, $largeur, $mh);
        effet_miroir($temporaireDeux, $temporaireUn);
        imagecopy($resultat, $temporaireDeux, 0, $hauteur, 0, 0, $largeur, $mh);
        $image_new = $resultat;
    }
    return $image_new;
}
开发者ID:anti-conformiste,项目名称:thelia1,代码行数:101,代码来源:image.php

示例12: desaturate

 /**
  * Desaturates an image, id optional $shade variable = 0 then image will be grey scale, 1 = red, 2 = greem 3 = blue
  *
  * NOTE: By adjusting the weight array prior to desaturating the image you can split the channels of an image.
  *
  * @param integer $shade What colour to shade the image
  * @return boolean Whether it was sucessful
  * @access public
  */
 function desaturate($shade = 0)
 {
     if (!$this->im) {
         return false;
     }
     //convert o,age to 256 colours
     ImageTrueColorToPalette($this->im, 1, 256);
     //calculate total number of colours in palette
     $total = ImageColorsTotal($this->im);
     //for each colour make it grey
     for ($i = 0; $i < $total; $i++) {
         $old = ImageColorsForIndex($this->im, $i);
         //get correct colouring by performing a weighted average of the 3
         $grey = round(($this->gamma[0] * $old["red"] + $this->gamma[1] * $old["green"] + $this->gamma[2] * $old["blue"]) / 3);
         if ($shade == 1) {
             ImageColorSet($this->im, $i, $grey, 0, 0);
         } else {
             if ($shade == 2) {
                 ImageColorSet($this->im, $i, 0, $grey, 0);
             } else {
                 if ($shade == 3) {
                     ImageColorSet($this->im, $i, 0, 0, $grey);
                 } else {
                     ImageColorSet($this->im, $i, $grey, $grey, $grey);
                 }
             }
         }
     }
     return true;
 }
开发者ID:xav335,项目名称:adanimalerie,代码行数:39,代码来源:imagemanipulator.php


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