public function generate() { $findColor = Image_Image::hexColorToArrayColor($this->find); $replaceColor = Image_Image::hexColorToArrayColor($this->replace); $index = imagecolorclosest($this->_owner->image, $findColor['red'], $findColor['green'], $findColor['blue']); //find imagecolorset($this->_owner->image, $index, $replaceColor['red'], $replaceColor['green'], $replaceColor['blue']); //replace unset($index); return true; }
public function generate() { $width = $this->_owner->imagesx(); $height = $this->_owner->imagesy(); $padding = $this->padding; $arrColor = Image_Image::hexColorToArrayColor($this->color); $temp = new Image_Image(); $temp->createImageTrueColor($width + $padding * 2, $height + $padding * 2); $tempcolor = imagecolorallocate($temp->image, $arrColor['red'], $arrColor['green'], $arrColor['blue']); imagefill($temp->image, 0, 0, $tempcolor); imagecopy($temp->image, $this->_owner->image, $padding, $padding, 0, 0, $width, $height); $this->_owner->image = $temp->image; unset($temp); return true; }
public function generate() { $alt = 0; imagesavealpha($this->_owner->image, true); imagealphablending($this->_owner->image, true); $arrColor = Image_Image::hexColorToArrayColor($this->color); $l = imagecolorallocatealpha($this->_owner->image, $arrColor['red'], $arrColor['green'], $arrColor['blue'], $this->light_alpha); $d = imagecolorallocatealpha($this->_owner->image, $arrColor['red'], $arrColor['green'], $arrColor['blue'], $this->dark_alpha); for ($x = 0; $x < $this->_owner->imagesy(); $x += $this->width) { if ($alt++ % 2 == 0) { imagefilledrectangle($this->_owner->image, 0, $x, $this->_owner->imagesx(), $x + $this->width - 1, $l); } else { imagefilledrectangle($this->_owner->image, 0, $x, $this->_owner->imagesx(), $x + $this->width - 1, $d); } } return true; }
public function generate() { $width = $this->_owner->imagesx(); $height = $this->_owner->imagesy(); $temp = new Image_Image(); if (!empty($this->color)) { $temp->createImageTrueColor($width + ($this->r + $this->l), $height + ($this->t + $this->b)); $arrColor = Image_Image::hexColorToArrayColor($this->color); $tempcolor = imagecolorallocate($temp->image, $arrColor['red'], $arrColor['green'], $arrColor['blue']); imagefilledrectangle($temp->image, 0, 0, $temp->imagesx(), $temp->imagesy(), $tempcolor); } else { $temp->createImageTrueColorTransparent($width + ($this->r + $this->l), $height + ($this->t + $this->b)); } imagecopy($temp->image, $this->_owner->image, $this->l, $this->t, 0, 0, $width, $height); $this->_owner->image = $temp->image; unset($temp); return true; }
private function image($frame, $width = 200, $height = 200) { $h = count($frame); $w = strlen($frame[0]); $imgW = $w + 2 * $this->margin; $imgH = $h + 2 * $this->margin; $pixelPerPoint = intval(min(array($width, $height))) / $imgW; $base_image = imagecreate($imgW, $imgH); $col[0] = imagecolorallocate($base_image, 255, 255, 255); $arrColor = Image_Image::hexColorToArrayColor($this->color); $col[1] = imagecolorallocate($base_image, $arrColor['red'], $arrColor['green'], $arrColor['blue']); imagefill($base_image, 0, 0, $col[0]); for ($y = 0; $y < $h; $y++) { for ($x = 0; $x < $w; $x++) { if ($frame[$y][$x] == '1') { imagesetpixel($base_image, $x + $this->margin, $y + $this->margin, $col[1]); } } } $target_image = imagecreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint); imagecopyresized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH); imagedestroy($base_image); return $target_image; }