Example #1
0
 public function Stroke($aFileName = '')
 {
     // Find out the necessary size for the container image
     $w = 0;
     $h = 0;
     for ($i = 0; $i < $this->iCnt; ++$i) {
         $maxw = $this->iGraphs[$i][1] + $this->iGraphs[$i][5];
         $maxh = $this->iGraphs[$i][2] + $this->iGraphs[$i][6];
         $w = max($w, $maxw);
         $h = max($h, $maxh);
     }
     $w += $this->lm + $this->rm;
     $h += $this->tm + $this->bm;
     // User specified width,height overrides
     if ($this->iWidth !== null && $this->iWidth !== 0) {
         $w = $this->iWidth;
     }
     if ($this->iHeight !== null && $this->iHeight !== 0) {
         $h = $this->iHeight;
     }
     if ($this->doshadow) {
         $w += $this->shadow_width;
         $h += $this->shadow_width;
     }
     $image = new Image\Image($w, $h);
     $image->SetImgFormat($this->image_format, $this->image_quality);
     if ($this->doshadow) {
         $image->SetColor($this->iFrameColor);
         $image->ShadowRectangle(0, 0, $w - 1, $h - 1, $this->iFillColor, $this->shadow_width, $this->shadow_color);
         $w -= $this->shadow_width;
         $h -= $this->shadow_width;
     } else {
         $image->SetColor($this->iFillColor);
         $image->FilledRectangle(0, 0, $w - 1, $h - 1);
     }
     $image->SetExpired($this->expired);
     $this->img = $image->img;
     $this->_strokeBackgroundImage();
     if ($this->iDoFrame && !$this->doshadow) {
         $image->SetColor($this->iFrameColor);
         $image->SetLineWeight($this->iFrameWeight);
         $image->Rectangle(0, 0, $w - 1, $h - 1);
     }
     // Copy all sub graphs to the container
     for ($i = 0; $i < $this->iCnt; ++$i) {
         $image->CopyMerge($this->iGraphs[$i][0], $this->iGraphs[$i][1] + $this->lm, $this->iGraphs[$i][2] + $this->tm, $this->iGraphs[$i][3], $this->iGraphs[$i][4], $this->iGraphs[$i][5], $this->iGraphs[$i][6], -1, -1, $this->iGraphs[$i][7]);
     }
     $this->StrokeTitle($image, $w, $h);
     $this->footer->Stroke($image);
     // Output image
     if ($aFileName == _IMG_HANDLER) {
         return $image->img;
     } else {
         //Finally stream the generated picture
         $this->cache = new ImgStreamCache();
         $this->cache->PutAndStream($image, $this->cache_name, $this->inline, $aFileName);
     }
 }
Example #2
0
 public function StrokeNumber($aValStr, $aColor = 0, $aFileName = '')
 {
     if ($aColor < 0 || $aColor >= sizeof($this->iColorSchema)) {
         $aColor = 0;
     }
     if (($n = mb_strlen($aValStr, 'utf8')) == 0) {
         $aValStr = ' ';
         $n = 1;
     }
     for ($i = 0; $i < $n; ++$i) {
         $d = mb_substr($aValStr, $i, 1, 'utf8');
         if (ctype_digit($d)) {
             $d = (int) $d;
         } else {
             $d = strtoupper($d);
         }
         $digit_img[$i] = $this->_GetLED($d, $aColor);
     }
     $w = imagesx($digit_img[0]->img);
     $h = imagesy($digit_img[0]->img);
     $number_img = new Image\Image($w * $n, $h, DEFAULT_GFORMAT, false);
     for ($i = 0; $i < $n; ++$i) {
         $number_img->Copy($digit_img[$i]->img, $i * $w, 0, 0, 0, $w, $h, $w, $h);
     }
     if ($aFileName != '') {
         $number_img->Stream($aFileName);
     } else {
         $number_img->Headers();
         $number_img->Stream();
     }
 }