本文整理汇总了PHP中ImageColorExact函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageColorExact函数的具体用法?PHP ImageColorExact怎么用?PHP ImageColorExact使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageColorExact函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetIndexDarkColor
function SetIndexDarkColor($which_color)
{
list($r, $g, $b) = $this->SetRGBColor($which_color);
$r -= 0x30;
$r = $r < 0 ? 0 : $r;
$g -= 0x30;
$g = $g < 0 ? 0 : $g;
$b -= 0x30;
$b = $b < 0 ? 0 : $b;
$index = ImageColorExact($this->img, $r, $g, $b);
if ($index == -1) {
return ImageColorResolve($this->img, $r, $g, $b);
} else {
return $index;
}
}
示例2: 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;
}
示例3: SetIndexColor
function SetIndexColor($which_color)
{
//Color is passed in as anything
list($r, $g, $b) = $this->SetRgbColor($which_color);
//Translate to RGB
$index = ImageColorExact($this->img, $r, $g, $b);
if ($index == -1) {
//return ImageColorAllocate($this->img, $r, $g, $b);
//return ImageColorClosest($this->img, $r, $g, $b);
return ImageColorResolve($this->img, $r, $g, $b);
//requires PHP 3.0.2 and later
} else {
return $index;
}
}
示例4: set_transparent_color
function set_transparent_color($r, $g, $b)
{
$r = $this->color($r);
$g = $this->color($g);
$b = $this->color($b);
$color_index = ImageColorExact($this->image, $r, $g, $b);
ImageColorTransparent($this->image, $color_index);
}
示例5: createMarkedImage
function createMarkedImage($type)
{
// Create marked image (original + watermark)
$this->marked_image = ImageCreateTrueColor($this->original_width, $this->original_height);
ImageCopy($this->marked_image, $this->original_image, 0, 0, 0, 0, $this->original_width, $this->original_height);
if ($this->transparent_color != -1) {
$transparent_color_index = ImageColorExact($this->mark_image, $this->transparent_color >> 16 & 0xff, $this->transparent_color >> 8 & 0xff, $this->transparent_color & 0xff);
ImageColorTransparent($this->mark_image, $transparent_color_index);
}
if ($this->gd_version >= 2) {
ImageAlphaBlending($this->marked_image, true);
}
if ($type == FILE_PNG) {
ImageCopy($this->marked_image, $this->mark_image, $this->mark_offset_x, $this->mark_offset_y, 0, 0, $this->mark_width, $this->mark_height);
} else {
ImageCopyMerge($this->marked_image, $this->mark_image, $this->mark_offset_x, $this->mark_offset_y, 0, 0, $this->mark_width, $this->mark_height, $this->transparency);
}
}
示例6: while
// Colour territories
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
// Allocate fill colour for un-occupied territories
if (in_array($row["powername"], array("Locals", "Neutral", "Warlords", "Pirates"))) {
if ($row["terrtype"] == "SEA") {
$bg = ImageColorExact($map, 0, 102, 255);
} else {
if ($row["terrtype"] == "OCE") {
$bg = ImageColorExact($map, 0, 0, 255);
} else {
$bg = ImageColorExact($map, 153, 153, 153);
}
}
} else {
$bg = ImageColorExact($map, $row["red"], $row["green"], $row["blue"]);
}
// Fill territory
ImageFill($map, $row["x"], $row["y"], $bg);
// Print only for Information Map points on large maps
if ($xsize > 500 and isset($row["info"]) ? $row["info"] : 0 == 1) {
// Draw outer circle
ImageFilledEllipse($map, $row["x"], $row["y"], 30, 24, $white);
// Draw resources
if ($row["minerals"] > 0) {
ImageFilledArc($map, $row["x"], $row["y"], 30, 24, 210 - 12 * $row["minerals"], 210 + 12 * $row["minerals"], $minerals, IMG_ARC_PIE);
}
if ($row["oil"] > 0) {
ImageFilledArc($map, $row["x"], $row["y"], 30, 24, 330 - 12 * $row["oil"], 330 + 12 * $row["oil"], $oil, IMG_ARC_PIE);
}
if ($row["grain"] > 0) {
示例7: 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);
}
示例8: make
//.........这里部分代码省略.........
$this->h = $XY[1];
// backColor is set
$BGcols = $this->convertColor($this->setup['backColor']);
$Bcolor = ImageColorAllocate($this->im, $BGcols[0], $BGcols[1], $BGcols[2]);
ImageFilledRectangle($this->im, 0, 0, $XY[0], $XY[1], $Bcolor);
// Traverse the GIFBUILDER objects an render each one:
if (is_array($this->setup)) {
$sKeyArray = t3lib_TStemplate::sortedKeyList($this->setup);
foreach ($sKeyArray as $theKey) {
$theValue = $this->setup[$theKey];
if (intval($theKey) && ($conf = $this->setup[$theKey . '.'])) {
switch ($theValue) {
// Images
case 'IMAGE':
if ($conf['mask']) {
$this->maskImageOntoImage($this->im, $conf, $this->workArea);
} else {
$this->copyImageOntoImage($this->im, $conf, $this->workArea);
}
break;
// Text
// Text
case 'TEXT':
if (!$conf['hide']) {
if (is_array($conf['shadow.'])) {
$this->makeShadow($this->im, $conf['shadow.'], $this->workArea, $conf);
}
if (is_array($conf['emboss.'])) {
$this->makeEmboss($this->im, $conf['emboss.'], $this->workArea, $conf);
}
if (is_array($conf['outline.'])) {
$this->makeOutline($this->im, $conf['outline.'], $this->workArea, $conf);
}
$conf['imgMap'] = 1;
$this->makeText($this->im, $conf, $this->workArea);
}
break;
// Text effects:
// Text effects:
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;
// Other
// Other
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->setWorkArea($conf['set']);
// this sets the workArea
}
if (isset($conf['clear'])) {
$this->workArea = $this->defaultWorkArea;
// this sets the current to the default;
}
break;
case 'ELLIPSE':
$this->makeEllipse($this->im, $conf, $this->workArea);
break;
}
}
}
}
if ($this->setup['transparentBackground']) {
// Auto transparent background is set
$Bcolor = ImageColorExact($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'], intval($this->setup['transparentColor.']['closest']));
if ($Tcolor >= 0) {
imagecolortransparent($this->im, $Tcolor);
}
}
}