1 | <?php |
||
8 | class IconImage |
||
9 | { |
||
10 | /** |
||
11 | * @var integer Width, in pixels, of the image |
||
12 | */ |
||
13 | public $width; |
||
14 | /** |
||
15 | * @var integer Height, in pixels, of the image |
||
16 | */ |
||
17 | public $height; |
||
18 | /** |
||
19 | * @var integer Number of colors in image |
||
20 | */ |
||
21 | public $colorCount; |
||
22 | /** |
||
23 | * @var integer Reserved ( must be 0) |
||
24 | */ |
||
25 | public $reserved; |
||
26 | /** |
||
27 | * @var integer Color Planes |
||
28 | */ |
||
29 | public $planes; |
||
30 | /** |
||
31 | * @var integer bits per pixel |
||
32 | */ |
||
33 | public $bitCount; |
||
34 | /** |
||
35 | * @var integer How many bytes in this resource? |
||
36 | */ |
||
37 | public $sizeInBytes; |
||
38 | /** |
||
39 | * @var integer Where in the file is this image? |
||
40 | */ |
||
41 | public $fileOffset; |
||
42 | |||
43 | /** |
||
44 | * @var integer size of BITMAPINFOHEADER structure |
||
45 | */ |
||
46 | public $bmpHeaderSize; |
||
47 | |||
48 | /** |
||
49 | * @var integer image width from BITMAPINFOHEADER |
||
50 | */ |
||
51 | public $bmpHeaderWidth; |
||
52 | |||
53 | /** |
||
54 | * @var integer image height from BITMAPINFOHEADER |
||
55 | */ |
||
56 | public $bmpHeaderHeight; |
||
57 | |||
58 | /** |
||
59 | * @var string PNG file for icon images which use PNG |
||
60 | */ |
||
61 | public $pngData = null; |
||
62 | |||
63 | /** |
||
64 | * @var string BMP bitmap data for images which use BMP |
||
65 | */ |
||
66 | public $bmpData = null; |
||
67 | |||
68 | public $palette = []; |
||
69 | |||
70 | /** |
||
71 | * IconEntry constructor. |
||
72 | * @param array $data array of data extracted from a ICONDIRENTRY binary structure |
||
73 | */ |
||
74 | 18 | public function __construct($data) |
|
75 | { |
||
76 | 18 | foreach ($data as $name => $value) { |
|
77 | 17 | $this->$name = $value; |
|
78 | 18 | } |
|
79 | 18 | } |
|
80 | |||
81 | 13 | public function getDescription() |
|
82 | { |
||
83 | 13 | return sprintf( |
|
84 | 13 | '%dx%d pixel %s @ %d bits/pixel', |
|
85 | 13 | $this->width, |
|
86 | 13 | $this->height, |
|
87 | 13 | $this->isPng() ? 'PNG' : 'BMP', |
|
88 | 13 | $this->bitCount |
|
89 | 13 | ); |
|
90 | } |
||
91 | |||
92 | /** |
||
93 | * Stores binary PNG file for the icon |
||
94 | * @param string $pngData |
||
95 | */ |
||
96 | 3 | public function setPngFile($pngData) |
|
100 | |||
101 | 15 | public function isPng() |
|
105 | |||
106 | 1 | public function isBmp() |
|
107 | { |
||
110 | |||
111 | 17 | public function setBitmapInfoHeader($bmpInfo) |
|
125 | |||
126 | 17 | public function setBitmapData($bmpData) |
|
130 | |||
131 | 10 | public function addToBmpPalette($r, $g, $b, $reserved) |
|
135 | } |
||
136 |