ImagickPixelIterator::getIteratorRow()函数是PHP中的内置函数,用于获取当前像素迭代器行。此函数用于在遍历图像像素时检查我们当前位于哪一行。
用法:
int ImagickPixelIterator::getIteratorRow( void )
参数:此函数不接受任何参数。
返回值:该函数返回一个包含当前像素迭代器行的整数值。
异常:该函数在错误时引发ImagickException。
下面给出的程序说明了PHP中的ImagickPixelIterator::getIteratorRow()函数:
程序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();
// Get the current iterator row
echo "Current row is " . $pixelIterator->getIteratorRow();
?>
输出:
Current row is 0 // which is the default row from where we start
程序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();
// Set the pixel iterator to 30
$pixelIterator->setIteratorRow(30);
// Get the current iterator row
echo "Current row is " . $pixelIterator->getIteratorRow();
?>
输出:
Current row is 30
程序3:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object with size of 10x10 pixels
$imagick->newImage(10, 10, 'black');
// Get the pixel iterator
$imageIterator = $imagick->getPixelIterator();
// Loop through pixel rows
foreach ($imageIterator as $row => $pixels) {
// Get the current iterator row
echo "Current row is " . $imageIterator->getIteratorRow() . '<br>';
}
?>
输出:
Current row is 0 Current row is 1 Current row is 2 Current row is 3 Current row is 4 Current row is 5 Current row is 6 Current row is 7 Current row is 8 Current row is 9
参考: https://www.php.net/manual/en/imagickpixeliterator.getiteratorrow.php
相关用法
- PHP ImagickPixelIterator setIteratorFirstRow()用法及代码示例
- PHP ImagickPixelIterator syncIterator()用法及代码示例
- PHP ImagickPixelIterator newPixelIterator()用法及代码示例
- PHP ImagickPixelIterator newPixelRegionIterator()用法及代码示例
- PHP ImagickPixelIterator resetIterator()用法及代码示例
- PHP ImagickPixelIterator resetIterator()用法及代码示例
- PHP ImagickPixelIterator setIteratorLastRow()用法及代码示例
- PHP ImagickPixelIterator getCurrentIteratorRow()用法及代码示例
- PHP ImagickPixelIterator __construct()用法及代码示例
- PHP ImagickPixelIterator getNextIteratorRow()用法及代码示例
- PHP ImagickPixelIterator setIteratorRow()用法及代码示例
- PHP ImagickPixelIterator getPreviousIteratorRow()用法及代码示例
注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | ImagickPixelIterator getIteratorRow() function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。