• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/captcha.php
  • Класс: CCaptcha
  • Вызов: CCaptcha::EmptyText
function EmptyText()
{
	$sx = imagesx($this->image)-1;
	$sy = imagesy($this->image)-1;

	$backup = imagecreatetruecolor($sx, $sy);
	imagealphablending($backup, false);
	imagecopy($backup, $this->image, 0, 0, 0, 0, $sx, $sy);

	$white = imagecolorallocate($this->image, 255, 255, 255);
	$bgColor = imagecolorallocate($this->image, $this->arRealBGColor[0], $this->arRealBGColor[1], $this->arRealBGColor[2]);

	for($x = 1; $x < $sx; $x++)
	for($y = 1; $y < $sy; $y++)
	{
		$c1 = imagecolorat($backup, $x-1, $y);
		if($c1 != $white && $c1 != $bgColor)
		{
			$c2 = imagecolorat($backup, $x+1, $y);
			if($c1 == $c2)
			{
				$c3 = imagecolorat($backup, $x, $y-1);
				if($c2 == $c3)
				{
					$c4 = imagecolorat($backup, $x, $y+1);
					if($c3 == $c4)
						imagesetpixel($this->image, $x, $y, $bgColor);
				}
			}
		}
	}

	if(function_exists('imageconvolution'))
	{
		$gaussian = array(array(1.0, 1.0, 1.0), array(1.0, 7.0, 1.0), array(1.0, 1.0, 1.0));
		imageconvolution($this->image, $gaussian, 15, 0);

		$mask = array(
			array( -0.1, -0.1, -0.1),
			array( -0.1,  1.8, -0.1),
			array( -0.1, -0.1, -0.1)
		);
		imageconvolution($this->image, $mask, 1, 0);
	}
}