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


PHP imagecolordeallocate函数代码示例

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


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

示例1: getAvatar

 public function getAvatar($string, $widthHeight = 12, $theme = 'default')
 {
     $widthHeight = max($widthHeight, 12);
     $md5 = md5($string);
     $fileName = _TMP_DIR_ . '/' . $md5 . '.png';
     if ($this->tmpFileExists($fileName)) {
         return $fileName;
     }
     // Create seed.
     $seed = intval(substr($md5, 0, 6), 16);
     mt_srand($seed);
     $body = array('legs' => mt_rand(0, count($this->availableParts[$theme]['legs']) - 1), 'hair' => mt_rand(0, count($this->availableParts[$theme]['hair']) - 1), 'arms' => mt_rand(0, count($this->availableParts[$theme]['arms']) - 1), 'body' => mt_rand(0, count($this->availableParts[$theme]['body']) - 1), 'eyes' => mt_rand(0, count($this->availableParts[$theme]['eyes']) - 1), 'mouth' => mt_rand(0, count($this->availableParts[$theme]['mouth']) - 1));
     // Avatar random parts.
     $parts = array('legs' => $this->availableParts[$theme]['legs'][$body['legs']], 'hair' => $this->availableParts[$theme]['hair'][$body['hair']], 'arms' => $this->availableParts[$theme]['arms'][$body['arms']], 'body' => $this->availableParts[$theme]['body'][$body['body']], 'eyes' => $this->availableParts[$theme]['eyes'][$body['eyes']], 'mouth' => $this->availableParts[$theme]['mouth'][$body['mouth']]);
     $avatar = imagecreate($widthHeight, $widthHeight);
     imagesavealpha($avatar, true);
     imagealphablending($avatar, false);
     $background = imagecolorallocate($avatar, 0, 0, 0);
     $line_colour = imagecolorallocate($avatar, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55);
     imagecolortransparent($avatar, $background);
     imagefilledrectangle($avatar, 0, 0, $widthHeight, $widthHeight, $background);
     // Fill avatar with random parts.
     foreach ($parts as &$part) {
         $this->drawPart($part, $avatar, $widthHeight, $line_colour, $background);
     }
     imagepng($avatar, $fileName);
     imagecolordeallocate($avatar, $line_colour);
     imagecolordeallocate($avatar, $background);
     imagedestroy($avatar);
     return $fileName;
 }
开发者ID:recallfx,项目名称:monsterid.php,代码行数:31,代码来源:MonsterId.php

示例2: color

 static function color(&$imgage, $color = 'ffffff', $delete = false)
 {
     $cd = str_split($color, strlen($color) > 4 ? 2 : 1);
     $color = imagecolorallocate($imgage, hexdec($cd[0]), hexdec($cd[1]), hexdec($cd[2]));
     $delete && imagecolordeallocate($imgage, $color);
     return $color;
 }
开发者ID:mjiong,项目名称:framework,代码行数:7,代码来源:image.php

示例3: free

 /**
  * Free resources used for this color
  */
 function free()
 {
     if ($this->resource !== NULL) {
         @imagecolordeallocate($this->resource, $this->color);
         $this->resource = NULL;
     }
 }
开发者ID:ber5ien,项目名称:www.jade-palace.co.uk,代码行数:10,代码来源:Color.class.php

示例4: renderImage

 /**
  * Renders the CAPTCHA image based on the code.
  * @param string the verification code
  * @return string image content
  */
 protected function renderImage($code)
 {
     $image = imagecreatetruecolor($this->width, $this->height);
     $backColor = imagecolorallocate($image, (int) ($this->backColor % 0x1000000 / 0x10000), (int) ($this->backColor % 0x10000 / 0x100), $this->backColor % 0x100);
     imagefilledrectangle($image, 0, 0, $this->width, $this->height, $backColor);
     imagecolordeallocate($image, $backColor);
     $foreColor = imagecolorallocate($image, (int) ($this->foreColor % 0x1000000 / 0x10000), (int) ($this->foreColor % 0x10000 / 0x100), $this->foreColor % 0x100);
     if ($this->fontFile === null) {
         $this->fontFile = dirname(__FILE__) . '/Duality.ttf';
     }
     $len = strlen($code);
     $fontSize = $this->height - $this->padding * 2;
     for ($i = 0; $i < $len; $i++) {
         $foreColor = imagecolorallocate($image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         $angle = mt_rand(-20, 20);
         $x = 5 + $fontSize * $i;
         $y = 20;
         imagettftext($image, $fontSize, $angle, $x, $y, $foreColor, $this->fontFile, $code[$i]);
         imageline($image, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $foreColor);
     }
     imagecolordeallocate($image, $foreColor);
     header('Pragma: public');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Content-Transfer-Encoding: binary');
     header("Content-type: image/png");
     imagepng($image);
     imagedestroy($image);
 }
开发者ID:jackycgq,项目名称:24beta,代码行数:34,代码来源:CdCaptchaAction.php

示例5: color

 static function color($res, $color = 'ffffff', $del = false)
 {
     $cr = str_split($color, strlen($color) > 4 ? 2 : 1);
     $color = imagecolorallocate($res, hexdec($cr[0]), hexdec($cr[1]), hexdec($cr[2]));
     if ($del) {
         imagecolordeallocate($res, $color);
     }
     return $color;
 }
开发者ID:art-youth,项目名称:framework,代码行数:9,代码来源:img.php

示例6: render

 /**
  * render module icon.
  *
  * @param string $fpath        base image file
  * @param string $dirname
  * @param string $trustDirname
  */
 public static function render($fpath, $dirname, $trustDirname)
 {
     self::_prepare();
     if (!file_exists($fpath)) {
         self::_error404();
     }
     $im = @imagecreatefrompng($fpath);
     if ($im === false) {
         self::_error404();
     }
     $mw = 79;
     // maximum width of drawing area
     $ox = 47;
     // offset X
     $oy = 12;
     // offset Y (if same directory name)
     $oy_d = 8;
     // offset Y for $dirname
     $oy_t = 19;
     // offset Y for $trustDirname
     $isSameDirname = $dirname == $trustDirname;
     imagealphablending($im, true);
     $color_d = imagecolorallocate($im, 0, 0, 0);
     $color_t = imagecolorallocate($im, 0xa0, 0xa0, 0xa0);
     // write dirname
     $cw = self::_getStringWidth($dirname);
     while ($cw > $mw) {
         // trim string if over length
         $dirname = substr($dirname, 0, -1);
         $cw = self::_getStringWidth($dirname);
     }
     $x = $ox + ($mw - $cw) / 2;
     $y = $isSameDirname ? $oy : $oy_d;
     self::_writeString($im, $x, $y, $dirname, $color_d);
     if (!$isSameDirname) {
         // write trust dirname if different
         $cw = self::_getStringWidth($trustDirname);
         while ($cw > $mw) {
             // trim string if over length
             $dirname = substr($trustDirname, 0, -1);
             $cw = self::_getStringWidth($dirname);
         }
         $x = $ox + ($mw - $cw) / 2;
         $y = $oy_t;
         self::_writeString($im, $x, $y, $trustDirname, $color_t);
     }
     self::_showImage($im);
     imagecolordeallocate($im, $color_d);
     imagecolordeallocate($im, $color_t);
     imagedestroy($im);
     self::_cleanup();
 }
开发者ID:neuroinformatics,项目名称:xcl-module-cosmoapi,代码行数:59,代码来源:ModuleIcon.class.php

示例7: imagecopymerge_alpha

		private function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct, $trans = NULL){
			$dst_w = imagesx($dst_im);
			$dst_h = imagesy($dst_im);

			// bounds checking
			$src_x = max($src_x, 0);
			$src_y = max($src_y, 0);
			$dst_x = max($dst_x, 0);
			$dst_y = max($dst_y, 0);
			if ($dst_x + $src_w > $dst_w){
				$src_w = $dst_w - $dst_x;
			}
			
			if ($dst_y + $src_h > $dst_h){
				$src_h = $dst_h - $dst_y;
			}

			for($x_offset = 0; $x_offset < $src_w; $x_offset++){
				for($y_offset = 0; $y_offset < $src_h; $y_offset++){
					// get source & dest color
					$srccolor = imagecolorsforindex($src_im, imagecolorat($src_im, $src_x + $x_offset, $src_y + $y_offset));
					$dstcolor = imagecolorsforindex($dst_im, imagecolorat($dst_im, $dst_x + $x_offset, $dst_y + $y_offset));

					// apply transparency
					if (is_null($trans) || ($srccolor !== $trans)){
						$src_a = $srccolor['alpha'] * $pct / 100;
						// blend
						$src_a = 127 - $src_a;
						$dst_a = 127 - $dstcolor['alpha'];
						$dst_r = ($srccolor['red'] * $src_a + $dstcolor['red'] * $dst_a * (127 - $src_a) / 127) / 127;
						$dst_g = ($srccolor['green'] * $src_a + $dstcolor['green'] * $dst_a * (127 - $src_a) / 127) / 127;
						$dst_b = ($srccolor['blue'] * $src_a + $dstcolor['blue'] * $dst_a * (127 - $src_a) / 127) / 127;
						$dst_a = 127 - ($src_a + $dst_a * (127 - $src_a) / 127);
						$color = imagecolorallocatealpha($dst_im, $dst_r, $dst_g, $dst_b, $dst_a);
						// paint
						if (!imagesetpixel($dst_im, $dst_x + $x_offset, $dst_y + $y_offset, $color)){
							return false;
						}
						imagecolordeallocate($dst_im, $color);
					}
				}
			}
			return true;
		}
开发者ID:rockerest,项目名称:vertebrox,代码行数:44,代码来源:ImageCombine.php

示例8: showImage

 function showImage()
 {
     $image = imagecreatetruecolor($this->width, $this->height);
     $backColor = imagecolorallocate($image, (int) ($this->backColor % 0x1000000 / 0x10000), (int) ($this->backColor % 0x10000 / 0x100), $this->backColor % 0x100);
     imagefilledrectangle($image, 0, 0, $this->width, $this->height, $backColor);
     imagecolordeallocate($image, $backColor);
     imagecolortransparent($image, $backColor);
     $text_color = imagecolorallocate($image, $this->text_color[0], $this->text_color[1], $this->text_color[2]);
     $fontFile = dirname(__FILE__) . '/fonts/Duality.ttf';
     $length = strlen($this->code);
     $box = imagettfbbox(30, 0, $fontFile, $this->code);
     $w = $box[4] - $box[0] + $this->offset * ($length - 1);
     $h = $box[1] - $box[5];
     $scale = min(($this->width - $this->padding * 2) / $w, ($this->height - $this->padding * 2) / $h);
     $x = 10;
     $y = round($this->height * 27 / 33);
     for ($i = 0; $i < $length; ++$i) {
         $fontSize = (int) (rand(26, 35) * $scale * 0.8);
         $angle = rand(-20, 30);
         $letter = $this->code[$i];
         $o = rand(-2, 2);
         $box = imagettftext($image, $fontSize, $angle, $x, $y, $text_color, $fontFile, $letter);
         $x = $box[2] + $o;
     }
     if ($this->showLine) {
         $line_color = imagecolorallocate($image, $this->line_color[0], $this->line_color[1], $this->line_color[2]);
         for ($i = 0; $i < rand(4, 8); $i++) {
             imageline($image, 1, rand(1, 50), rand(150, 180), rand(1, 50), $line_color);
         }
     }
     header('Pragma: public');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Content-Transfer-Encoding: binary');
     header("Content-type: image/png");
     imagepng($image);
     imagedestroy($image);
 }
开发者ID:SwayWebStudio,项目名称:night.com,代码行数:38,代码来源:class.captcha.php

示例9: renderImageByGD

 /**
  * Renders the CAPTCHA image based on the code using GD library.
  * @param string $code the verification code
  * @return string image contents in PNG format.
  */
 protected function renderImageByGD($code)
 {
     $image = imagecreatetruecolor($this->width, $this->height);
     $backColor = imagecolorallocate($image, (int) ($this->backColor % 0x1000000 / 0x10000), (int) ($this->backColor % 0x10000 / 0x100), $this->backColor % 0x100);
     imagefilledrectangle($image, 0, 0, $this->width, $this->height, $backColor);
     imagecolordeallocate($image, $backColor);
     if ($this->transparent) {
         imagecolortransparent($image, $backColor);
     }
     $foreColor = imagecolorallocate($image, (int) ($this->foreColor % 0x1000000 / 0x10000), (int) ($this->foreColor % 0x10000 / 0x100), $this->foreColor % 0x100);
     $length = strlen($code);
     $box = imagettfbbox(30, 0, $this->fontFile, $code);
     $w = $box[4] - $box[0] + $this->offset * ($length - 1);
     $h = $box[1] - $box[5];
     $scale = min(($this->width - $this->padding * 2) / $w, ($this->height - $this->padding * 2) / $h);
     $x = 10;
     $y = round($this->height * 27 / 40);
     for ($i = 0; $i < $length; ++$i) {
         $fontSize = (int) (rand(26, 32) * $scale * 0.8);
         $angle = rand(-10, 10);
         $letter = $code[$i];
         $box = imagettftext($image, $fontSize, $angle, $x, $y, $foreColor, $this->fontFile, $letter);
         $x = $box[2] + $this->offset;
     }
     imagecolordeallocate($image, $foreColor);
     ob_start();
     imagepng($image);
     imagedestroy($image);
     return ob_get_clean();
 }
开发者ID:uxff,项目名称:yii2-advanced,代码行数:35,代码来源:CaptchaAction.php

示例10: renderImage

 /**
  * muestra la imagen CAPTCHA basada en el codigo.
  * @param string el código de verificación
  * @return string contenido imagen
  */
 protected function renderImage($code)
 {
     $image = imagecreatetruecolor($this->width, $this->height);
     $backColor = imagecolorallocate($image, (int) ($this->backColor % 0x1000000 / 0x10000), (int) ($this->backColor % 0x10000 / 0x100), $this->backColor % 0x100);
     imagefilledrectangle($image, 0, 0, $this->width, $this->height, $backColor);
     imagecolordeallocate($image, $backColor);
     $foreColor = imagecolorallocate($image, (int) ($this->foreColor % 0x1000000 / 0x10000), (int) ($this->foreColor % 0x10000 / 0x100), $this->foreColor % 0x100);
     if ($this->fontFile === null) {
         $this->fontFile = CAPTCHA_VENDOR_DIR . 'Duality.ttf';
     }
     $offset = 2;
     $length = strlen($code);
     $box = imagettfbbox(30, 0, $this->fontFile, $code);
     $w = $box[4] - $box[0] - $offset * ($length - 1);
     $h = $box[1] - $box[5];
     $scale = min(($this->width - $this->padding * 2) / $w, ($this->height - $this->padding * 2) / $h);
     $x = 10;
     $y = round($this->height * 27 / 40);
     for ($i = 0; $i < $length; ++$i) {
         $fontSize = (int) (rand(26, 32) * $scale * 0.8);
         $angle = rand(-10, 10);
         $letter = $code[$i];
         $box = imagettftext($image, $fontSize, $angle, $x, $y, $foreColor, $this->fontFile, $letter);
         $x = $box[2] - $offset;
     }
     imagecolordeallocate($image, $foreColor);
     header('Pragma: public');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Content-Transfer-Encoding: binary');
     header("Content-type: image/png");
     imagepng($image);
     imagedestroy($image);
 }
开发者ID:al3jandro,项目名称:Tellus,代码行数:39,代码来源:captcha.php

示例11: round

            if ($type == 'date') {
                $process[$country . '(' . $quantity . ' click)'] = $quantity;
            } else {
                $process[$country . '(' . round(intval($quantity) * 100 / $total, 2) . '%)'] = round(intval($quantity) * 100 / $total, 2);
            }
        }
        # google chart intergrated :|
        $imagechart = 'http://chart.apis.google.com/chart?chs=700x350&cht=p3&chco=7777CC|76A4FB|3399CC|3366CC|000000|7D5F5F|A94A4A|13E9E9|526767|DBD6D6&chd=t:';
        $imagechart .= implode(',', array_values($process));
        $imagechart .= '&chl=';
        $imagechart .= implode('|', array_keys($process));
        $imagechart .= '&chtt=Banner Stats';
        $imagechart = str_replace(' ', '%20', $imagechart);
        header("Content-type: image/png");
        echo $geturl->get($imagechart);
    } else {
        $my_img = imagecreate(700, 80);
        $background = imagecolorallocate($my_img, 255, 255, 255);
        $text_colour = imagecolorallocate($my_img, 0, 0, 0);
        $line_colour = imagecolorallocate($my_img, 128, 255, 0);
        imagestring($my_img, 4, 30, 25, "no data", $text_colour);
        imagesetthickness($my_img, 5);
        imageline($my_img, 30, 45, 165, 45, $line_colour);
        header("Content-type: image/png");
        imagepng($my_img);
        imagecolordeallocate($line_color);
        imagecolordeallocate($text_color);
        imagecolordeallocate($background);
        imagedestroy($my_img);
    }
}
开发者ID:anhtunguyen,项目名称:vietnamguide,代码行数:31,代码来源:viewmap.php

示例12: Create


//.........这里部分代码省略.........
         $thumb_img = imagecreatetruecolor($resize_width, $resize_height);
         if (!imagecopyresampled($thumb_img, $this->img, 0, 0, 0, 0, $resize_width, $resize_height, $width, $height)) {
             return $this->ShowError("Error: Could not resize image!");
         }
         // fix these
         $height = $resize_height;
         $width = $resize_width;
         // destroy original object
         imagedestroy($this->img);
         $this->img = $thumb_img;
     }
     // allocate colors for text
     if ($text_color === -1) {
         $text_color = imagecolorallocate($this->img, 255, 255, 255);
     } else {
         $text_color = imagecolorallocate($this->img, $text_color[0], $text_color[1], $text_color[2]);
     }
     // allocate colors for text shadow
     if ($shadow_color === -1) {
         $shadow_color = imagecolorallocate($this->img, 0, 0, 0);
     } else {
         $shadow_color = imagecolorallocate($this->img, $shadow_color[0], $shadow_color[1], $shadow_color[2]);
     }
     // next, we should try to create the text.. hopefully it wraps nicely
     putenv('GDFONTPATH=' . realpath('.'));
     // hack, just in case
     // grab the font height, M is supposed to be big, with any random chars lying around
     $font_height = $this->img_height(imagettfbbox($fontsize, 0, $font, 'Mjg'));
     $row_spacing = intval($font_height * 0.2);
     // purely arbitrary value
     $space_width = $this->img_width(imagettfbbox($fontsize, 0, $font, ' '));
     // try and do our best imitation of wordwrapping
     $text_elements = explode(' ', str_replace("\n", '', str_replace("\r\n", '', $text)));
     // adjust this depending on alignment
     $top = $padding + $font_height;
     $left = $padding;
     // initialize
     $line_width = 0;
     $line_beginning = 0;
     // index of beginning of line
     $inc = 1;
     $c = count($text_elements);
     $i = 0;
     if ($align[0] == 'b') {
         $top = $height - $padding;
         $font_height = $font_height * -1;
         $row_spacing = $row_spacing * -1;
         $inc = -1;
         $i = $c - 1;
     }
     $dbg = get_get_var('dbg');
     $line_beginning = $i;
     // draw text elements starting from alignment position..
     for (; $i >= 0 && $i < $c; $i += $inc) {
         $lf_width = $this->img_width(imagettfbbox($fontsize, 0, $font, $text_elements[$i]));
         // add a space
         if ($i != $line_beginning) {
             $lf_width += $space_width;
         }
         // see if we've exceeded the max width
         if ($lf_width + $line_width + $padding * 2 > $width) {
             // draw it out then!
             if ($align[1] == 'r') {
                 $left = $width - $padding - $line_width;
             }
             if ($align[0] == 'b') {
                 $text = implode(' ', array_slice($text_elements, $i + 1, $line_beginning - $i));
             } else {
                 $text = implode(' ', array_slice($text_elements, $line_beginning, $i - $line_beginning));
             }
             // draw the text
             imagettftext($this->img, $fontsize, 0, $left - 1, $top + 1, $shadow_color, $font, $text);
             imagettftext($this->img, $fontsize, 0, $left, $top, $text_color, $font, $text);
             // keep moving, reset params
             $top += $font_height + $row_spacing;
             $line_beginning = $i;
             $line_width = $lf_width;
         } else {
             // keep trucking
             $line_width += $lf_width;
         }
     }
     // get the last line too
     if ($line_width != 0) {
         if ($align[1] == 'r') {
             $left = $width - $padding - $line_width;
         }
         if ($align[0] == 'b') {
             $text = implode(' ', array_slice($text_elements, $i + 1, $line_beginning - $i));
         } else {
             $text = implode(' ', array_slice($text_elements, $line_beginning, $i - $line_beginning));
         }
         imagettftext($this->img, $fontsize, 0, $left - 1, $top + 1, $shadow_color, $font, $text);
         imagettftext($this->img, $fontsize, 0, $left, $top, $text_color, $font, $text);
     }
     imagecolordeallocate($this->img, $shadow_color);
     imagecolordeallocate($this->img, $text_color);
     restore_error_handler();
     return true;
 }
开发者ID:GerryG,项目名称:newz,代码行数:101,代码来源:lolcats.inc.php

示例13: GenerateLegend

function GenerateLegend()
{
    global $sessionID, $mapName, $width, $height, $offsetX, $offsetY, $xPad, $yPad, $iconWidth, $iconHeight, $xIndent, $groupIcon, $fontIndex, $textColor;
    $userInfo = new MgUserInformation($sessionID);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
    $mappingService = $siteConnection->CreateService(MgServiceType::MappingService);
    $map = new MgMap();
    $map->Open($resourceService, $mapName);
    $scale = $map->GetViewScale();
    CompileVisibleLayerCount($map);
    $image = imagecreatetruecolor($width, $height);
    $white = imagecolorallocate($image, 255, 255, 255);
    $textColor = imagecolorallocate($image, 0, 0, 0);
    imagefilledrectangle($image, 0, 0, $width, $height, $white);
    //Uncomment regions marked with BEGIN DEBUG / END DEBUG and comment out regions marked with
    //BEGIN COMMENT OUT IF DEBUGGING / END COMMENT OUT IF DEBUGGING to see what PHP-isms get spewed out
    //that may be tripping up rendering
    //
    //Also replace instances of "////print_r" with "//print_r" to insta-uncomment all debugging calls
    //==BEGIN DEBUG==
    //header("Content-type: text/html", true);
    //==END DEBUG==
    ProcessGroupsForLegend($mappingService, $resourceService, $map, $scale, NULL, $image);
    //==BEGIN COMMENT OUT IF DEBUGGING==
    header("Content-type: image/png");
    imagepng($image);
    //==END COMMENT OUT IF DEBUGGING==
    //==BEGIN DEBUG==
    /*
    ob_start();
    imagepng($image);
    $im = base64_encode(ob_get_contents());
    ob_end_clean();
    echo "<img src='data:image/png;base64,".$im."' alt='legend image'></img>";
    */
    //==END DEBUG==
    imagecolordeallocate($image, $white);
    imagecolordeallocate($image, $textColor);
    imagedestroy($image);
}
开发者ID:kanbang,项目名称:Colt,代码行数:42,代码来源:GenerateLegend.php

示例14: update_media

 function update_media($media)
 {
     parent::update_media($media);
     /**
      * Here we use a small hack; media height and width (in millimetres) match
      * the size of screenshot (in pixels), so we take them as-is
      */
     $this->_heightPixels = $media->height();
     $this->_widthPixels = $media->width();
     $this->_image = imagecreatetruecolor($this->_widthPixels, $this->_heightPixels);
     /**
      * Render white background
      */
     $white = imagecolorallocate($this->_image, 255, 255, 255);
     imagefill($this->_image, 0, 0, $white);
     imagecolordeallocate($this->_image, $white);
     $this->_color[0] = array('rgb' => array(0, 0, 0), 'object' => imagecolorallocate($this->_image, 0, 0, 0));
     /**
      * Setup initial clipping region
      */
     $this->_clipping = array();
     $this->_saveClip(new Rectangle(new Point(0, 0), new Point($this->_widthPixels - 1, $this->_heightPixels - 1)));
     $this->_transform = new AffineTransform($this->_heightPixels, $this->_widthPixels / mm2pt($this->media->width()), $this->_heightPixels / mm2pt($this->media->height()));
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:24,代码来源:output.png.class.php

示例15: CenterSquarify

 /**
  * Crops the image to the biggest fitting, centered square 
  * 
  */
 function CenterSquarify(ArgbColor $backgroundColor = null)
 {
     $width = $this->Width();
     $height = $this->Height();
     $squareSize = min($width, $height);
     $xOrigin = 0;
     $yOrigin = 0;
     if ($width > $squareSize) {
         $xOrigin = round(($width - $squareSize) / 2);
     } else {
         if ($height > $squareSize) {
             $yOrigin = round(($height - $squareSize) / 2);
         }
     }
     $destRes = \imagecreatetruecolor($squareSize, $squareSize);
     if ($backgroundColor) {
         $colRes = \imagecolorallocate($destRes, $backgroundColor->GetRed(), $backgroundColor->GetGreen(), $backgroundColor->GetBlue());
         \imagefill($destRes, 0, 0, $colRes);
         \imagecolordeallocate($destRes, $colRes);
     }
     \imagecopy($destRes, $this->resource, 0, 0, $xOrigin, $yOrigin, $squareSize, $squareSize);
     $this->AssignResource($destRes);
 }
开发者ID:agentmedia,项目名称:phine-framework,代码行数:27,代码来源:Image.php


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