Debian Codegraph @

vendor/chillerlan/php-qrcode/src/Common/LuminanceSourceInterface.php

raw
1 <?php
2 /**
3 * Interface LuminanceSourceInterface
4 *
5 * @created 18.11.2021
6 * @author smiley <[email protected]>
7 * @copyright 2021 smiley
8 * @license MIT
9 */
10 declare(strict_types=1);
11
12 namespace chillerlan\QRCode\Common;
13
14 use chillerlan\QRCode\QROptions;
15 use chillerlan\Settings\SettingsContainerInterface;
16
17 /**
18 * Interface for the luminance sources
19 */
20 interface LuminanceSourceInterface{
21
22 /**
23 * Fetches luminance data for the underlying bitmap. Values should be fetched using:
24 * `int luminance = array[y * width + x] & 0xff`
25 *
26 * @return int[] A row-major 2D array of luminance values. Do not use result $length as it may be
27 * larger than $width * $height bytes on some platforms. Do not modify the contents
28 * of the result.
29 *
30 * @deprecated 6.0.1 This method will be removed. In v7, use the property "LuminanceSourceInterface::$luminances" instead.
31 */
32 public function getLuminances():array;
33
34 /**
35 * @return int The width of the bitmap.
36 *
37 * @deprecated 6.0.1 This method will be removed. In v7, use the property "LuminanceSourceInterface::$width" instead.
38 */
39 public function getWidth():int;
40
41 /**
42 * @return int The height of the bitmap.
43 *
44 * @deprecated 6.0.1 This method will be removed. In v7, use the property "LuminanceSourceInterface::$height" instead.
45 */
46 public function getHeight():int;
47
48 /**
49 * Fetches one row of luminance data from the underlying platform's bitmap. Values range from
50 * 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have
51 * to bitwise and with 0xff for each value. It is preferable for implementations of this method
52 * to only fetch this row rather than the whole image, since no 2D Readers may be installed and
53 * getLuminances() may never be called.
54 *
55 * @param int $y The row to fetch, which must be in [0,getHeight())
56 *
57 * @return int[] An array containing the luminance data.
58 * @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException
59 */
60 public function getRow(int $y):array;
61
62 /**
63 * Creates a LuminanceSource instance from the given file
64 */
65 public static function fromFile(string $path, SettingsContainerInterface|QROptions $options = new QROptions):static;
66
67 /**
68 * Creates a LuminanceSource instance from the given data blob
69 */
70 public static function fromBlob(string $blob, SettingsContainerInterface|QROptions $options = new QROptions):static;
71
72 }