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


PHP Canvas::getImage方法代码示例

本文整理汇总了PHP中Canvas::getImage方法的典型用法代码示例。如果您正苦于以下问题:PHP Canvas::getImage方法的具体用法?PHP Canvas::getImage怎么用?PHP Canvas::getImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Canvas的用法示例。


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

示例1: draw

 function draw(Canvas $dest, $x = null, $y = null, $width = null, $height = null)
 {
     $image = new Canvas($width, $height);
     $p = $image->getPainter();
     if (!$x) {
         $x = 0;
     }
     if (!$y) {
         $y = 0;
     }
     if (!$width) {
         $width = $dest->width;
     }
     if (!$height) {
         $height = $dest->height;
     }
     if ($width && $height) {
         $grad = $height;
         // Top down
         $this->colors['step'] = array((double) ($this->colors['delta'][0] / $grad), (double) ($this->colors['delta'][1] / $grad), (double) ($this->colors['delta'][2] / $grad));
         $w = $width;
         for ($n = 0; $n < $grad; $n++) {
             $c = new RgbColor(floor($this->colors['first'][0] + $this->colors['step'][0] * $n), floor($this->colors['first'][1] + $this->colors['step'][1] * $n), floor($this->colors['first'][2] + $this->colors['step'][2] * $n));
             // Console::debug("Row %d: rgb(%d,%d,%d)", $n, $c->r, $c->g, $c->b);
             $p->drawLine(0, $n, $w, $n, $c);
         }
         imagecopy($dest->getImage(), $image->getImage(), $x, $y, 0, 0, $width, $height);
     } else {
         throw new BadArgumentException();
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:31,代码来源:gradient.php

示例2: applyFilter

 function applyFilter(Canvas $canvas)
 {
     $himage = $canvas->getImage();
     if (function_exists('imagefilter')) {
         // If gd is bundled this will work
         imagefilter($himage, IMG_FILTER_GRAYSCALE);
     } else {
         // If not we need to do some enumeration
         $total = imagecolorstotal($himage);
         if ($total > 0) {
             // This works for indexed images but not for truecolor
             for ($i = 0; $i < $total; $i++) {
                 $index = imagecolorsforindex($himage, $i);
                 $avg = ($index["red"] + $index["green"] + $index["blue"]) / 3;
                 $red = $avg;
                 $green = $avg;
                 $blue = $avg;
                 imagecolorset($himage, $i, $red, $green, $blue);
             }
         } else {
             // For truecolor we need to enum it all
             for ($x = 0; $x < imagesx($himage); $x++) {
                 for ($y = 0; $y < imagesy($himage); $y++) {
                     $index = imagecolorat($himage, $x, $y);
                     $avg = (($index & 0xff) + ($index >> 8 & 0xff) + ($index >> 16 & 0xff)) / 3;
                     imagesetpixel($himage, $x, $y, $avg | $avg << 8 | $avg << 16);
                 }
             }
         }
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:31,代码来源:grayscale.php

示例3: applyFilter

 function applyFilter(Canvas $canvas)
 {
     $himage = $canvas->getImage();
     // If not we need to do some enumeration
     $total = imagecolorstotal($himage);
     if ($total > 0) {
         // This works for indexed images but not for truecolor
         for ($i = 0; $i < $total; $i++) {
             $index = imagecolorsforindex($himage, $i);
             $rgb = rgb($index['red'], $index['green'], $index['blue']);
             $hsv = hsv($rgb);
             $hsv->hue = $this->hue;
             $rgb = rgb($hsv);
             $red = $rgb->red;
             $green = $rgb->green;
             $blue = $rgb->blue;
             imagecolorset($himage, $i, $red, $green, $blue);
         }
     } else {
         // For truecolor we need to enum it all
         for ($x = 0; $x < imagesx($himage); $x++) {
             for ($y = 0; $y < imagesy($himage); $y++) {
                 $index = imagecolorat($himage, $x, $y);
                 $rgb = rgb($index['red'], $index['green'], $index['blue'], $index['alpha']);
                 $hsv = hsv($rgb);
                 $hsv->hue = $this->hue;
                 $rgb = rgb($hsv);
                 $red = $rgb->red;
                 $green = $rgb->green;
                 $blue = $rgb->blue;
                 imagesetpixel($himage, $x, $y, $red << 16 | $green < 8 | $blue);
             }
         }
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:35,代码来源:hue.php

示例4: applyFilter

 function applyFilter(Canvas $canvas)
 {
     $himage = $canvas->getImage();
     $m = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0));
     $div = 16;
     $offs = 0;
     ImageUtils::imageconvolution($himage, $m, $div, $offs);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:8,代码来源:blur.php

示例5: applyFilter

 function applyFilter(Canvas $canvas)
 {
     $himage = $canvas->getImage();
     if (function_exists('imagefilter') && defined('IMG_FILTER_COLORIZE')) {
         // If gd is bundled this will work
         imagefilter($himage, IMG_FILTER_COLORIZE, $this->r, $this->g, $this->b);
     } else {
         throw new FunctionNotSupportedException("Colorize not supported by this version of GD");
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:10,代码来源:colorize.php

示例6: applyFilter

 function applyFilter(Canvas $canvas)
 {
     $himage = $canvas->getImage();
     if ($this->usegdfilter) {
         if (!imagefilter($himage, IMG_FILTER_PIXELATE, $this->pixelsize, $this->advanced)) {
             throw new GraphicsException("Failed to apply filter");
         }
     } else {
         // TODO: Implement our own pixelation filter
     }
     $canvas->setImage($himage);
     return null;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:13,代码来源:pixelize.php

示例7: draw

 function draw(Canvas $dest, $x = null, $y = null, $width = null, $height = null)
 {
     $c = new Canvas($width, $height, rgb($this->props['background']));
     $p = $c->getPainter();
     $p->drawRect(0, 0, $width - 1, $height - 1, rgb($this->props['bordercolor']));
     $labels = $this->dataset->getLabels();
     $labelcount = count($labels);
     // $ls = floor($height / $labelcount) - 4;
     $ls = 16;
     for ($i = 0; $i < $labelcount; $i++) {
         $x1 = 3;
         $y1 = 3 + ($ls + 2) * $i;
         $x2 = $x1 + $ls;
         $y2 = $y1 + $ls;
         $p->drawFilledRect($x1, $y1, $x2, $y2, rgb(80, 80, 80), rgb(rand(0, 200), rand(0, 200), rand(0, 200)));
     }
     imagecopy($dest->getImage(), $c->getImage(), $x, $y, 0, 0, $width, $height);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:18,代码来源:legend.php

示例8: applyFilter

 function applyFilter(Canvas $canvas)
 {
     $himage = $canvas->getImage();
     $iw = imagesx($himage);
     $ih = imagesy($himage);
     switch ($this->placement) {
         case WatermarkImageFilter::POS_RELATIVE:
             $dx = $this->x >= 0 ? $this->x : $iw - $this->width + $this->x + 1;
             $dy = $this->y >= 0 ? $this->y : $ih - $this->height + $this->y + 1;
             break;
         case WatermarkImageFilter::POS_ABSOLUTE:
             $dx = $this->x;
             $dy = $this->y;
             break;
         case WatermarkImageFilter::POS_CENTERED:
             $dx = $iw / 2 + $this->x;
             $dy = $ih / 2 + $this->y;
             break;
     }
     imagecopymerge_alpha($himage, $this->hwatermark, $dx, $dy, 0, 0, $this->width, $this->height, 0);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:21,代码来源:watermark.php

示例9: applyFilter

 function applyFilter(Canvas $canvas)
 {
     $himage = $canvas->getImage();
     $rheight = $this->_os->get('reflectionheight', 25);
     $iheight = imagesy($himage);
     $iwidth = imagesx($himage);
     if ($this->_os->get('resizecanvas', false)) {
         // create new canvas of iheight+rheight, set offset to
         // iheight
         $offs = $iheight;
         $hreflect = imagecreatetruecolor($iwidth, $iheight + $rheight);
     } else {
         // create new canvas of iheight, set offset to iheight to
         // iheight-rheight
         $offs = $iheight - $rheight;
         $hreflect = imagecreatetruecolor($iwidth, $iheight);
     }
     if ($this->_os->get('background', null)) {
         // Fill with background if specified, note that this disables
         // the alpha saving
         imagefilledrectangle($hreflect, 0, 0, imagesx($hreflect), imagesy($hreflect), new Color($this->_os->get('background')));
     } else {
         // Disable alphablending and enable saving of the alpha channel
         imagealphablending($hreflect, false);
         imagesavealpha($hreflect, true);
     }
     imagecopy($hreflect, $himage, 0, 0, 0, 0, $iwidth, $iheight);
     $as = 80 / $rheight;
     $sc = $this->_os->get('scale', 2);
     for ($y = 1; $y <= $rheight; $y++) {
         for ($x = 0; $x < $iwidth; $x++) {
             $rgba = imagecolorat($himage, $x, $offs - $y * $sc);
             $alpha = max($rgba >> 24 & 0x7f, 47 + $y * $as);
             $rgba = imagecolorallocatealpha($hreflect, $rgba >> 16 & 0xff, $rgba >> 8 & 0xff, $rgba & 0xff, $alpha);
             imagesetpixel($hreflect, $x, $offs + $y - 1, $rgba);
         }
     }
     return $hreflect;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:39,代码来源:reflection.php

示例10: draw

 function draw(Canvas $dest, $x = null, $y = null, $width = null, $height = null)
 {
     $hi = $dest->getImage();
     $str = '*' . $this->_text . '*';
     if ($x && $y && $width && $height) {
         // Each character is 12 units wide, so let's figure out how wide
         // we should make the output. We add 2 for the padding.
         $outwidth = strlen($str) * 14;
         $unitwidth = (int) ($width / $outwidth);
         $rx = 0;
         for ($i = 0; $i < strlen($str); $i++) {
             $charbin = $this->getCharacter($str[$i]);
             for ($j = 0; $j < 9; $j++) {
                 $bw = $charbin[$j] == '1' ? 1 : 0;
                 imagefilledrectangle($hi, $x + $rx * $unitwidth, $y, $x + ($rx + $bw + 1) * $unitwidth, $y + $height, $j % 2 ? 0xffffff : 0x0);
                 $rx = $rx + 2 + $bw;
             }
             $rx = $rx + 2;
         }
     } else {
         new BadArgumentException();
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:23,代码来源:code39.php

示例11: drawText

 function drawText(Canvas $canvas, $x, $y, $color, $text)
 {
     $himage = $canvas->getImage();
     if ($this->effect == BitmapFont::EFFECT_OUTLINE) {
         $ow = 1;
         for ($xx = $x - $ow; $xx <= $x + $ow; $xx++) {
             for ($yy = $y - $ow; $yy <= $y + $ow; $yy++) {
                 imagestring($himage, $this->font, $xx, $yy, $text, $this->options->getColor($himage));
             }
         }
     } elseif ($this->effect == BitmapFont::EFFECT_SHADOW) {
         $ow = 1;
         for ($z = 0; $z <= $ow; $z++) {
             imagestring($himage, $this->font, $x + $z, $y + $z, $text, $this->options->getColor($himage));
         }
     } elseif ($this->effect == BitmapFont::EFFECT_BOLD) {
         imagestring($himage, $this->font, $x + 1, $y, $text, $color->getColor($himage));
     }
     imagestring($himage, $this->font, $x, $y, $text, $color->getColor($himage));
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:20,代码来源:font.php

示例12: draw

 /**
  * @brief Draw the canvas onto another canvas.
  *
  * @param Canvas $dest The destination canvas
  * @param integer $x The left coordinate of the destination canvas
  * @param integer $y The top coordinate of the destination canvas
  * @param integer $width The width of the drawing
  * @param integer $height The height of the drawing
  */
 function draw(Canvas $dest, $x = null, $y = null, $width = null, $height = null, $alpha = false)
 {
     $this->checkMeta();
     $dstimage = $dest->getImage();
     if (!$x) {
         $x = 0;
     }
     if (!$y) {
         $y = 0;
     }
     if (!$width) {
         $width = $this->width;
     }
     if (!$height) {
         $height = $this->height;
     }
     if (!$alpha) {
         imagecopy($dstimage, $this->himage, $x, $y, 0, 0, $width, $height);
     } else {
         imagecopymerge_alpha($dstimage, $this->himage, $x, $y, 0, 0, $width, $height, 0);
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:31,代码来源:canvas.php

示例13:

 function __construct(Canvas $canvas)
 {
     $this->himage = $canvas->getImage();
     $this->canvas = $canvas;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:5,代码来源:canvaspainter.php

示例14: applyFilter

 function applyFilter(Canvas $canvas)
 {
     $himage = $canvas->getImage();
     ImageUtils::imageconvolution($himage, $this->matrix, $this->div, $this->offset);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:5,代码来源:convolution.php


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