ImagickPixelIterator::resetIterator()函数是PHP中的内置函数,用于重置像素迭代器。
用法:
bool ImagickPixelIterator::resetIterator( void )
参数:此函数不接受任何参数。
返回值:成功时此函数返回TRUE。
以下示例程序旨在说明PHP中的ImagickPixelIterator::resetIterator()函数:
程序1:
<?php
// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Get the pixel iterator
$pixelIterator = $imagick->getPixelIterator();
// Set the pixel iterator to 50
$pixelIterator->setIteratorRow(50);
// Get the current iterator row
echo "Before reset row is " . $pixelIterator->getIteratorRow();
// Reset the iterator
$pixelIterator->resetIterator();
// Get the current iterator row
echo "<br>After reset row is " . $pixelIterator->getIteratorRow();
?>
输出:
Before reset row is 50 After reset row is 0
程序2:
<?php
// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Get the pixel iterator
$pixelIterator = $imagick->getPixelIterator();
$pixelIterator->setIteratorRow(40);
// Get the current iterator row
$row = $pixelIterator->getCurrentIteratorRow();
echo "Colors of 61th and 62nd pixel from 40th row are:<br>";
print("Pixel 60:" . "<pre>".print_r($row[60]->getColor(), true)."</pre>");
print("Pixel 61:" . "<pre>".print_r($row[61]->getColor(), true)."</pre>");
// Reset the iterator to first row
$pixelIterator->resetIterator();
// Get the current iterator row
$row = $pixelIterator->getCurrentIteratorRow();
echo "First two colors of pixels from first row are:<br>";
print("Pixel 1:" . "<pre>".print_r($row[0]->getColor(), true)."</pre>");
print("Pixel 2:" . "<pre>".print_r($row[1]->getColor(), true)."</pre>");
?>
输出:
Colors of 61th and 62nd pixel from 40th row are: Pixel 60: Array ( [r] => 110 [g] => 199 [b] => 131 [a] => 1 ) Pixel 61: Array ( [r] => 23 [g] => 165 [b] => 57 [a] => 1 ) First two colors of pixels from first row are: Pixel 1: Array ( [r] => 255 [g] => 255 [b] => 255 [a] => 1 ) Pixel 2: Array ( [r] => 255 [g] => 255 [b] => 255 [a] => 1 )
参考: https://www.php.net/manual/en/imagickpixeliterator.resetiterator.php
相关用法
- PHP ImagickPixelIterator resetIterator()用法及代码示例
- PHP ImagickPixelIterator syncIterator()用法及代码示例
- PHP ImagickPixelIterator newPixelIterator()用法及代码示例
- PHP ImagickPixelIterator getIteratorRow()用法及代码示例
- PHP ImagickPixelIterator setIteratorFirstRow()用法及代码示例
- PHP ImagickPixelIterator newPixelRegionIterator()用法及代码示例
- PHP ImagickPixelIterator setIteratorLastRow()用法及代码示例
- PHP ImagickPixelIterator getPreviousIteratorRow()用法及代码示例
- PHP ImagickPixelIterator __construct()用法及代码示例
- PHP ImagickPixelIterator setIteratorRow()用法及代码示例
- PHP ImagickPixelIterator getCurrentIteratorRow()用法及代码示例
- PHP ImagickPixelIterator getNextIteratorRow()用法及代码示例
注:本文由纯净天空筛选整理自 PHP | ImagickPixelIterator resetIterator() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。