本文整理汇总了PHP中ImagickDraw::point方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::point方法的具体用法?PHP ImagickDraw::point怎么用?PHP ImagickDraw::point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::point方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: image
private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $format = "png", $quality = 85, $filename = FALSE, $save = TRUE, $print = false)
{
$imgH = count($frame);
$imgW = strlen($frame[0]);
$col[0] = new \ImagickPixel("white");
$col[1] = new \ImagickPixel("black");
$image = new \Imagick();
$image->newImage($imgW, $imgH, $col[0]);
$image->setCompressionQuality($quality);
$image->setImageFormat($format);
$draw = new \ImagickDraw();
$draw->setFillColor($col[1]);
for ($y = 0; $y < $imgH; $y++) {
for ($x = 0; $x < $imgW; $x++) {
if ($frame[$y][$x] == '1') {
$draw->point($x, $y);
}
}
}
$image->drawImage($draw);
$image->borderImage($col[0], $outerFrame, $outerFrame);
$image->scaleImage(($imgW + 2 * $outerFrame) * $pixelPerPoint, 0);
if ($save) {
if ($filename === false) {
throw new Exception("QR Code filename can't be empty");
}
$image->writeImages($filename, true);
}
if ($print) {
Header("Content-type: image/" . $format);
echo $image;
}
}
示例2: execute
/**
* Draws one pixel to a given image
*
* @param Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$color = $this->argument(0)->required()->value();
$color = new Color($color);
$x = $this->argument(1)->type('integer')->required()->value();
$y = $this->argument(2)->type('integer')->required()->value();
// prepare pixel
$draw = new \ImagickDraw();
$draw->setFillColor($color->getPixel());
$draw->point($x, $y);
// apply pixel
return $image->getCore()->drawImage($draw);
}
示例3: setColorspaceToRGB
/**
* @return $this
*/
public function setColorspaceToRGB()
{
$imageColorspace = $this->resource->getImageColorspace();
if ($imageColorspace == \Imagick::COLORSPACE_CMYK) {
if (self::getCMYKColorProfile() && self::getRGBColorProfile()) {
$profiles = $this->resource->getImageProfiles('*', false);
// we're only interested if ICC profile(s) exist
$has_icc_profile = array_search('icc', $profiles) !== false;
// if it doesn't have a CMYK ICC profile, we add one
if ($has_icc_profile === false) {
$this->resource->profileImage('icc', self::getCMYKColorProfile());
}
// then we add an RGB profile
$this->resource->profileImage('icc', self::getRGBColorProfile());
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
// we have to use SRGB here, no clue why but it works
} else {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
}
} else {
if ($imageColorspace == \Imagick::COLORSPACE_GRAY) {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
} else {
if (!in_array($imageColorspace, array(\Imagick::COLORSPACE_RGB, \Imagick::COLORSPACE_SRGB))) {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
} else {
// this is to handle embedded icc profiles in the RGB/sRGB colorspace
$profiles = $this->resource->getImageProfiles('*', false);
$has_icc_profile = array_search('icc', $profiles) !== false;
if ($has_icc_profile) {
try {
// if getImageColorspace() says SRGB but the embedded icc profile is CMYK profileImage() will throw an exception
$this->resource->profileImage('icc', self::getRGBColorProfile());
} catch (\Exception $e) {
\Logger::warn($e);
}
}
}
}
}
// this is a HACK to force grayscale images to be real RGB - truecolor, this is important if you want to use
// thumbnails in PDF's because they do not support "real" grayscale JPEGs or PNGs
// problem is described here: http://imagemagick.org/Usage/basics/#type
// and here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=6888#p31891
$currentLocale = setlocale(LC_ALL, "0");
// this locale hack thing is also a hack for imagick
setlocale(LC_ALL, "");
// details see https://www.pimcore.org/issues/browse/PIMCORE-2728
$draw = new \ImagickDraw();
$draw->setFillColor("#ff0000");
$draw->setfillopacity(0.01);
$draw->point(floor($this->getWidth() / 2), floor($this->getHeight() / 2));
// place it in the middle of the image
$this->resource->drawImage($draw);
setlocale(LC_ALL, $currentLocale);
// see setlocale() above, for details ;-)
return $this;
}
示例4: dot
/**
* {@inheritdoc}
*/
public function dot(PointInterface $position, ColorInterface $color)
{
$x = $position->getX();
$y = $position->getY();
try {
$pixel = $this->getColor($color);
$point = new \ImagickDraw();
$point->setFillColor($pixel);
$point->point($x, $y);
$this->imagick->drawimage($point);
$pixel->clear();
$pixel->destroy();
$point->clear();
$point->destroy();
} catch (\ImagickException $e) {
throw new RuntimeException('Draw point operation failed', $e->getCode(), $e);
}
return $this;
}
示例5: applyColorProfiles
/**
* this is to force RGB and to apply custom icc color profiles
*/
protected function applyColorProfiles()
{
if ($this->resource->getImageColorspace() == Imagick::COLORSPACE_CMYK) {
if (self::getCMYKColorProfile() && self::getRGBColorProfile()) {
$profiles = $this->resource->getImageProfiles('*', false);
// we're only interested if ICC profile(s) exist
$has_icc_profile = array_search('icc', $profiles) !== false;
// if it doesn't have a CMYK ICC profile, we add one
if ($has_icc_profile === false) {
$this->resource->profileImage('icc', self::getCMYKColorProfile());
}
// then we add an RGB profile
$this->resource->profileImage('icc', self::getRGBColorProfile());
$this->resource->setImageColorspace(Imagick::COLORSPACE_RGB);
}
}
// this is a HACK to force grayscale images to be real RGB - truecolor, this is important if you want to use
// thumbnails in PDF's because they do not support "real" grayscale JPEGs or PNGs
// problem is described here: http://imagemagick.org/Usage/basics/#type
// and here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=6888#p31891
if ($this->resource->getimagetype() == Imagick::IMGTYPE_GRAYSCALE) {
$draw = new ImagickDraw();
$draw->setFillColor("red");
$draw->setfillopacity(0.001);
$draw->point(0, 0);
$this->resource->drawImage($draw);
}
}
示例6: generateImage
//.........这里部分代码省略.........
$demerit_n4 = floor(abs((100 * (substr_count($ver, chr($bit_r)) / $byte_num) - 50) / 5)) * 10;
$n2_search1 = "/" . chr($bit_r) . chr($bit_r) . "+/";
$n2_search2 = "/" . chr(255) . chr(255) . "+/";
$demerit_n2 = 0;
preg_match_all($n2_search1, $ver_and, $ptn_temp);
foreach ($ptn_temp[0] as $str_temp) {
$demerit_n2 += strlen($str_temp) - 1;
}
$ptn_temp = array();
preg_match_all($n2_search2, $ver_or, $ptn_temp);
foreach ($ptn_temp[0] as $str_temp) {
$demerit_n2 += strlen($str_temp) - 1;
}
$demerit_n2 *= 3;
$ptn_temp = array();
preg_match_all($n1_search, $hor, $ptn_temp);
foreach ($ptn_temp[0] as $str_temp) {
$demerit_n1 += strlen($str_temp) - 2;
}
$demerit_score = $demerit_n1 + $demerit_n2 + $demerit_n3 + $demerit_n4;
if ($demerit_score <= $min_demerit_score || $i == 0) {
$mask_number = $i;
$min_demerit_score = $demerit_score;
}
$i++;
}
$mask_content = 1 << $mask_number;
# --- format information
$format_information_value = $ec << 3 | $mask_number;
$format_information_array = array("101010000010010", "101000100100101", "101111001111100", "101101101001011", "100010111111001", "100000011001110", "100111110010111", "100101010100000", "111011111000100", "111001011110011", "111110110101010", "111100010011101", "110011000101111", "110001100011000", "110110001000001", "110100101110110", "001011010001001", "001001110111110", "001110011100111", "001100111010000", "000011101100010", "000001001010101", "000110100001100", "000100000111011", "011010101011111", "011000001101000", "011111100110001", "011101000000110", "010010010110100", "010000110000011", "010111011011010", "010101111101101");
$i = 0;
while ($i < 15) {
$content = substr($format_information_array[$format_information_value], $i, 1);
$matrix_content[$format_information_x1[$i]][$format_information_y1[$i]] = $content * 255;
$matrix_content[$format_information_x2[$i + 1]][$format_information_y2[$i + 1]] = $content * 255;
$i++;
}
$mib = $max_modules_1side + 8;
$this->imagePath = $this->imagePath . "/qrv" . $version . ".png";
$image = new \Imagick($this->imagePath);
$draw = new \ImagickDraw();
if ($this->fillColor != "black") {
$clut = new \Imagick();
$clut->newImage(1, 1, new \ImagickPixel($this->fillColor));
$image->clutImage($clut);
$clut->destroy();
unset($clut);
}
$draw->setFillColor(new \ImagickPixel($this->fillColor));
$draw->setStrokeColor(new \ImagickPixel($this->strokeColor));
$i = 4;
$mxe = 4 + $max_modules_1side;
$ii = 0;
while ($i < $mxe) {
$j = 4;
$jj = 0;
while ($j < $mxe) {
if ($matrix_content[$ii][$jj] & $mask_content) {
$draw->point($i, $j);
}
$j++;
$jj++;
}
$i++;
$ii++;
}
$image->drawImage($draw);
if ($this->blockImage) {
$blockSize = $this->blockImage->getImageWidth();
$image->resizeImage($mib * $blockSize, $mib * $blockSize, \Imagick::FILTER_POINT, 1);
$testPixel = new \ImagickPixel($this->fillColor);
for ($x = 0; $x < $image->getImageWidth(); $x += $blockSize) {
for ($y = 0; $y < $image->getImageHeight(); $y += $blockSize) {
if ($testPixel->isSimilar($image->getImagePixelColor($x, $y), 1)) {
$image->compositeImage($this->blockImage, $this->overlayBlockImage ? \Imagick::COMPOSITE_OVER : \Imagick::COMPOSITE_REPLACE, $x, $y);
}
}
}
}
$geo = $image->getImageGeometry();
if (!empty($this->width) && $geo['width'] <= $this->width) {
if (!$this->width) {
$this->width = 0;
} else {
if ($this->width < $image->getImageWidth()) {
$this->width = $image->getImageWidth();
}
}
$remaining_pixels = $this->width % $geo['width'];
$fit_width = $this->width - $remaining_pixels;
$image->resizeImage($fit_width, $fit_width, \Imagick::FILTER_POINT, 1);
//FILTER_POINT
$tmp = new \Imagick();
$tmp->newImage($this->width, $this->width, 'none', 'png');
$tmp->compositeImage($image, \Imagick::COMPOSITE_OVER, floor($remaining_pixels / 2), floor($remaining_pixels / 2));
$image->destroy();
$image =& $tmp;
}
return $image;
}
示例7: setColor
function setColor($x, $y, Color $color)
{
$pixel = $this->im->getImagePixelColor($x, $y);
$pixel->setColorValue(\Imagick::COLOR_RED, $color->r / 0xff);
$pixel->setColorValue(\Imagick::COLOR_GREEN, $color->g / 0xff);
$pixel->setColorValue(\Imagick::COLOR_BLUE, $color->b / 0xff);
$pixel->setColorValue(\Imagick::COLOR_ALPHA, max($color->a, 1) / 0xff);
$draw = new \ImagickDraw();
$draw->setFillColor($pixel);
$draw->point($x, $y);
$this->im->drawImage($draw);
}
示例8: brightness
public function brightness($n, $s_x = 0, $e_x = 0, $s_y = 0, $e_y = 0)
{
$info = $this->_handle->getImageGeometry();
$w = $info["width"];
$h = $info["height"];
$format = $this->_handle->getImageFormat();
if ($s_x == 0 && $s_y == 0 && $e_x == 0 && $e_y == 0) {
$e_x = $w;
$e_y = $h;
}
$image = new \Imagick();
$image->newImage($w, $h, "transparent");
$draw = new \ImagickDraw();
for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) {
$p = $image->getImagePixelColor($x, $y);
$rgb = $p->getColor();
if ($x >= $s_x && $x < $e_x && $y >= $s_y && $y < $e_y) {
$rgb["r"] = $rgb["r"] + $rgb["r"] * $n;
$rgb["g"] = $rgb["g"] + $rgb["g"] * $n;
$rgb["b"] = $rgb["b"] + $rgb["b"] * $n;
$rgb["r"] = min(255, $rgb["r"]);
$rgb["r"] = max(0, $rgb["r"]);
$rgb["g"] = min(255, $rgb["g"]);
$rgb["g"] = max(0, $rgb["g"]);
$rgb["b"] = min(255, $rgb["b"]);
$rgb["b"] = max(0, $rgb["b"]);
}
$p->setColor("rgb({$rgb["r"]},{$rgb["g"]},{$rgb["b"]})");
$draw->setFillColor($p);
$draw->point($x, $y);
}
}
$image->drawImage($draw);
$image->setImageFormat($format);
$this->_handle = $image;
$draw->destroy();
}
示例9: point
function point($fillColor, $backgroundColor)
{
$draw = new \ImagickDraw();
$draw->setFillColor($fillColor);
for ($x = 0; $x < 10000; $x++) {
$draw->point(rand(0, 500), rand(0, 500));
}
$imagick = new \Imagick();
$imagick->newImage(500, 500, $backgroundColor);
$imagick->setImageFormat("png");
$imagick->drawImage($draw);
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
示例10: _set_pixel
/**
* 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;
}
示例11: setColorspaceToRGB
/**
* @return $this
*/
public function setColorspaceToRGB()
{
$imageColorspace = $this->resource->getImageColorspace();
if ($imageColorspace == \Imagick::COLORSPACE_CMYK) {
if (self::getCMYKColorProfile() && self::getRGBColorProfile()) {
$profiles = $this->resource->getImageProfiles('*', false);
// we're only interested if ICC profile(s) exist
$has_icc_profile = array_search('icc', $profiles) !== false;
// if it doesn't have a CMYK ICC profile, we add one
if ($has_icc_profile === false) {
$this->resource->profileImage('icc', self::getCMYKColorProfile());
}
// then we add an RGB profile
$this->resource->profileImage('icc', self::getRGBColorProfile());
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
// we have to use SRGB here, no clue why but it works
} else {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
}
} else {
if ($imageColorspace == \Imagick::COLORSPACE_GRAY) {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
} else {
if (!in_array($imageColorspace, array(\Imagick::COLORSPACE_RGB, \Imagick::COLORSPACE_SRGB))) {
$this->resource->setImageColorspace(\Imagick::COLORSPACE_SRGB);
} else {
// this is to handle embedded icc profiles in the RGB/sRGB colorspace
$profiles = $this->resource->getImageProfiles('*', false);
$has_icc_profile = array_search('icc', $profiles) !== false;
if ($has_icc_profile) {
$this->resource->profileImage('icc', self::getRGBColorProfile());
}
}
}
}
// this is a HACK to force grayscale images to be real RGB - truecolor, this is important if you want to use
// thumbnails in PDF's because they do not support "real" grayscale JPEGs or PNGs
// problem is described here: http://imagemagick.org/Usage/basics/#type
// and here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=6888#p31891
$draw = new \ImagickDraw();
$draw->setFillColor("#ff0000");
$draw->setfillopacity(0.01);
$draw->point(floor($this->getWidth() / 2), floor($this->getHeight() / 2));
// place it in the middle of the image
$this->resource->drawImage($draw);
return $this;
}