Пример #1
0
    /**
     * (non-PHPdoc)
     * @see Imagine\Draw\DrawerInterface::dot()
     */
    public function dot(PointInterface $position, Color $color)
    {
        $x = $position->getX();
        $y = $position->getY();

        try {
            $pixel = $this->getColor($color);
            $point = new \GmagickDraw();

            $point->setfillcolor($pixel);
            $point->point($x, $y);

            $this->gmagick->drawimage($point);

            $pixel = null;

            $point = null;
        } catch (\GmagickException $e) {
            throw new RuntimeException(
                'Draw point operation failed', $e->getCode(), $e
            );
        }

        return $this;
    }
Пример #2
0
    /**
     * (non-PHPdoc)
     * @see Imagine\Image\ManipulatorInterface::fill()
     */
    public function fill(FillInterface $fill)
    {
        try {
            $draw = new \GmagickDraw();
            $size = $this->getSize();

            for ($x = 0; $x <= $size->getWidth(); $x++) {
                for ($y = 0; $y <= $size->getHeight(); $y++) {
                    $pixel = $this->getColor($fill->getColor(new Point($x, $y)));

                    $draw->setfillcolor($pixel);
                    $draw->point($x, $y);

                    $pixel = null;
                }
            }

            $this->gmagick->drawimage($draw);

            $draw = null;
        } catch (\GmagickException $e) {
            throw new RuntimeException(
                'Fill operation failed', $e->getCode(), $e
            );
        }

        return $this;
    }
Пример #3
0
 function out()
 {
     if (self::DEBUG) {
         echo __FUNCTION__ . "\n";
     }
     $image = new \Gmagick();
     $image->newimage($this->width, $this->height);
     $image->drawimage($this->canvas);
     $tmp = tempnam("", "gm");
     $image->write($tmp);
     return file_get_contents($tmp);
 }
 private function drawRectangleAndReplaceExistImg($image, $height, $width)
 {
     // прямоугольник рисуем снизу изображения высотой 8% от высоты изображения
     $heightRectagle = $height * 0.08;
     $gmagicDraw = new GmagickDraw();
     $gmagicDraw->setfillcolor("#fff");
     $gmagicDraw->rectangle(0, $height - $heightRectagle, $width, $height);
     $gImage = new Gmagick();
     $gImage->readImage($image);
     $gImage->drawimage($gmagicDraw);
     $gImage->writeimage($image);
     $gImage->destroy();
 }