/** * {@inheritdoc} */ 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; }
/** * {@inheritdoc} */ 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; }
/** * Internal method to set a pixel into the existing image object instance * * @param resource the image object instance * @param integer the x position * @param integer the y position * @param integer the color to be set * @return boolean true on success, false on failure */ protected function _set_pixel(&$image, $x, $y, $color) { switch (self::$driver) { case 'gd': imagesetpixel($image, $x, $y, $color); return TRUE; case 'gmagick': $draw = new GmagickDraw(); $draw->setFillColor($color); $draw->point($x, $y); $image->drawImage($draw); return TRUE; case 'imagick': $draw = new ImagickDraw(); $draw->setFillColor($color); $draw->point($x, $y); $image->drawImage($draw); return TRUE; } return FALSE; }