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

PHP imagecolorresolve函数代码示例

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

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



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


示例16: _wave

 /**
  * Apply a wave filter to an image
  *
  * @param	image	 image			  Image  to convert
  * @param	int		   wave			   Amount of wave to apply
  * @param	bool	randirection	Randomize direction of wave
  *
  * @return	 image
  */
 function _wave(&$image, $wave = 10, $randirection = true)
 {
     $image_width = imagesx($image);
     $image_height = imagesy($image);
     $temp = $this->_imagecreate($image_width, $image_height);
     if ($randirection) {
         $direction = mt_rand(0, 1) == 1 ? true : false;
     }
     for ($x = 0; $x < $image_width; $x++) {
         for ($y = 0; $y < $image_height; $y++) {
             $xo = $wave * sin(2 * 3.1415 * $y / 128);
             $yo = $wave * cos(2 * 3.1415 * $x / 128);
             if ($direction) {
                 $newx = $x - $xo;
                 $newy = $y - $yo;
             } else {
                 $newx = $x + $xo;
                 $newy = $y + $yo;
             }
             if ($newx > 0 and $newx < $image_width and ($newy > 0 and $newy < $image_height)) {
                 $index = imagecolorat($image, $newx, $newy);
                 $colors = imagecolorsforindex($image, $index);
                 $color = imagecolorresolve($temp, $colors['red'], $colors['green'], $colors['blue']);
             } else {
                 $color = imagecolorresolve($temp, 255, 255, 255);
             }
             imagesetpixel($temp, $x, $y, $color);
         }
     }
     return $temp;
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:40,代码来源:class.veriword.php


示例17: imagesx

 /**
  *
  * Apply a wave filter to an image
  *
  * @param	image	image			Image  to convert
  * @param	int		wave			Amount of wave to apply
  * @param	bool	randirection	Randomize direction of wave
  *
  * @return	image
  */
 protected function &wave(&$image, $wave = 10, $randirection = true)
 {
     $image_width = imagesx($image);
     $image_height = imagesy($image);
     $temp = imagecreatetruecolor($image_width, $image_height);
     if ($randirection) {
         $direction = vB::getRequest()->getTimeNow() & 2 ? true : false;
     }
     $middlex = floor($image_width / 2);
     $middley = floor($image_height / 2);
     for ($x = 0; $x < $image_width; $x++) {
         for ($y = 0; $y < $image_height; $y++) {
             $xo = $wave * sin(2 * 3.1415 * $y / 128);
             $yo = $wave * cos(2 * 3.1415 * $x / 128);
             if ($direction) {
                 $newx = $x - $xo;
                 $newy = $y - $yo;
             } else {
                 $newx = $x + $xo;
                 $newy = $y + $yo;
             }
             if ($newx > 0 and $newx < $image_width and ($newy > 0 and $newy < $image_height)) {
                 $index = imagecolorat($image, $newx, $newy);
                 $colors = imagecolorsforindex($image, $index);
                 $color = imagecolorresolve($temp, $colors['red'], $colors['green'], $colors['blue']);
             } else {
                 $color = imagecolorresolve($temp, 255, 255, 255);
             }
             imagesetpixel($temp, $x, $y, $color);
         }
     }
     return $temp;
 }
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:43,代码来源:gd.php


示例18: make_copyright_gd1

 /**
  * For GDLib V1.0
  * Creates the rectangle sets the colors and the text and saves the new image.  Returns void.
  * @public
  * @returns void
  */
 function make_copyright_gd1($datei)
 {
     $this->set_imageinfo($datei);
     $rectanglelen = strlen($this->copytext) * 7.5;
     if ($this->imageinfo[2] == 1) {
         $img = imagecreatefromgif("{$datei}");
     }
     if ($this->imageinfo[2] == 2) {
         $img = imagecreatefromjpeg("{$datei}");
     }
     if ($this->imageinfo[2] == 3) {
         $img = imagecreatefrompng("{$datei}");
     }
     $textcolor = imagecolorresolve($img, $this->copytextcolor[red], $this->copytextcolor[green], $this->copytextcolor[blue]);
     $bgcolor = imagecolorresolve($img, $this->copybgcolor[red], $this->copybgcolor[green], $this->copybgcolor[blue]);
     $korrektur = -25;
     if ($this->copyinpicture == 2) {
         if ($this->copyposition == 1 or $this->copyposition == 4) {
             $up = 25;
             $rectx1 = 0;
             $recty1 = 0;
             $rectx2 = $this->imageinfo[0];
             $recty2 = 25;
         }
         if ($this->copyposition == 2 or $this->copyposition == 3) {
             $up = 0;
             $rectx1 = 0;
             $recty1 = $this->imageinfo[1];
             $rectx2 = $this->imageinfo[0];
             $recty2 = $this->imageinfo[1] + 25;
         }
         $korrektur = 0;
         $imgh = imagecreate($this->imageinfo[0], $this->imageinfo[1] + 25);
         imagecopy($imgh, $img, 0, $up, 0, 0, $this->imageinfo[0], $this->imageinfo[1]);
         $img = $imgh;
         $textcolor = imagecolorresolve($img, $this->copytextcolor[red], $this->copytextcolor[green], $this->copytextcolor[blue]);
         $bgcolor = imagecolorresolve($img, $this->copybgcolor[red], $this->copybgcolor[green], $this->copybgcolor[blue]);
         imagefilledrectangle($img, $rectx1, $recty1, $rectx2, $recty2, $bgcolor);
     }
     if ($this->copyposition == 1) {
         $recty1 = 0;
         $rectx1 = 0;
         $rectx2 = $rectx1 + $rectanglelen;
         $recty2 = $recty1 + 25;
         $textup = 5;
         $textleft = 7;
     } elseif ($this->copyposition == 2) {
         $recty1 = $this->imageinfo[1] + $korrektur;
         $rectx1 = 0;
         $rectx2 = $rectx1 + $rectanglelen;
         $recty2 = $recty1 + 25;
         $textup = $recty1 + 5;
         $textleft = 7;
     } elseif ($this->copyposition == 3) {
         $rectx1 = $this->imageinfo[0] - $rectanglelen;
         $rectx2 = $this->imageinfo[0];
         $recty1 = $this->imageinfo[1] + $korrektur;
         $recty2 = $recty1 + 25;
         $textup = $recty1 + 5;
         $textleft = $this->imageinfo[0] - $rectanglelen + 7;
     } elseif ($this->copyposition == 4) {
         $recty1 = 0;
         $rectx1 = $this->imageinfo[0] - $rectanglelen;
         $rectx2 = $rectx1 + $rectanglelen;
         $recty2 = $recty1 + 25;
         $textup = 5;
         $textleft = $this->imageinfo[0] - $rectanglelen + 7;
     }
     if ($this->ractanglebg == 1) {
         imagefilledrectangle($img, $rectx1, $recty1, $rectx2, $recty2, $bgcolor);
     }
     imagestring($img, 3, $textleft, $textup, $this->copytext, $textcolor);
     if ($this->imageinfo[2] == 1) {
         imagegif($img, "{$datei}");
     }
     if ($this->imageinfo[2] == 2) {
         if ($this->{$jpg_IPTC}['create'] == 1) {
             /*
             $this->jpg_IPTC['name']          	= $name;
             $this->jpg_IPTC['copyright']        = $copyright;
             $this->jpg_IPTC['creator']         	= $creator;
             //array iptcembed ( string iptcdata, string jpeg_file_name [, int spool])
             */
         }
         imagejpeg($img, "{$datei}");
     }
     if ($this->imageinfo[2] == 3) {
         imagepng($img, "{$datei}");
     }
 }
开发者ID:BackupTheBerlios,项目名称:rescuedogportal-svn,代码行数:96,代码来源:class.copyright.php


示例19: rotate

 /**
  * Rotate 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(  'autoresize'=>true|false,
  *                                      'color_mask'=>array(r,g,b), named color or #rrggbb
  *                                   )
  * @author Pierre-Alain Joye
  * @return mixed none or a PEAR error object on error
  * @see PEAR::isError()
  */
 function rotate($angle, $options = null)
 {
     if (function_exists('imagerotate')) {
         $white = imagecolorallocate($this->imageHandle, 255, 255, 255);
         $this->imageHandle = imagerotate($this->imageHandle, $angle, $white);
         return true;
     }
     if ($options == null) {
         $autoresize = true;
         $color_mask = array(255, 255, 0);
     } else {
         extract($options);
     }
     while ($angle <= -45) {
         $angle += 360;
     }
     while ($angle > 270) {
         $angle -= 360;
     }
     $t = deg2rad($angle);
     if (!is_array($color_mask)) {
         if ($color[0] == '#') {
             $this->colorhex2colorarray($color_mask);
         } else {
             include_once 'Image/Transform/Driver/ColorDefs.php';
             $color = isset($colornames[$color_mask]) ? $colornames[$color_mask] : false;
         }
     }
     // Do not round it, too much lost of quality
     $cosT = cos($t);
     $sinT = sin($t);
     $img =& $this->imageHandle;
     $width = $max_x = $this->img_x;
     $height = $max_y = $this->img_y;
     $min_y = 0;
     $min_x = 0;
     $x1 = round($max_x / 2, 0);
     $y1 = round($max_y / 2, 0);
     if ($autoresize) {
         $t = abs($t);
         $a = round($angle, 0);
         switch ((int) $angle) {
             case 0:
                 $width2 = $width;
                 $height2 = $height;
                 break;
             case 90:
                 $width2 = $height;
                 $height2 = $width;
                 break;
             case 180:
                 $width2 = $width;
                 $height2 = $height;
                 break;
             case 270:
                 $width2 = $height;
                 $height2 = $width;
                 break;
             default:
                 $width2 = (int) abs(sin($t) * $height + cos($t) * $width);
                 $height2 = (int) abs(cos($t) * $height + sin($t) * $width);
         }
         $width2 -= $width2 % 2;
         $height2 -= $height2 % 2;
         $d_width = abs($width - $width2);
         $d_height = abs($height - $height2);
         $x_offset = $d_width / 2;
         $y_offset = $d_height / 2;
         $min_x2 = -abs($x_offset);
         $min_y2 = -abs($y_offset);
         $max_x2 = $width2;
         $max_y2 = $height2;
     }
     $img2 = @imagecreate($width2, $height2);
     if (!is_resource($img2)) {
         return false;
         /*PEAR::raiseError('Cannot create buffer for the rotataion.',
           null, PEAR_ERROR_TRIGGER, E_USER_NOTICE);*/
     }
     $this->img_x = $width2;
     $this->img_y = $height2;
     imagepalettecopy($img2, $img);
     $mask = imagecolorresolve($img2, $color_mask[0], $color_mask[1], $color_mask[2]);
     // use simple lines copy for axes angles
     switch ((int) $angle) {
         case 0:
             imagefill($img2, 0, 0, $mask);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:101,代码来源:GD.php


示例20: renderAlphaForPalette

 protected function renderAlphaForPalette(&$dst, $src, $dstx, $dsty, $srcx, $srcy, $srcw, $srch)
 {
     $partialtransparent = array();
     imagealphablending($src, false);
     imagesavealpha($src, true);
     $width = $srcx + $srcw - 1;
     $height = $srcy + $srch - 1;
     $x = $srcx;
     $y = $srcy;
     while ($y <= $height) {
         $index = imagecolorat($src, $x, $y);
         $color = imagecolorsforindex($src, $index);
         if ($color['alpha'] > 0 && $color['alpha'] < 127) {
             $partialtransparent[] = array('x' => $x - $srcx, 'y' => $y - $srcy);
         }
         if ($x < $width) {
             $x++;
         } else {
             if ($x === $width && $y < $height) {
                 $x = $srcx;
                 $y++;
             } else {
                 if ($x === $width && $y === $height) {
                     break;
                 }
             }
         }
     }
     $whiteindex = imagecolorresolve($dst, 255, 255, 255);
     foreach ($partialtransparent as $value) {
         $index = imagecolorat($dst, $value['x'] + $dstx, $value['y'] + $dsty);
         $color = imagecolorsforindex($dst, $index);
         if ($color['alpha'] === 127) {
             imagesetpixel($dst, $value['x'] + $dstx, $value['y'] + $dsty, $whiteindex);
         }
     }
 }
开发者ID:feeel1,项目名称:akina,代码行数:37,代码来源:Output.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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