/** * (non-PHPdoc) * @see Imagine\ImageInterface::fill() */ public function fill(FillInterface $fill) { try { $iterator = $this->imagick->getPixelIterator(); foreach ($iterator as $y => $pixels) { foreach ($pixels as $x => $pixel) { $color = $fill->getColor(new Point($x, $y)); $pixel->setColor((string) $color); $pixel->setColorValue(\Imagick::COLOR_OPACITY, number_format(abs(round($color->getAlpha() / 100, 1)), 1)); } $iterator->syncIterator(); } } catch (\ImagickException $e) { throw new RuntimeException('Fill operation failed', $e->getCode(), $e); } return $this; }
/** * (non-PHPdoc) * @see Imagine\ImageInterface::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; }
/** * (non-PHPdoc) * @see Imagine\ImageInterface::fill() */ public function fill(FillInterface $fill) { $size = $this->getSize(); for ($x = 0; $x < $size->getWidth(); $x++) { for ($y = 0; $y < $size->getHeight(); $y++) { if (false === imagesetpixel($this->resource, $x, $y, $this->getColor($fill->getColor(new Point($x, $y))))) { throw new RuntimeException('Fill operation failed'); } } } return $this; }