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


PHP imagecolorresolve函数代码示例

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


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

示例1: fromBinary

 public static function fromBinary($binary)
 {
     $handle = imagecreatefromstring($binary);
     $whiteColor = imagecolorresolve($handle, 0xff, 0xff, 0xff);
     $blackColor = imagecolorresolve($handle, 0x0, 0x0, 0x0);
     return new self($handle, $whiteColor, $blackColor);
 }
开发者ID:kofel,项目名称:gutenberg,代码行数:7,代码来源:Image.php

示例2: toPngColor

 public function toPngColor($image)
 {
     $color = imagecolorallocate($image, $this->red, $this->green, $this->blue);
     if ($color == false) {
         $color = imagecolorresolve($image, $this->red, $this->green, $this->blue);
     }
     return $color;
 }
开发者ID:arioch31,项目名称:anarstock,代码行数:8,代码来源:Color.class.php

示例3: testGetColorAt

 public function testGetColorAt()
 {
     $CGraphImageHandler = new ImageHandler(new Image(__DIR__ . '/resource/color_red.jpg'));
     $this->assertEquals(imagecolorresolve($CGraphImageHandler->getImage(), 254, 0, 0), $CGraphImageHandler->getColorAt(1, 1));
     $CGraphImageHandler = new ImageHandler(new Image(__DIR__ . '/resource/color_green.jpg'));
     $this->assertEquals(imagecolorresolve($CGraphImageHandler->getImage(), 0, 255, 1), $CGraphImageHandler->getColorAt(1, 1));
     $CGraphImageHandler = new ImageHandler(new Image(__DIR__ . '/resource/color_blue.jpg'));
     $this->assertEquals(imagecolorresolve($CGraphImageHandler->getImage(), 0, 0, 254), $CGraphImageHandler->getColorAt(1, 1));
 }
开发者ID:moszkva,项目名称:cgraph,代码行数:9,代码来源:ImageHandlerTest.php

示例4: RequestInfo

 /**
  * This function will be available automatically after the module is imported with the module control.
  * Using the custom prefix this function will be callable from PHP and JSON-RPC through:
  *
  * UWZ_RequestInfo($id);
  *
  */
 public function RequestInfo()
 {
     $imagePath = IPS_GetKernelDir() . $this->imagePath;
     $area = $this->ReadPropertyString("area");
     $homeX = $this->ReadPropertyInteger("homeX");
     $homeY = $this->ReadPropertyInteger("homeY");
     $homeRadius = $this->ReadPropertyInteger("homeRadius");
     //Calculate time
     $minute = floor(date("i") / 15) * 15;
     $dateline = mktime(date("H"), $minute, 0, date("m"), date("d"), date("y"));
     //Download picture
     $opts = array('http' => array('method' => "GET", 'max_redirects' => 1));
     $context = stream_context_create($opts);
     $remoteImage = "http://www.wetteronline.de/daten/radar/{$area}/" . gmdate("Y", $dateline) . "/" . gmdate("m", $dateline) . "/" . gmdate("d", $dateline) . "/" . gmdate("Hi", $dateline) . ".gif";
     $data = @file_get_contents($remoteImage, false, $context);
     if ($data === false) {
         //No new picture. Download old one.
         $dateline -= 15 * 60;
         $remoteImage = "http://www.wetteronline.de/daten/radar/{$area}/" . gmdate("Y", $dateline) . "/" . gmdate("m", $dateline) . "/" . gmdate("d", $dateline) . "/" . gmdate("Hi", $dateline) . ".gif";
         $data = @file_get_contents($remoteImage, false, $context);
         if ($data === false) {
             return;
         }
     }
     if (strpos($http_response_header[0], "200") === false) {
         return;
     }
     file_put_contents($imagePath, $data);
     //Radarbild auswerten
     $im = ImageCreateFromGIF($imagePath);
     //Stärken
     $regen[6] = imagecolorresolve($im, 250, 2, 250);
     $regen[5] = imagecolorresolve($im, 156, 50, 156);
     $regen[4] = imagecolorresolve($im, 28, 126, 220);
     $regen[3] = imagecolorresolve($im, 44, 170, 252);
     $regen[2] = imagecolorresolve($im, 84, 210, 252);
     $regen[1] = imagecolorresolve($im, 172, 254, 252);
     //Pixel durchgehen
     $regenmenge = 0;
     for ($x = $homeX - $homeRadius; $x <= $homeX + $homeRadius; $x++) {
         for ($y = $homeY - $homeRadius; $y <= $homeY + $homeRadius; $y++) {
             $found = array_search(imagecolorat($im, $x, $y), $regen);
             if (!($found === FALSE)) {
                 $regenmenge += $found;
             }
         }
     }
     // Bereich zeichnen
     $schwarz = ImageColorAllocate($im, 0, 0, 0);
     $rot = ImageColorAllocate($im, 255, 0, 0);
     imagerectangle($im, $homeX - $homeRadius, $homeY - $homeRadius, $homeX + $homeRadius, $homeY + $homeRadius, $rot);
     imagesetpixel($im, $homeX, $homeY, $rot);
     imagegif($im, $localImage);
     imagedestroy($im);
     SetValue($this->GetIDForIdent("RainValue"), $regenmenge);
 }
开发者ID:Bonox1,项目名称:SymconMisc,代码行数:63,代码来源:module.php

示例5: horizontal

 function horizontal($start, $end)
 {
     for ($x = 0; $x < $this->gradient_width; $x++) {
         foreach ($start as $k => $v) {
             $diff = $start[$k] - $end[$k];
             $new[$k] = $start[$k] - intval($diff / $this->gradient_width * $x);
         }
         $col_color = imagecolorresolve($this->image, $new['red'], $new['green'], $new['blue']);
         imagefilledrectangle($this->image, $x, 0, $x, $this->gradient_height, $col_color);
     }
 }
开发者ID:re5et,项目名称:trickyInc,代码行数:11,代码来源:trickyImg.php

示例6: my_draw

function my_draw($img, $plot)
{
    $black = imagecolorresolve($img, 0, 0, 0);
    $x = 100;
    $y = 50;
    $dy = 30;
    $plot->DrawText('', 0, $x, $y += $dy, $black, 'Font="" (generic): sans italic 12pt');
    $plot->DrawText('generic', 0, $x, $y += $dy, $black, 'Font="generic": sans italic 12pt');
    $plot->DrawText('legend', 0, $x, $y += $dy, $black, 'Font="legend": serif bold 14pt');
    $plot->DrawText($plot->fonts['title'], 0, $x, $y += $dy, $black, 'Font=fonts["title"]: sans 12pt');
    $plot->DrawText('x_title', 0, $x, $y += $dy, $black, 'Font="x_title": mono bold 10pt');
}
开发者ID:myfarms,项目名称:PHPlot,代码行数:12,代码来源:drawtextfont.php

示例7: captcha

 function captcha()
 {
     require dirname(__FILE__) . '/captcha-config.php';
     $this->keystring = '';
     for ($i = 0; $i < $length; $i++) {
         $this->keystring .= $use_symbols[mt_rand(0, $use_symbols_len - 1)];
     }
     $im = imagecreatefromgif(dirname(__FILE__) . "/back.gif");
     $width = imagesx($im);
     $height = imagesy($im);
     $rc = mt_rand(120, 140);
     $font_color = imagecolorresolve($im, $rc, $rc, $rc);
     $px = $margin_left;
     for ($i = 0; $i < $length; $i++) {
         imagettftext($im, $font_size, 0, $px, $margin_top, $font_color, dirname(__FILE__) . "/CARTOON8.TTF", $this->keystring[$i]);
         $px += $font_width + mt_rand($rand_bsimb_min, $rand_bsimb_max);
     }
     $h_y = mt_rand(0, $height);
     $h_y1 = mt_rand(0, $height);
     imageline($im, mt_rand(0, 20), $h_y, mt_rand($width - 20, $width), $h_y1, $font_color);
     imageline($im, mt_rand(0, 20), $h_y, mt_rand($width - 20, $width), $h_y1, $font_color);
     $h_y = mt_rand(0, $height);
     $h_y1 = mt_rand(0, $height);
     imageline($im, mt_rand(0, 20), $h_y, mt_rand($width - 20, $width), $h_y1, $font_color);
     imageline($im, mt_rand(0, 20), $h_y, mt_rand($width - 20, $width), $h_y1, $font_color);
     image_make_pomexi($im, 50, 80);
     $rand = mt_rand(0, 1);
     if ($rand) {
         $rand = -1;
     } else {
         $rand = 1;
     }
     wave_region($im, 0, 0, $width, $height, $rand * mt_rand($amplitude_min, $amplitude_max), mt_rand(30, 40));
     header('Expires: Sat, 17 May 2008 05:00:00 GMT');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Cache-Control: post-check=0, pre-check=0', FALSE);
     header('Pragma: no-cache');
     if (function_exists("imagejpeg")) {
         header("Content-Type: image/jpeg");
         imagejpeg($im, null, $jpeg_quality);
     } else {
         if (function_exists("imagegif")) {
             header("Content-Type: image/gif");
             imagegif($im);
         } else {
             if (function_exists("imagepng")) {
                 header("Content-Type: image/x-png");
                 imagepng($im);
             }
         }
     }
 }
开发者ID:hiimdonald,项目名称:hiimdonald,代码行数:52,代码来源:captcha-gen.php

示例8: twMachTransparent

function twMachTransparent($img)
{
    $farbePixel = imagecolorat($img, $_SESSION['klamotteDruckmass'][0] + 1, $_SESSION['klamotteDruckmass'][1] + 1);
    $farbwerte = imagecolorsforindex($img, $farbePixel);
    $transp = imagecolorresolve($img, $farbwerte["red"], $farbwerte["green"], $farbwerte["blue"]);
    ///$transp = imagecolorallocate($ziel, $farbwerte["red"], $farbwerte["green"], $farbwerte["blue"]);
    ///$transp = imagecolorallocatealpha($ziel, $farbwerte["red"], $farbwerte["green"], $farbwerte["blue"], 53);
    imagefill($img, 0, 0, $transp);
    // sonst is Rest des Bildes schwarz
    imagecolortransparent($img, $transp);
    //imagealphablending ($ziel, false);
    //imagesavealpha($target, true);
    return $img;
}
开发者ID:BackupTheBerlios,项目名称:shirtbemaler-svn,代码行数:14,代码来源:machVorschaubildMotivOhneSave.php

示例9: write_text

/**
* Write text on images
*/
function write_text($source_pic, $dest_pic, $text_content, $text_font, $text_size = 10, $text_color = '#FFFFFF', $text_position = '0')
{
    $temp_pic = imagecreatefromgif($source_pic);
    list($image_width, $image_height) = getimagesize($source_pic);
    /*
    $temp_pic_empty = imagecreatetruecolor ($image_width, $image_height);
    imagealphablending($temp_pic_empty, false);
    imagecopyresampled($temp_pic_empty, $temp_pic, 0, 0, 0, 0, $image_width, $image_height, $image_width, $image_height);
    imagesavealpha($temp_pic_empty, true);
    //imagepng($im_re, 'small_redfade.png');
    $temp_pic2 = imagecreatefrompng($source_pic);
    */
    // Calculate the centre
    for (;;) {
        list($left_x, , $right_x) = imagettfbbox($text_size, $text_position, $text_font, $text_content);
        $text_width = $right_x - $left_x;
        if ($image_width > $text_width + 5) {
            break;
        }
        $text_size = $text_size - 0.5;
        if ($text_size == 1) {
            die('Font size may not be reduced further, try to insert a shorter text');
        }
    }
    $text_padding = ($image_width - $text_width) / 2;
    $text_color = substr($text_color, 0, 1) == '#' ? substr($text_color, 1, 6) : $text_color;
    $text_color_r = hexdec(substr($text_color, 0, 2));
    $text_color_g = hexdec(substr($text_color, 2, 2));
    $text_color_b = hexdec(substr($text_color, 4, 2));
    $text_color = imagecolorresolve($temp_pic, $text_color_r, $text_color_g, $text_color_b);
    //$text_color = imagecolorallocate($temp_pic, $text_color_r, $text_color_g, $text_color_b);
    imagettftext($temp_pic, $text_size, $text_position, $text_padding, $image_height - $text_size / 2, $text_color, $text_font, $text_content);
    if ($_GET['dl']) {
        header('Content-Disposition: attachment; filename="avatar.gif"');
    }
    /*
    header("Content-type: image/png");
    imagepng($temp_pic, $dest_pic);
    imagepng($temp_pic);
    imagedestroy($temp_pic);
    */
    header('Content-type: image/gif');
    imagegif($temp_pic, $dest_pic);
    imagegif($temp_pic);
    imagedestroy($temp_pic);
    return true;
}
开发者ID:ALTUN69,项目名称:icy_phoenix,代码行数:50,代码来源:generate_avatar.php

示例10: cb

function cb($img, $arg)
{
    global $wasnt_called;
    static $x = 20;
    static $y = 20;
    static $color_index = -1;
    // Color not yet allocated.
    # Cannot output this in normal test mode or it thinks we failed.
    # fwrite(STDERR, "callback: $arg\n");
    # Make a color index. Use gray (146,146,146) for compatibility with
    # older versions of this test which blindly used color index 1.
    if ($color_index == -1) {
        $color_index = imagecolorresolve($img, 146, 146, 146);
    }
    imagestring($img, 3, $x, $y, "CB: {$arg}", $color_index);
    $y += 20;
    # Mark it has being called:
    unset($wasnt_called[$arg]);
}
开发者ID:myfarms,项目名称:PHPlot,代码行数:19,代码来源:callback1.php

示例11: annotate_plot

function annotate_plot($img, $plot)
{
    global $best_index, $best_sales, $worst_index, $worst_sales;
    # Allocate our own colors, rather than poking into the PHPlot object:
    $red = imagecolorresolve($img, 255, 0, 0);
    $green = imagecolorresolve($img, 0, 216, 0);
    # Get the pixel coordinates of the data points for the best and worst:
    list($best_x, $best_y) = $plot->GetDeviceXY($best_index, $best_sales);
    list($worst_x, $worst_y) = $plot->GetDeviceXY($worst_index, $worst_sales);
    # Draw ellipses centered on those two points:
    imageellipse($img, $best_x, $best_y, 50, 20, $green);
    imageellipse($img, $worst_x, $worst_y, 50, 20, $red);
    # Place some text above the points:
    $font = '3';
    $fh = imagefontheight($font);
    $fw = imagefontwidth($font);
    imagestring($img, $font, $best_x - $fw * 4, $best_y - $fh - 10, 'Good Job!', $green);
    # We can also use the PHPlot internal function for text.
    # It does the center/bottom alignment calculations for us.
    # Specify the font argument as NULL or '' to use the generic one.
    $plot->DrawText('', 0, $worst_x, $worst_y - 10, $red, 'Bad News!', 'center', 'bottom');
}
开发者ID:myfarms,项目名称:PHPlot,代码行数:22,代码来源:annotate.php

示例12: rotate

 /**
  * Rotates image by the given angle
  *
  * Uses a fast rotation algorythm for custom angles
  * or lines copy for multiple of 90 degrees
  *
  * @param int   $angle   Rotation angle
  * @param array $options array(
  *                             'canvasColor' => array(r ,g, b), named color or #rrggbb
  *                            )
  * @author Pierre-Alain Joye
  * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
  * @access public
  */
 function rotate($angle, $options = null)
 {
     if ($angle % 360 == 0) {
         return true;
     }
     $color_mask = $this->_getColor('canvasColor', $options, array(255, 255, 255));
     $mask = imagecolorresolve($this->imageHandle, $color_mask[0], $color_mask[1], $color_mask[2]);
     $this->old_image = $this->imageHandle;
     // Multiply by -1 to change the sign, so the image is rotated clockwise
     $this->imageHandle = ImageRotate($this->imageHandle, $angle * -1, $mask);
     return true;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:26,代码来源:GD.php

示例13: addText

 /**
  * addText
  *
  * @param   array   options     Array contains options
  *                              array(
  *                                  'text'  The string to draw
  *                                  'x'     Horizontal position
  *                                  'y'     Vertical Position
  *                                  'Color' Font color
  *                                  'font'  Font to be used
  *                                  'size'  Size of the fonts in pixel
  *                                  'resize_first'  Tell if the image has to be resized
  *                                                  before drawing the text
  *                              )
  *
  * @return none
  * @see PEAR::isError()
  */
 function addText($params)
 {
     $default_params = array('text' => 'This is Text', 'x' => 10, 'y' => 20, 'color' => array(255, 0, 0), 'font' => 'Arial.ttf', 'size' => '12', 'angle' => 0, 'resize_first' => false);
     $params = array_merge($default_params, $params);
     extract($params);
     if (!is_array($color)) {
         if ($color[0] == '#') {
             $this->colorhex2colorarray($color);
         } else {
             include_once 'Image/Transform/Driver/ColorsDefs.php';
             $color = isset($colornames[$color]) ? $colornames[$color] : false;
         }
     }
     $c = imagecolorresolve($this->imageHandle, $color[0], $color[1], $color[2]);
     if ('ttf' == substr($font, -3)) {
         ImageTTFText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text);
     } else {
         ImagePSText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text);
     }
     return true;
 }
开发者ID:blacksqr,项目名称:portable-nsd,代码行数:39,代码来源:GD.php

示例14: DrawMessage

 function DrawMessage($text, $options = NULL)
 {
     // Merge options with defaults, and set as local variables:
     extract(array_merge(array('draw_background' => FALSE, 'draw_border' => FALSE, 'force_print' => TRUE, 'reset_font' => TRUE, 'text_color' => '', 'text_wrap' => TRUE, 'wrap_width' => 75), (array) $options));
     // Do colors, background, and border:
     if ($draw_border && !isset($this->ndx_i_border) || $draw_background && !isset($this->ndx_bg_color)) {
         $this->SetBgColorIndexes();
     }
     if ($draw_background) {
         // User-specified background
         $this->DrawBackground(TRUE);
         // TRUE means force overwriting of background
     } else {
         // Default to plain white background
         $bgcolor = imagecolorresolve($this->img, 255, 255, 255);
         ImageFilledRectangle($this->img, 0, 0, $this->image_width, $this->image_height, $bgcolor);
     }
     if ($draw_border) {
         $this->DrawImageBorder(TRUE);
     }
     if (empty($text_color)) {
         $rgb = array(0, 0, 0);
     } else {
         $rgb = $this->SetRGBColor($text_color);
     }
     $ndx_text_color = imagecolorresolve($this->img, $rgb[0], $rgb[1], $rgb[2]);
     // Error images should reset fonts, to avoid chance of a TTF error when displaying an error.
     if ($reset_font) {
         $this->SetUseTTF(FALSE);
     }
     // Determine the space needed for the text, and center the text box within the image:
     if ($text_wrap) {
         $text = wordwrap($text, $wrap_width);
     }
     list($text_width, $text_height) = $this->SizeText('generic', 0, $text);
     $x = max($this->safe_margin, ($this->image_width - $text_width) / 2);
     $y = max($this->safe_margin, ($this->image_height - $text_height) / 2);
     $this->DrawText('generic', 0, $x, $y, $ndx_text_color, $text, 'left', 'top');
     if ($force_print || $this->print_image) {
         $this->PrintImage();
     }
     return TRUE;
 }
开发者ID:danorama,项目名称:orsee,代码行数:43,代码来源:class.phplot.php

示例15: imagegreyscale

function imagegreyscale(&$img)
{
    $x = imagesx($img);
    $y = imagesy($img);
    for ($i = 0; $i < $y; $i++) {
        for ($j = 0; $j < $x; $j++) {
            $pos = imagecolorat($img, $j, $i);
            $f = imagecolorsforindex($img, $pos);
            $gst = $f['red'] * 0.15 + $f['green'] * 0.5 + $f['blue'] * 0.35;
            $col = imagecolorresolve($img, $gst, $gst, $gst);
            imagesetpixel($img, $j, $i, $col);
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:14,代码来源:function.phpcore.php


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