@@ -22,21 +22,21 @@ discard block |
||
22 | 22 | * @package WideImage |
23 | 23 | **/ |
24 | 24 | |
25 | - require_once(WideImage::path() . 'Exception.php'); |
|
26 | - require_once(WideImage::path() . 'Image.php'); |
|
27 | - require_once(WideImage::path() . 'TrueColorImage.php'); |
|
28 | - require_once(WideImage::path() . 'PaletteImage.php'); |
|
25 | + require_once(WideImage::path().'Exception.php'); |
|
26 | + require_once(WideImage::path().'Image.php'); |
|
27 | + require_once(WideImage::path().'TrueColorImage.php'); |
|
28 | + require_once(WideImage::path().'PaletteImage.php'); |
|
29 | 29 | |
30 | - require_once(WideImage::path() . 'Coordinate.php'); |
|
31 | - require_once(WideImage::path() . 'Canvas.php'); |
|
32 | - require_once(WideImage::path() . 'PaletteImage.php'); |
|
33 | - require_once(WideImage::path() . 'TrueColorImage.php'); |
|
34 | - require_once(WideImage::path() . 'MapperFactory.php'); |
|
35 | - require_once(WideImage::path() . 'OperationFactory.php'); |
|
30 | + require_once(WideImage::path().'Coordinate.php'); |
|
31 | + require_once(WideImage::path().'Canvas.php'); |
|
32 | + require_once(WideImage::path().'PaletteImage.php'); |
|
33 | + require_once(WideImage::path().'TrueColorImage.php'); |
|
34 | + require_once(WideImage::path().'MapperFactory.php'); |
|
35 | + require_once(WideImage::path().'OperationFactory.php'); |
|
36 | 36 | |
37 | - require_once(WideImage::path() . 'Font/TTF.php'); |
|
38 | - require_once(WideImage::path() . 'Font/GDF.php'); |
|
39 | - require_once(WideImage::path() . 'Font/PS.php'); |
|
37 | + require_once(WideImage::path().'Font/TTF.php'); |
|
38 | + require_once(WideImage::path().'Font/GDF.php'); |
|
39 | + require_once(WideImage::path().'Font/PS.php'); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @package Exceptions |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | static function path() |
76 | 76 | { |
77 | 77 | if (self::$path === null) |
78 | - self::$path = dirname(__FILE__) . DIRECTORY_SEPARATOR; |
|
78 | + self::$path = dirname(__FILE__).DIRECTORY_SEPARATOR; |
|
79 | 79 | return self::$path; |
80 | 80 | } |
81 | 81 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | if (!$predictedSourceType) |
127 | 127 | $predictedSourceType = 'File'; |
128 | 128 | |
129 | - return call_user_func(array('WideImage', 'loadFrom' . $predictedSourceType), $source, $format); |
|
129 | + return call_user_func(array('WideImage', 'loadFrom'.$predictedSourceType), $source, $format); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -90,10 +90,10 @@ |
||
90 | 90 | */ |
91 | 91 | function __call($method, $params) |
92 | 92 | { |
93 | - if (function_exists('image' . $method)) |
|
93 | + if (function_exists('image'.$method)) |
|
94 | 94 | { |
95 | 95 | array_unshift($params, $this->handle); |
96 | - call_user_func_array('image' . $method, $params); |
|
96 | + call_user_func_array('image'.$method, $params); |
|
97 | 97 | } |
98 | 98 | else |
99 | 99 | throw new WideImage_InvalidCanvasMethodException("Function doesn't exist: image{$method}."); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * @package Internal/Mappers |
23 | 23 | **/ |
24 | 24 | |
25 | - include_once(WideImage::path() . '/vendor/JPEXS/bmp.php'); |
|
25 | + include_once(WideImage::path().'/vendor/JPEXS/bmp.php'); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Mapper support for BMP |
@@ -69,152 +69,152 @@ discard block |
||
69 | 69 | * @param int $alphaBgB Background color B value for alpha-channel images (Default is White) |
70 | 70 | * @return resource Image resource |
71 | 71 | */ |
72 | -function imageCreateFromIco($filename,$icoColorCount=16,$icoSize=16,$alphaBgR=255,$alphaBgG=255,$alphaBgB=255) |
|
72 | +function imageCreateFromIco($filename, $icoColorCount = 16, $icoSize = 16, $alphaBgR = 255, $alphaBgG = 255, $alphaBgB = 255) |
|
73 | 73 | { |
74 | -$Ikona=jpexs_GetIconsInfo($filename); |
|
74 | +$Ikona = jpexs_GetIconsInfo($filename); |
|
75 | 75 | |
76 | -$IconID=-1; |
|
76 | +$IconID = -1; |
|
77 | 77 | |
78 | -$ColMax=-1; |
|
79 | -$SizeMax=-1; |
|
78 | +$ColMax = -1; |
|
79 | +$SizeMax = -1; |
|
80 | 80 | |
81 | -for($p=0;$p<count($Ikona);$p++) |
|
81 | +for ($p = 0; $p < count($Ikona); $p++) |
|
82 | 82 | { |
83 | -$Ikona[$p]["NumberOfColors"]=pow(2,$Ikona[$p]["Info"]["BitsPerPixel"]); |
|
83 | +$Ikona[$p]["NumberOfColors"] = pow(2, $Ikona[$p]["Info"]["BitsPerPixel"]); |
|
84 | 84 | }; |
85 | 85 | |
86 | 86 | |
87 | -for($p=0;$p<count($Ikona);$p++) |
|
87 | +for ($p = 0; $p < count($Ikona); $p++) |
|
88 | 88 | { |
89 | 89 | |
90 | -if(($ColMax==-1)or($Ikona[$p]["NumberOfColors"]>=$Ikona[$ColMax]["NumberOfColors"])) |
|
91 | -if(($icoSize==$Ikona[$p]["Width"])or($icoSize==ICO_MAX_SIZE)) |
|
90 | +if (($ColMax == -1) or ($Ikona[$p]["NumberOfColors"] >= $Ikona[$ColMax]["NumberOfColors"])) |
|
91 | +if (($icoSize == $Ikona[$p]["Width"]) or ($icoSize == ICO_MAX_SIZE)) |
|
92 | 92 | { |
93 | - $ColMax=$p; |
|
93 | + $ColMax = $p; |
|
94 | 94 | }; |
95 | 95 | |
96 | -if(($SizeMax==-1)or($Ikona[$p]["Width"]>=$Ikona[$SizeMax]["Width"])) |
|
97 | -if(($icoColorCount==$Ikona[$p]["NumberOfColors"])or($icoColorCount==ICO_MAX_COLOR)) |
|
96 | +if (($SizeMax == -1) or ($Ikona[$p]["Width"] >= $Ikona[$SizeMax]["Width"])) |
|
97 | +if (($icoColorCount == $Ikona[$p]["NumberOfColors"]) or ($icoColorCount == ICO_MAX_COLOR)) |
|
98 | 98 | { |
99 | - $SizeMax=$p; |
|
99 | + $SizeMax = $p; |
|
100 | 100 | }; |
101 | 101 | |
102 | 102 | |
103 | -if($Ikona[$p]["NumberOfColors"]==$icoColorCount) |
|
104 | -if($Ikona[$p]["Width"]==$icoSize) |
|
103 | +if ($Ikona[$p]["NumberOfColors"] == $icoColorCount) |
|
104 | +if ($Ikona[$p]["Width"] == $icoSize) |
|
105 | 105 | { |
106 | 106 | |
107 | - $IconID=$p; |
|
107 | + $IconID = $p; |
|
108 | 108 | }; |
109 | 109 | }; |
110 | 110 | |
111 | - if($icoColorCount==ICO_MAX_COLOR) $IconID=$ColMax; |
|
112 | - if($icoSize==ICO_MAX_SIZE) $IconID=$SizeMax; |
|
111 | + if ($icoColorCount == ICO_MAX_COLOR) $IconID = $ColMax; |
|
112 | + if ($icoSize == ICO_MAX_SIZE) $IconID = $SizeMax; |
|
113 | 113 | |
114 | -$ColName=$icoColorCount; |
|
114 | +$ColName = $icoColorCount; |
|
115 | 115 | |
116 | -if($icoSize==ICO_MAX_SIZE) $icoSize="Max"; |
|
117 | -if($ColName==ICO_TRUE_COLOR) $ColName="True"; |
|
118 | -if($ColName==ICO_XP_COLOR) $ColName="XP"; |
|
119 | -if($ColName==ICO_MAX_COLOR) $ColName="Max"; |
|
120 | -if($IconID==-1) die("Icon with $ColName colors and $icoSize x $icoSize size doesn't exist in this file!"); |
|
116 | +if ($icoSize == ICO_MAX_SIZE) $icoSize = "Max"; |
|
117 | +if ($ColName == ICO_TRUE_COLOR) $ColName = "True"; |
|
118 | +if ($ColName == ICO_XP_COLOR) $ColName = "XP"; |
|
119 | +if ($ColName == ICO_MAX_COLOR) $ColName = "Max"; |
|
120 | +if ($IconID == -1) die("Icon with $ColName colors and $icoSize x $icoSize size doesn't exist in this file!"); |
|
121 | 121 | |
122 | 122 | |
123 | -jpexs_readIcon($filename,$IconID,$Ikona); |
|
123 | +jpexs_readIcon($filename, $IconID, $Ikona); |
|
124 | 124 | |
125 | - $biBitCount=$Ikona[$IconID]["Info"]["BitsPerPixel"]; |
|
125 | + $biBitCount = $Ikona[$IconID]["Info"]["BitsPerPixel"]; |
|
126 | 126 | |
127 | 127 | |
128 | - if($Ikona[$IconID]["Info"]["BitsPerPixel"]==0) |
|
128 | + if ($Ikona[$IconID]["Info"]["BitsPerPixel"] == 0) |
|
129 | 129 | { |
130 | - $Ikona[$IconID]["Info"]["BitsPerPixel"]=24; |
|
130 | + $Ikona[$IconID]["Info"]["BitsPerPixel"] = 24; |
|
131 | 131 | }; |
132 | 132 | |
133 | - $biBitCount=$Ikona[$IconID]["Info"]["BitsPerPixel"]; |
|
134 | - if($biBitCount==0) $biBitCount=1; |
|
133 | + $biBitCount = $Ikona[$IconID]["Info"]["BitsPerPixel"]; |
|
134 | + if ($biBitCount == 0) $biBitCount = 1; |
|
135 | 135 | |
136 | 136 | |
137 | -$Ikona[$IconID]["BitCount"]=$Ikona[$IconID]["Info"]["BitsPerPixel"]; |
|
137 | +$Ikona[$IconID]["BitCount"] = $Ikona[$IconID]["Info"]["BitsPerPixel"]; |
|
138 | 138 | |
139 | 139 | |
140 | 140 | |
141 | -if($Ikona[$IconID]["BitCount"]>=24) |
|
141 | +if ($Ikona[$IconID]["BitCount"] >= 24) |
|
142 | 142 | { |
143 | -$img=imagecreatetruecolor($Ikona[$IconID]["Width"],$Ikona[$IconID]["Height"]); |
|
144 | -if($Ikona[$IconID]["BitCount"]==32): |
|
145 | - $backcolor=imagecolorallocate($img,$alphaBgR,$alphaBgG,$alphaBgB); |
|
146 | - imagefilledrectangle($img,0,0,$Ikona[$IconID]["Width"]-1,$Ikona[$IconID]["Height"]-1,$backcolor); |
|
143 | +$img = imagecreatetruecolor($Ikona[$IconID]["Width"], $Ikona[$IconID]["Height"]); |
|
144 | +if ($Ikona[$IconID]["BitCount"] == 32): |
|
145 | + $backcolor = imagecolorallocate($img, $alphaBgR, $alphaBgG, $alphaBgB); |
|
146 | + imagefilledrectangle($img, 0, 0, $Ikona[$IconID]["Width"] - 1, $Ikona[$IconID]["Height"] - 1, $backcolor); |
|
147 | 147 | endif; |
148 | -for($y=0;$y<$Ikona[$IconID]["Height"];$y++) |
|
149 | -for($x=0;$x<$Ikona[$IconID]["Width"];$x++) |
|
148 | +for ($y = 0; $y < $Ikona[$IconID]["Height"]; $y++) |
|
149 | +for ($x = 0; $x < $Ikona[$IconID]["Width"]; $x++) |
|
150 | 150 | { |
151 | - $R=$Ikona[$IconID]["Data"][$x][$y]["r"]; |
|
152 | - $G=$Ikona[$IconID]["Data"][$x][$y]["g"]; |
|
153 | - $B=$Ikona[$IconID]["Data"][$x][$y]["b"]; |
|
154 | - if($Ikona[$IconID]["BitCount"]==32) |
|
151 | + $R = $Ikona[$IconID]["Data"][$x][$y]["r"]; |
|
152 | + $G = $Ikona[$IconID]["Data"][$x][$y]["g"]; |
|
153 | + $B = $Ikona[$IconID]["Data"][$x][$y]["b"]; |
|
154 | + if ($Ikona[$IconID]["BitCount"] == 32) |
|
155 | 155 | { |
156 | - $Alpha=127-round($Ikona[$IconID]["Data"][$x][$y]["alpha"]*127/255); |
|
157 | - if($Ikona[$IconID]["Maska"][$x][$y]==1) $Alpha=127; |
|
158 | - $color=imagecolorexactalpha($img,$R,$G,$B,$Alpha); |
|
159 | - if($color==-1) $color=imagecolorallocatealpha($img,$R,$G,$B,$Alpha); |
|
156 | + $Alpha = 127 - round($Ikona[$IconID]["Data"][$x][$y]["alpha"] * 127 / 255); |
|
157 | + if ($Ikona[$IconID]["Maska"][$x][$y] == 1) $Alpha = 127; |
|
158 | + $color = imagecolorexactalpha($img, $R, $G, $B, $Alpha); |
|
159 | + if ($color == -1) $color = imagecolorallocatealpha($img, $R, $G, $B, $Alpha); |
|
160 | 160 | } |
161 | 161 | else |
162 | 162 | { |
163 | - $color=imagecolorexact($img,$R,$G,$B); |
|
164 | - if($color==-1) $color=imagecolorallocate($img,$R,$G,$B); |
|
163 | + $color = imagecolorexact($img, $R, $G, $B); |
|
164 | + if ($color == -1) $color = imagecolorallocate($img, $R, $G, $B); |
|
165 | 165 | }; |
166 | 166 | |
167 | - imagesetpixel($img,$x,$y,$color); |
|
167 | + imagesetpixel($img, $x, $y, $color); |
|
168 | 168 | |
169 | 169 | }; |
170 | 170 | |
171 | 171 | } |
172 | 172 | else |
173 | 173 | { |
174 | -$img=imagecreate($Ikona[$IconID]["Width"],$Ikona[$IconID]["Height"]); |
|
175 | -for($p=0;$p<count($Ikona[$IconID]["Paleta"]);$p++) |
|
176 | - $Paleta[$p]=imagecolorallocate($img,$Ikona[$IconID]["Paleta"][$p]["r"],$Ikona[$IconID]["Paleta"][$p]["g"],$Ikona[$IconID]["Paleta"][$p]["b"]); |
|
174 | +$img = imagecreate($Ikona[$IconID]["Width"], $Ikona[$IconID]["Height"]); |
|
175 | +for ($p = 0; $p < count($Ikona[$IconID]["Paleta"]); $p++) |
|
176 | + $Paleta[$p] = imagecolorallocate($img, $Ikona[$IconID]["Paleta"][$p]["r"], $Ikona[$IconID]["Paleta"][$p]["g"], $Ikona[$IconID]["Paleta"][$p]["b"]); |
|
177 | 177 | |
178 | -for($y=0;$y<$Ikona[$IconID]["Height"];$y++) |
|
179 | -for($x=0;$x<$Ikona[$IconID]["Width"];$x++) |
|
178 | +for ($y = 0; $y < $Ikona[$IconID]["Height"]; $y++) |
|
179 | +for ($x = 0; $x < $Ikona[$IconID]["Width"]; $x++) |
|
180 | 180 | { |
181 | - imagesetpixel($img,$x,$y,$Paleta[$Ikona[$IconID]["Data"][$x][$y]]); |
|
181 | + imagesetpixel($img, $x, $y, $Paleta[$Ikona[$IconID]["Data"][$x][$y]]); |
|
182 | 182 | }; |
183 | 183 | }; |
184 | -$IsTransparent=false; |
|
185 | -for($y=0;$y<$Ikona[$IconID]["Height"];$y++) |
|
186 | -for($x=0;$x<$Ikona[$IconID]["Width"];$x++) |
|
187 | - if($Ikona[$IconID]["Maska"][$x][$y]==1) |
|
184 | +$IsTransparent = false; |
|
185 | +for ($y = 0; $y < $Ikona[$IconID]["Height"]; $y++) |
|
186 | +for ($x = 0; $x < $Ikona[$IconID]["Width"]; $x++) |
|
187 | + if ($Ikona[$IconID]["Maska"][$x][$y] == 1) |
|
188 | 188 | { |
189 | - $IsTransparent=true; |
|
189 | + $IsTransparent = true; |
|
190 | 190 | break; |
191 | 191 | }; |
192 | -if($Ikona[$IconID]["BitCount"]==32) |
|
192 | +if ($Ikona[$IconID]["BitCount"] == 32) |
|
193 | 193 | { |
194 | 194 | imagealphablending($img, false); |
195 | - if(function_exists("imagesavealpha")) |
|
196 | - imagesavealpha($img,true); |
|
195 | + if (function_exists("imagesavealpha")) |
|
196 | + imagesavealpha($img, true); |
|
197 | 197 | }; |
198 | 198 | |
199 | -if($IsTransparent) |
|
199 | +if ($IsTransparent) |
|
200 | 200 | { |
201 | - if(($Ikona[$IconID]["BitCount"]>=24)or(imagecolorstotal($img)>=256)) |
|
201 | + if (($Ikona[$IconID]["BitCount"] >= 24) or (imagecolorstotal($img) >= 256)) |
|
202 | 202 | { |
203 | - $img2=imagecreatetruecolor(imagesx($img),imagesy($img)); |
|
204 | - imagecopy($img2,$img,0,0,0,0,imagesx($img),imagesy($img)); |
|
203 | + $img2 = imagecreatetruecolor(imagesx($img), imagesy($img)); |
|
204 | + imagecopy($img2, $img, 0, 0, 0, 0, imagesx($img), imagesy($img)); |
|
205 | 205 | imagedestroy($img); |
206 | - $img=$img2; |
|
207 | - imagetruecolortopalette($img,true,255); |
|
206 | + $img = $img2; |
|
207 | + imagetruecolortopalette($img, true, 255); |
|
208 | 208 | |
209 | 209 | }; |
210 | - $Pruhledna=imagecolorallocate($img,0,0,0); |
|
211 | - for($y=0;$y<$Ikona[$IconID]["Height"];$y++) |
|
212 | - for($x=0;$x<$Ikona[$IconID]["Width"];$x++) |
|
213 | - if($Ikona[$IconID]["Maska"][$x][$y]==1) |
|
210 | + $Pruhledna = imagecolorallocate($img, 0, 0, 0); |
|
211 | + for ($y = 0; $y < $Ikona[$IconID]["Height"]; $y++) |
|
212 | + for ($x = 0; $x < $Ikona[$IconID]["Width"]; $x++) |
|
213 | + if ($Ikona[$IconID]["Maska"][$x][$y] == 1) |
|
214 | 214 | { |
215 | - imagesetpixel($img,$x,$y,$Pruhledna); |
|
215 | + imagesetpixel($img, $x, $y, $Pruhledna); |
|
216 | 216 | }; |
217 | - imagecolortransparent($img,$Pruhledna); |
|
217 | + imagecolortransparent($img, $Pruhledna); |
|
218 | 218 | }; |
219 | 219 | |
220 | 220 | return $img; |
@@ -225,121 +225,121 @@ discard block |
||
225 | 225 | |
226 | 226 | |
227 | 227 | |
228 | -function jpexs_readIcon($filename,$id,&$Ikona) |
|
228 | +function jpexs_readIcon($filename, $id, &$Ikona) |
|
229 | 229 | { |
230 | 230 | global $jpexs_currentBit; |
231 | 231 | |
232 | -$f=fopen($filename,"rb"); |
|
232 | +$f = fopen($filename, "rb"); |
|
233 | 233 | |
234 | -fseek($f,6+$id*16); |
|
235 | - $Width=jpexs_freadbyte($f); |
|
236 | - $Height=jpexs_freadbyte($f); |
|
237 | -fseek($f,6+$id*16+12); |
|
238 | -$OffSet=jpexs_freaddword($f); |
|
239 | -fseek($f,$OffSet); |
|
234 | +fseek($f, 6 + $id * 16); |
|
235 | + $Width = jpexs_freadbyte($f); |
|
236 | + $Height = jpexs_freadbyte($f); |
|
237 | +fseek($f, 6 + $id * 16 + 12); |
|
238 | +$OffSet = jpexs_freaddword($f); |
|
239 | +fseek($f, $OffSet); |
|
240 | 240 | |
241 | -$p=$id; |
|
241 | +$p = $id; |
|
242 | 242 | |
243 | - $Ikona[$p]["Info"]["HeaderSize"]=jpexs_freadlngint($f); |
|
244 | - $Ikona[$p]["Info"]["ImageWidth"]=jpexs_freadlngint($f); |
|
245 | - $Ikona[$p]["Info"]["ImageHeight"]=jpexs_freadlngint($f); |
|
246 | - $Ikona[$p]["Info"]["NumberOfImagePlanes"]=jpexs_freadword($f); |
|
247 | - $Ikona[$p]["Info"]["BitsPerPixel"]=jpexs_freadword($f); |
|
248 | - $Ikona[$p]["Info"]["CompressionMethod"]=jpexs_freadlngint($f); |
|
249 | - $Ikona[$p]["Info"]["SizeOfBitmap"]=jpexs_freadlngint($f); |
|
250 | - $Ikona[$p]["Info"]["HorzResolution"]=jpexs_freadlngint($f); |
|
251 | - $Ikona[$p]["Info"]["VertResolution"]=jpexs_freadlngint($f); |
|
252 | - $Ikona[$p]["Info"]["NumColorUsed"]=jpexs_freadlngint($f); |
|
253 | - $Ikona[$p]["Info"]["NumSignificantColors"]=jpexs_freadlngint($f); |
|
243 | + $Ikona[$p]["Info"]["HeaderSize"] = jpexs_freadlngint($f); |
|
244 | + $Ikona[$p]["Info"]["ImageWidth"] = jpexs_freadlngint($f); |
|
245 | + $Ikona[$p]["Info"]["ImageHeight"] = jpexs_freadlngint($f); |
|
246 | + $Ikona[$p]["Info"]["NumberOfImagePlanes"] = jpexs_freadword($f); |
|
247 | + $Ikona[$p]["Info"]["BitsPerPixel"] = jpexs_freadword($f); |
|
248 | + $Ikona[$p]["Info"]["CompressionMethod"] = jpexs_freadlngint($f); |
|
249 | + $Ikona[$p]["Info"]["SizeOfBitmap"] = jpexs_freadlngint($f); |
|
250 | + $Ikona[$p]["Info"]["HorzResolution"] = jpexs_freadlngint($f); |
|
251 | + $Ikona[$p]["Info"]["VertResolution"] = jpexs_freadlngint($f); |
|
252 | + $Ikona[$p]["Info"]["NumColorUsed"] = jpexs_freadlngint($f); |
|
253 | + $Ikona[$p]["Info"]["NumSignificantColors"] = jpexs_freadlngint($f); |
|
254 | 254 | |
255 | 255 | |
256 | - $biBitCount=$Ikona[$p]["Info"]["BitsPerPixel"]; |
|
256 | + $biBitCount = $Ikona[$p]["Info"]["BitsPerPixel"]; |
|
257 | 257 | |
258 | - if($Ikona[$p]["Info"]["BitsPerPixel"]<=8) |
|
258 | + if ($Ikona[$p]["Info"]["BitsPerPixel"] <= 8) |
|
259 | 259 | { |
260 | 260 | |
261 | - $barev=pow(2,$biBitCount); |
|
261 | + $barev = pow(2, $biBitCount); |
|
262 | 262 | |
263 | - for($b=0;$b<$barev;$b++) |
|
263 | + for ($b = 0; $b < $barev; $b++) |
|
264 | 264 | { |
265 | - $Ikona[$p]["Paleta"][$b]["b"]=jpexs_freadbyte($f); |
|
266 | - $Ikona[$p]["Paleta"][$b]["g"]=jpexs_freadbyte($f); |
|
267 | - $Ikona[$p]["Paleta"][$b]["r"]=jpexs_freadbyte($f); |
|
265 | + $Ikona[$p]["Paleta"][$b]["b"] = jpexs_freadbyte($f); |
|
266 | + $Ikona[$p]["Paleta"][$b]["g"] = jpexs_freadbyte($f); |
|
267 | + $Ikona[$p]["Paleta"][$b]["r"] = jpexs_freadbyte($f); |
|
268 | 268 | jpexs_freadbyte($f); |
269 | 269 | }; |
270 | 270 | |
271 | -$Zbytek=(4-ceil(($Width/(8/$biBitCount)))%4)%4; |
|
271 | +$Zbytek = (4 - ceil(($Width / (8 / $biBitCount))) % 4) % 4; |
|
272 | 272 | |
273 | 273 | |
274 | -for($y=$Height-1;$y>=0;$y--) |
|
274 | +for ($y = $Height - 1; $y >= 0; $y--) |
|
275 | 275 | { |
276 | - $jpexs_currentBit=0; |
|
277 | - for($x=0;$x<$Width;$x++) |
|
276 | + $jpexs_currentBit = 0; |
|
277 | + for ($x = 0; $x < $Width; $x++) |
|
278 | 278 | { |
279 | - $C=jpexs_freadbits($f,$biBitCount); |
|
280 | - $Ikona[$p]["Data"][$x][$y]=$C; |
|
279 | + $C = jpexs_freadbits($f, $biBitCount); |
|
280 | + $Ikona[$p]["Data"][$x][$y] = $C; |
|
281 | 281 | }; |
282 | 282 | |
283 | - if($jpexs_currentBit!=0) {jpexs_freadbyte($f);}; |
|
284 | - for($g=0;$g<$Zbytek;$g++) |
|
283 | + if ($jpexs_currentBit != 0) {jpexs_freadbyte($f); }; |
|
284 | + for ($g = 0; $g < $Zbytek; $g++) |
|
285 | 285 | jpexs_freadbyte($f); |
286 | 286 | }; |
287 | 287 | |
288 | 288 | } |
289 | -elseif($biBitCount==24) |
|
289 | +elseif ($biBitCount == 24) |
|
290 | 290 | { |
291 | - $Zbytek=$Width%4; |
|
291 | + $Zbytek = $Width % 4; |
|
292 | 292 | |
293 | - for($y=$Height-1;$y>=0;$y--) |
|
293 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
294 | 294 | { |
295 | - for($x=0;$x<$Width;$x++) |
|
295 | + for ($x = 0; $x < $Width; $x++) |
|
296 | 296 | { |
297 | - $B=jpexs_freadbyte($f); |
|
298 | - $G=jpexs_freadbyte($f); |
|
299 | - $R=jpexs_freadbyte($f); |
|
300 | - $Ikona[$p]["Data"][$x][$y]["r"]=$R; |
|
301 | - $Ikona[$p]["Data"][$x][$y]["g"]=$G; |
|
302 | - $Ikona[$p]["Data"][$x][$y]["b"]=$B; |
|
297 | + $B = jpexs_freadbyte($f); |
|
298 | + $G = jpexs_freadbyte($f); |
|
299 | + $R = jpexs_freadbyte($f); |
|
300 | + $Ikona[$p]["Data"][$x][$y]["r"] = $R; |
|
301 | + $Ikona[$p]["Data"][$x][$y]["g"] = $G; |
|
302 | + $Ikona[$p]["Data"][$x][$y]["b"] = $B; |
|
303 | 303 | } |
304 | - for($z=0;$z<$Zbytek;$z++) |
|
304 | + for ($z = 0; $z < $Zbytek; $z++) |
|
305 | 305 | jpexs_freadbyte($f); |
306 | 306 | }; |
307 | 307 | } |
308 | -elseif($biBitCount==32) |
|
308 | +elseif ($biBitCount == 32) |
|
309 | 309 | { |
310 | - $Zbytek=$Width%4; |
|
310 | + $Zbytek = $Width % 4; |
|
311 | 311 | |
312 | - for($y=$Height-1;$y>=0;$y--) |
|
312 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
313 | 313 | { |
314 | - for($x=0;$x<$Width;$x++) |
|
314 | + for ($x = 0; $x < $Width; $x++) |
|
315 | 315 | { |
316 | - $B=jpexs_freadbyte($f); |
|
317 | - $G=jpexs_freadbyte($f); |
|
318 | - $R=jpexs_freadbyte($f); |
|
319 | - $Alpha=jpexs_freadbyte($f); |
|
320 | - $Ikona[$p]["Data"][$x][$y]["r"]=$R; |
|
321 | - $Ikona[$p]["Data"][$x][$y]["g"]=$G; |
|
322 | - $Ikona[$p]["Data"][$x][$y]["b"]=$B; |
|
323 | - $Ikona[$p]["Data"][$x][$y]["alpha"]=$Alpha; |
|
316 | + $B = jpexs_freadbyte($f); |
|
317 | + $G = jpexs_freadbyte($f); |
|
318 | + $R = jpexs_freadbyte($f); |
|
319 | + $Alpha = jpexs_freadbyte($f); |
|
320 | + $Ikona[$p]["Data"][$x][$y]["r"] = $R; |
|
321 | + $Ikona[$p]["Data"][$x][$y]["g"] = $G; |
|
322 | + $Ikona[$p]["Data"][$x][$y]["b"] = $B; |
|
323 | + $Ikona[$p]["Data"][$x][$y]["alpha"] = $Alpha; |
|
324 | 324 | } |
325 | - for($z=0;$z<$Zbytek;$z++) |
|
325 | + for ($z = 0; $z < $Zbytek; $z++) |
|
326 | 326 | jpexs_freadbyte($f); |
327 | 327 | }; |
328 | 328 | }; |
329 | 329 | |
330 | 330 | |
331 | 331 | //Maska |
332 | -$Zbytek=(4-ceil(($Width/(8)))%4)%4; |
|
333 | -for($y=$Height-1;$y>=0;$y--) |
|
332 | +$Zbytek = (4 - ceil(($Width / (8))) % 4) % 4; |
|
333 | +for ($y = $Height - 1; $y >= 0; $y--) |
|
334 | 334 | { |
335 | - $jpexs_currentBit=0; |
|
336 | - for($x=0;$x<$Width;$x++) |
|
335 | + $jpexs_currentBit = 0; |
|
336 | + for ($x = 0; $x < $Width; $x++) |
|
337 | 337 | { |
338 | - $C=jpexs_freadbits($f,1); |
|
339 | - $Ikona[$p]["Maska"][$x][$y]=$C; |
|
338 | + $C = jpexs_freadbits($f, 1); |
|
339 | + $Ikona[$p]["Maska"][$x][$y] = $C; |
|
340 | 340 | }; |
341 | - if($jpexs_currentBit!=0) {jpexs_freadbyte($f);}; |
|
342 | - for($g=0;$g<$Zbytek;$g++) |
|
341 | + if ($jpexs_currentBit != 0) {jpexs_freadbyte($f); }; |
|
342 | + for ($g = 0; $g < $Zbytek; $g++) |
|
343 | 343 | jpexs_freadbyte($f); |
344 | 344 | }; |
345 | 345 | //-------------- |
@@ -352,28 +352,28 @@ discard block |
||
352 | 352 | { |
353 | 353 | global $jpexs_currentBit; |
354 | 354 | |
355 | -$f=fopen($filename,"rb"); |
|
355 | +$f = fopen($filename, "rb"); |
|
356 | 356 | |
357 | -$Reserved=jpexs_freadword($f); |
|
358 | -$Type=jpexs_freadword($f); |
|
359 | -$Count=jpexs_freadword($f); |
|
360 | -for($p=0;$p<$Count;$p++) |
|
357 | +$Reserved = jpexs_freadword($f); |
|
358 | +$Type = jpexs_freadword($f); |
|
359 | +$Count = jpexs_freadword($f); |
|
360 | +for ($p = 0; $p < $Count; $p++) |
|
361 | 361 | { |
362 | - $Ikona[$p]["Width"]=jpexs_freadbyte($f); |
|
363 | - $Ikona[$p]["Height"]=jpexs_freadbyte($f); |
|
364 | - $Ikona[$p]["ColorCount"]=jpexs_freadword($f); |
|
365 | - if($Ikona[$p]["ColorCount"]==0) $Ikona[$p]["ColorCount"]=256; |
|
366 | - $Ikona[$p]["Planes"]=jpexs_freadword($f); |
|
367 | - $Ikona[$p]["BitCount"]=jpexs_freadword($f); |
|
368 | - $Ikona[$p]["BytesInRes"]=jpexs_freaddword($f); |
|
369 | - $Ikona[$p]["ImageOffset"]=jpexs_freaddword($f); |
|
362 | + $Ikona[$p]["Width"] = jpexs_freadbyte($f); |
|
363 | + $Ikona[$p]["Height"] = jpexs_freadbyte($f); |
|
364 | + $Ikona[$p]["ColorCount"] = jpexs_freadword($f); |
|
365 | + if ($Ikona[$p]["ColorCount"] == 0) $Ikona[$p]["ColorCount"] = 256; |
|
366 | + $Ikona[$p]["Planes"] = jpexs_freadword($f); |
|
367 | + $Ikona[$p]["BitCount"] = jpexs_freadword($f); |
|
368 | + $Ikona[$p]["BytesInRes"] = jpexs_freaddword($f); |
|
369 | + $Ikona[$p]["ImageOffset"] = jpexs_freaddword($f); |
|
370 | 370 | }; |
371 | 371 | |
372 | -if(!feof($f)): |
|
373 | - for($p=0;$p<$Count;$p++) |
|
372 | +if (!feof($f)): |
|
373 | + for ($p = 0; $p < $Count; $p++) |
|
374 | 374 | { |
375 | - fseek($f,$Ikona[$p]["ImageOffset"]+14); |
|
376 | - $Ikona[$p]["Info"]["BitsPerPixel"]=jpexs_freadword($f); |
|
375 | + fseek($f, $Ikona[$p]["ImageOffset"] + 14); |
|
376 | + $Ikona[$p]["Info"]["BitsPerPixel"] = jpexs_freadword($f); |
|
377 | 377 | }; |
378 | 378 | endif; |
379 | 379 | fclose($f); |
@@ -394,13 +394,13 @@ discard block |
||
394 | 394 | * @param int $alphaBgB Background color B value for alpha-channel images (Default is White) |
395 | 395 | * @return resource Image resource or false on error |
396 | 396 | */ |
397 | -function imageCreateFromExeIco($filename,$icoIndex,$icoColorCount=16,$icoSize=16,$alphaBgR=255,$alphaBgG=255,$alphaBgB=255) |
|
397 | +function imageCreateFromExeIco($filename, $icoIndex, $icoColorCount = 16, $icoSize = 16, $alphaBgR = 255, $alphaBgG = 255, $alphaBgB = 255) |
|
398 | 398 | { |
399 | - $ok=saveExeIcon($filename,"icotemp.dat",$icoIndex); |
|
400 | - if(!$ok): |
|
401 | - $im=false; |
|
399 | + $ok = saveExeIcon($filename, "icotemp.dat", $icoIndex); |
|
400 | + if (!$ok): |
|
401 | + $im = false; |
|
402 | 402 | else: |
403 | - $im=imageCreateFromIco("icotemp.dat",$icoColorCount,$icoSize,$alphaBgR,$alphaBgG,$alphaBgB); |
|
403 | + $im = imageCreateFromIco("icotemp.dat", $icoColorCount, $icoSize, $alphaBgR, $alphaBgG, $alphaBgB); |
|
404 | 404 | unlink("icotemp.dat"); |
405 | 405 | endif; |
406 | 406 | return $im; |
@@ -417,77 +417,77 @@ discard block |
||
417 | 417 | * @param int|array $iconIndex Index(es) of the icon in exefile (Default -1) If -1, all icons are saved, Can be an array of indexes. |
418 | 418 | * @return boolean True on successful save |
419 | 419 | */ |
420 | -function saveExeIcon($filename,$icoFileNameOrPath="",$iconIndex=-1) /*-1 for all,or can be array*/ |
|
421 | -{ |
|
422 | - global $jpexs_f,$jpexs_StartOfRsrc,$jpexs_ImageBase,$jpexs_ResVirtualAddress; |
|
423 | - $jpexs_f=fopen($filename,"r"); |
|
424 | - $MZ=fread($jpexs_f,2); |
|
425 | - if($MZ!="MZ") NotValidExe(); |
|
426 | - fseek($jpexs_f,60); |
|
427 | - $OffsetToNewHeader=jpexs_freaddword($jpexs_f); |
|
428 | - fseek($jpexs_f,$OffsetToNewHeader); |
|
429 | - $PE=fread($jpexs_f,2); |
|
430 | - if($PE!="PE") NotValidExe(); |
|
431 | - fread($jpexs_f,4); |
|
432 | - $NumberOfSections=jpexs_freadword($jpexs_f); |
|
433 | - fseek($jpexs_f,ftell($jpexs_f)+12); |
|
434 | - $SizeOfOptionalHeader=jpexs_freadword($jpexs_f); |
|
435 | - $PosMagic=ftell($jpexs_f)+2; |
|
436 | - fseek($jpexs_f,$PosMagic+$SizeOfOptionalHeader); |
|
437 | - |
|
438 | - for($p=0;$p<$NumberOfSections;$p++): |
|
439 | - $SectionName[$p]=trim(fread($jpexs_f,8)); |
|
440 | - $VirtualSize[$p]=jpexs_freaddword($jpexs_f); |
|
441 | - $VirtualAddress[$p]=jpexs_freaddword($jpexs_f); |
|
442 | - $PhysicalSize[$p]=jpexs_freaddword($jpexs_f); |
|
443 | - $PhysicalOffset[$p]=jpexs_freaddword($jpexs_f); |
|
444 | - fread($jpexs_f,16); |
|
445 | - if($SectionName[$p]==".rsrc"): |
|
446 | - $jpexs_ResVirtualAddress=$VirtualAddress[$p]; |
|
447 | - fseek($jpexs_f,$PhysicalOffset[$p]); |
|
448 | - $jpexs_StartOfRsrc=$PhysicalOffset[$p]; |
|
449 | - jpexs_readResDirectoryEntry($R,$PhysicalOffset[$p]); |
|
450 | - $IconCount=null; |
|
451 | - $Ikona=null; |
|
452 | - while (list ($key, $val) = each ($R["Subdir"])): |
|
453 | - if($key==14): |
|
454 | - $r=0; |
|
455 | - while (list ($key2, $val2) = each ($R["Subdir"][$key]["Subdir"])): |
|
456 | - while (list ($key3, $val3) = each ($R["Subdir"][$key]["Subdir"][$key2]["Subdir"])): |
|
457 | - fseek($jpexs_f,$val3["DataOffset"]); |
|
458 | - $Reserved=jpexs_freadword($jpexs_f); |
|
459 | - $Type=jpexs_freadword($jpexs_f); |
|
460 | - $ic=jpexs_freadword($jpexs_f); |
|
461 | - $IconCount[]=$ic; |
|
462 | - for($s=0;$s<$ic;$s++) |
|
420 | +function saveExeIcon($filename, $icoFileNameOrPath = "", $iconIndex = -1) /*-1 for all,or can be array*/ |
|
421 | +{ |
|
422 | + global $jpexs_f, $jpexs_StartOfRsrc, $jpexs_ImageBase, $jpexs_ResVirtualAddress; |
|
423 | + $jpexs_f = fopen($filename, "r"); |
|
424 | + $MZ = fread($jpexs_f, 2); |
|
425 | + if ($MZ != "MZ") NotValidExe(); |
|
426 | + fseek($jpexs_f, 60); |
|
427 | + $OffsetToNewHeader = jpexs_freaddword($jpexs_f); |
|
428 | + fseek($jpexs_f, $OffsetToNewHeader); |
|
429 | + $PE = fread($jpexs_f, 2); |
|
430 | + if ($PE != "PE") NotValidExe(); |
|
431 | + fread($jpexs_f, 4); |
|
432 | + $NumberOfSections = jpexs_freadword($jpexs_f); |
|
433 | + fseek($jpexs_f, ftell($jpexs_f) + 12); |
|
434 | + $SizeOfOptionalHeader = jpexs_freadword($jpexs_f); |
|
435 | + $PosMagic = ftell($jpexs_f) + 2; |
|
436 | + fseek($jpexs_f, $PosMagic + $SizeOfOptionalHeader); |
|
437 | + |
|
438 | + for ($p = 0; $p < $NumberOfSections; $p++): |
|
439 | + $SectionName[$p] = trim(fread($jpexs_f, 8)); |
|
440 | + $VirtualSize[$p] = jpexs_freaddword($jpexs_f); |
|
441 | + $VirtualAddress[$p] = jpexs_freaddword($jpexs_f); |
|
442 | + $PhysicalSize[$p] = jpexs_freaddword($jpexs_f); |
|
443 | + $PhysicalOffset[$p] = jpexs_freaddword($jpexs_f); |
|
444 | + fread($jpexs_f, 16); |
|
445 | + if ($SectionName[$p] == ".rsrc"): |
|
446 | + $jpexs_ResVirtualAddress = $VirtualAddress[$p]; |
|
447 | + fseek($jpexs_f, $PhysicalOffset[$p]); |
|
448 | + $jpexs_StartOfRsrc = $PhysicalOffset[$p]; |
|
449 | + jpexs_readResDirectoryEntry($R, $PhysicalOffset[$p]); |
|
450 | + $IconCount = null; |
|
451 | + $Ikona = null; |
|
452 | + while (list ($key, $val) = each($R["Subdir"])): |
|
453 | + if ($key == 14): |
|
454 | + $r = 0; |
|
455 | + while (list ($key2, $val2) = each($R["Subdir"][$key]["Subdir"])): |
|
456 | + while (list ($key3, $val3) = each($R["Subdir"][$key]["Subdir"][$key2]["Subdir"])): |
|
457 | + fseek($jpexs_f, $val3["DataOffset"]); |
|
458 | + $Reserved = jpexs_freadword($jpexs_f); |
|
459 | + $Type = jpexs_freadword($jpexs_f); |
|
460 | + $ic = jpexs_freadword($jpexs_f); |
|
461 | + $IconCount[] = $ic; |
|
462 | + for ($s = 0; $s < $ic; $s++) |
|
463 | 463 | { |
464 | - $Ikona[$r][$s]["Width"]=jpexs_freadbyte($jpexs_f); |
|
465 | - $Ikona[$r][$s]["Height"]=jpexs_freadbyte($jpexs_f); |
|
466 | - $Ikona[$r][$s]["ColorCount"]=jpexs_freadword($jpexs_f); |
|
467 | - $Ikona[$r][$s]["Planes"]=jpexs_freadword($jpexs_f); |
|
468 | - $Ikona[$r][$s]["BitCount"]=jpexs_freadword($jpexs_f); |
|
469 | - $Ikona[$r][$s]["BytesInRes"]=jpexs_freaddword($jpexs_f); |
|
470 | - $Ikona[$r][$s]["IconId"]=jpexs_freadword($jpexs_f); |
|
464 | + $Ikona[$r][$s]["Width"] = jpexs_freadbyte($jpexs_f); |
|
465 | + $Ikona[$r][$s]["Height"] = jpexs_freadbyte($jpexs_f); |
|
466 | + $Ikona[$r][$s]["ColorCount"] = jpexs_freadword($jpexs_f); |
|
467 | + $Ikona[$r][$s]["Planes"] = jpexs_freadword($jpexs_f); |
|
468 | + $Ikona[$r][$s]["BitCount"] = jpexs_freadword($jpexs_f); |
|
469 | + $Ikona[$r][$s]["BytesInRes"] = jpexs_freaddword($jpexs_f); |
|
470 | + $Ikona[$r][$s]["IconId"] = jpexs_freadword($jpexs_f); |
|
471 | 471 | }; |
472 | - fseek($jpexs_f,$val3["DataOffset"]); |
|
472 | + fseek($jpexs_f, $val3["DataOffset"]); |
|
473 | 473 | $r++; |
474 | 474 | endwhile; |
475 | 475 | endwhile; |
476 | 476 | endif; |
477 | 477 | endwhile; |
478 | 478 | |
479 | - reset ($R["Subdir"]); |
|
480 | - |
|
481 | - while (list ($key, $val) = each ($R["Subdir"])): |
|
482 | - if($key==3): |
|
483 | - while (list ($key2, $val2) = each ($R["Subdir"][$key]["Subdir"])): |
|
484 | - for($r=0;$r<count($Ikona);$r++): |
|
485 | - for($s=0;$s<count($Ikona[$r]);$s++): |
|
486 | - while (list ($key3, $val3) = each ($R["Subdir"][$key]["Subdir"][$Ikona[$r][$s]["IconId"]]["Subdir"])): |
|
487 | - if(($iconIndex==$r)or($iconIndex==-1)or((is_array($iconIndex))and(in_array($r,$iconIndex)))): |
|
488 | - fseek($jpexs_f,$val3["DataOffset"]); |
|
489 | - $Ikona[$r][$s]["Data"]=fread($jpexs_f,$val3["DataSize"]); |
|
490 | - $Ikona[$r][$s]["DataSize"]=$val3["DataSize"]; |
|
479 | + reset($R["Subdir"]); |
|
480 | + |
|
481 | + while (list ($key, $val) = each($R["Subdir"])): |
|
482 | + if ($key == 3): |
|
483 | + while (list ($key2, $val2) = each($R["Subdir"][$key]["Subdir"])): |
|
484 | + for ($r = 0; $r < count($Ikona); $r++): |
|
485 | + for ($s = 0; $s < count($Ikona[$r]); $s++): |
|
486 | + while (list ($key3, $val3) = each($R["Subdir"][$key]["Subdir"][$Ikona[$r][$s]["IconId"]]["Subdir"])): |
|
487 | + if (($iconIndex == $r) or ($iconIndex == -1) or ((is_array($iconIndex)) and (in_array($r, $iconIndex)))): |
|
488 | + fseek($jpexs_f, $val3["DataOffset"]); |
|
489 | + $Ikona[$r][$s]["Data"] = fread($jpexs_f, $val3["DataSize"]); |
|
490 | + $Ikona[$r][$s]["DataSize"] = $val3["DataSize"]; |
|
491 | 491 | endif; |
492 | 492 | endwhile; |
493 | 493 | endfor; |
@@ -495,39 +495,39 @@ discard block |
||
495 | 495 | endwhile; |
496 | 496 | endif; |
497 | 497 | endwhile; |
498 | - $ok=false; |
|
499 | - for($r=0;$r<count($Ikona);$r++): |
|
500 | - if(($iconIndex==$r)or($iconIndex==-1)or((is_array($iconIndex))and(in_array($r,$iconIndex)))): |
|
501 | - $savefile=$icoFileNameOrPath; |
|
502 | - if($icoFileNameOrPath=="") |
|
498 | + $ok = false; |
|
499 | + for ($r = 0; $r < count($Ikona); $r++): |
|
500 | + if (($iconIndex == $r) or ($iconIndex == -1) or ((is_array($iconIndex)) and (in_array($r, $iconIndex)))): |
|
501 | + $savefile = $icoFileNameOrPath; |
|
502 | + if ($icoFileNameOrPath == "") |
|
503 | 503 | { |
504 | - $savefile="$r.ico"; |
|
504 | + $savefile = "$r.ico"; |
|
505 | 505 | } |
506 | 506 | else |
507 | 507 | { |
508 | - if(($iconIndex==-1)or(is_array($iconIndex))) |
|
509 | - $savefile=$icoFileNameOrPath."$r.ico"; |
|
508 | + if (($iconIndex == -1) or (is_array($iconIndex))) |
|
509 | + $savefile = $icoFileNameOrPath."$r.ico"; |
|
510 | 510 | }; |
511 | - $f2=fopen($savefile,"w"); |
|
512 | - fwrite($f2,jpexs_inttoword(0)); |
|
513 | - fwrite($f2,jpexs_inttoword(1)); |
|
514 | - fwrite($f2,jpexs_inttoword(count($Ikona[$r]))); |
|
515 | - $Offset=6+16*count($Ikona[$r]); |
|
516 | - for($s=0;$s<count($Ikona[$r]);$s++): |
|
517 | - fwrite($f2,jpexs_inttobyte($Ikona[$r][$s]["Width"])); |
|
518 | - fwrite($f2,jpexs_inttobyte($Ikona[$r][$s]["Height"])); |
|
519 | - fwrite($f2,jpexs_inttoword($Ikona[$r][$s]["ColorCount"])); |
|
520 | - fwrite($f2,jpexs_inttoword($Ikona[$r][$s]["Planes"])); |
|
521 | - fwrite($f2,jpexs_inttoword($Ikona[$r][$s]["BitCount"])); |
|
522 | - fwrite($f2,jpexs_inttodword($Ikona[$r][$s]["BytesInRes"])); |
|
523 | - fwrite($f2,jpexs_inttodword($Offset)); |
|
524 | - $Offset+=$Ikona[$r][$s]["DataSize"]; |
|
511 | + $f2 = fopen($savefile, "w"); |
|
512 | + fwrite($f2, jpexs_inttoword(0)); |
|
513 | + fwrite($f2, jpexs_inttoword(1)); |
|
514 | + fwrite($f2, jpexs_inttoword(count($Ikona[$r]))); |
|
515 | + $Offset = 6 + 16 * count($Ikona[$r]); |
|
516 | + for ($s = 0; $s < count($Ikona[$r]); $s++): |
|
517 | + fwrite($f2, jpexs_inttobyte($Ikona[$r][$s]["Width"])); |
|
518 | + fwrite($f2, jpexs_inttobyte($Ikona[$r][$s]["Height"])); |
|
519 | + fwrite($f2, jpexs_inttoword($Ikona[$r][$s]["ColorCount"])); |
|
520 | + fwrite($f2, jpexs_inttoword($Ikona[$r][$s]["Planes"])); |
|
521 | + fwrite($f2, jpexs_inttoword($Ikona[$r][$s]["BitCount"])); |
|
522 | + fwrite($f2, jpexs_inttodword($Ikona[$r][$s]["BytesInRes"])); |
|
523 | + fwrite($f2, jpexs_inttodword($Offset)); |
|
524 | + $Offset += $Ikona[$r][$s]["DataSize"]; |
|
525 | 525 | endfor; |
526 | - for($s=0;$s<count($Ikona[$r]);$s++): |
|
527 | - fwrite($f2,$Ikona[$r][$s]["Data"]); |
|
526 | + for ($s = 0; $s < count($Ikona[$r]); $s++): |
|
527 | + fwrite($f2, $Ikona[$r][$s]["Data"]); |
|
528 | 528 | endfor; |
529 | 529 | fclose($f2); |
530 | - $ok=true; |
|
530 | + $ok = true; |
|
531 | 531 | endif; |
532 | 532 | endfor; |
533 | 533 | return $ok; |
@@ -540,212 +540,212 @@ discard block |
||
540 | 540 | /** |
541 | 541 | * Internal function for reading exe icons |
542 | 542 | */ |
543 | -function jpexs_readResDirectoryEntry(&$parentRes,$offset) |
|
543 | +function jpexs_readResDirectoryEntry(&$parentRes, $offset) |
|
544 | 544 | { |
545 | -global $jpexs_f,$jpexs_StartOfRsrc,$jpexs_ImageBase,$jpexs_ResVirtualAddress; |
|
546 | -$lastPos=ftell($jpexs_f); |
|
547 | -$Res=null; |
|
548 | -fseek($jpexs_f,$offset); |
|
545 | +global $jpexs_f, $jpexs_StartOfRsrc, $jpexs_ImageBase, $jpexs_ResVirtualAddress; |
|
546 | +$lastPos = ftell($jpexs_f); |
|
547 | +$Res = null; |
|
548 | +fseek($jpexs_f, $offset); |
|
549 | 549 | //IMAGE_RESOURCE_DIRECTORY |
550 | - $Characteristics=jpexs_freaddword($jpexs_f); |
|
551 | - $TimeDateStamp=jpexs_freaddword($jpexs_f); |
|
552 | - $MajorVersion=jpexs_freadword($jpexs_f); |
|
553 | - $MinorVersion=jpexs_freadword($jpexs_f); |
|
554 | - $NumberOfNamedEntries=jpexs_freadword($jpexs_f); |
|
555 | - $NumberOfIdEntries=jpexs_freadword($jpexs_f); |
|
556 | - for($q=0;$q<$NumberOfNamedEntries+$NumberOfIdEntries;$q++): |
|
550 | + $Characteristics = jpexs_freaddword($jpexs_f); |
|
551 | + $TimeDateStamp = jpexs_freaddword($jpexs_f); |
|
552 | + $MajorVersion = jpexs_freadword($jpexs_f); |
|
553 | + $MinorVersion = jpexs_freadword($jpexs_f); |
|
554 | + $NumberOfNamedEntries = jpexs_freadword($jpexs_f); |
|
555 | + $NumberOfIdEntries = jpexs_freadword($jpexs_f); |
|
556 | + for ($q = 0; $q < $NumberOfNamedEntries + $NumberOfIdEntries; $q++): |
|
557 | 557 | //IMAGE_RESOURCE_DIRECTORY_ENTRY |
558 | - $ResName=jpexs_freaddword($jpexs_f); |
|
559 | - $lastPos2=ftell($jpexs_f); |
|
560 | - if($ResName>=0x80000000): |
|
558 | + $ResName = jpexs_freaddword($jpexs_f); |
|
559 | + $lastPos2 = ftell($jpexs_f); |
|
560 | + if ($ResName >= 0x80000000): |
|
561 | 561 | //String Name |
562 | - $ResNameOffset=$ResName-0x80000000; |
|
563 | - fseek($jpexs_f,$jpexs_StartOfRsrc+$ResNameOffset); |
|
564 | - $StringLength=jpexs_freadword($jpexs_f); |
|
565 | - $Identificator=(fread($jpexs_f,$StringLength*2)); |
|
566 | - fseek($jpexs_f,$lastPos2); |
|
562 | + $ResNameOffset = $ResName - 0x80000000; |
|
563 | + fseek($jpexs_f, $jpexs_StartOfRsrc + $ResNameOffset); |
|
564 | + $StringLength = jpexs_freadword($jpexs_f); |
|
565 | + $Identificator = (fread($jpexs_f, $StringLength * 2)); |
|
566 | + fseek($jpexs_f, $lastPos2); |
|
567 | 567 | else: |
568 | 568 | //Integer Id |
569 | - $Identificator=$ResName; |
|
569 | + $Identificator = $ResName; |
|
570 | 570 | endif; |
571 | 571 | |
572 | - $ResOffsetToData=jpexs_freaddword($jpexs_f); |
|
573 | - if($ResOffsetToData>=0x80000000): |
|
574 | - $SubResOffset=$ResOffsetToData-0x80000000; |
|
575 | - jpexs_readResDirectoryEntry($Res["$Identificator"],$jpexs_StartOfRsrc+$SubResOffset); |
|
572 | + $ResOffsetToData = jpexs_freaddword($jpexs_f); |
|
573 | + if ($ResOffsetToData >= 0x80000000): |
|
574 | + $SubResOffset = $ResOffsetToData - 0x80000000; |
|
575 | + jpexs_readResDirectoryEntry($Res["$Identificator"], $jpexs_StartOfRsrc + $SubResOffset); |
|
576 | 576 | else: |
577 | - $RawDataOffset=$ResOffsetToData; |
|
578 | - $lastPos2=ftell($jpexs_f); |
|
579 | - fseek($jpexs_f,$jpexs_StartOfRsrc+$RawDataOffset); |
|
577 | + $RawDataOffset = $ResOffsetToData; |
|
578 | + $lastPos2 = ftell($jpexs_f); |
|
579 | + fseek($jpexs_f, $jpexs_StartOfRsrc + $RawDataOffset); |
|
580 | 580 | //IMAGE_RESOURCE_DATA_ENTRY |
581 | - $OffsetToData=jpexs_freaddword($jpexs_f); |
|
582 | - $Res["$Identificator"]["DataOffset"]=$jpexs_StartOfRsrc-$jpexs_ResVirtualAddress+$OffsetToData; |
|
583 | - $Res["$Identificator"]["DataSize"]=jpexs_freaddword($jpexs_f); |
|
584 | - $CodePage=jpexs_freaddword($jpexs_f); |
|
585 | - $Reserved=jpexs_freaddword($jpexs_f); |
|
586 | - fseek($jpexs_f,$lastPos2); |
|
581 | + $OffsetToData = jpexs_freaddword($jpexs_f); |
|
582 | + $Res["$Identificator"]["DataOffset"] = $jpexs_StartOfRsrc - $jpexs_ResVirtualAddress + $OffsetToData; |
|
583 | + $Res["$Identificator"]["DataSize"] = jpexs_freaddword($jpexs_f); |
|
584 | + $CodePage = jpexs_freaddword($jpexs_f); |
|
585 | + $Reserved = jpexs_freaddword($jpexs_f); |
|
586 | + fseek($jpexs_f, $lastPos2); |
|
587 | 587 | endif; |
588 | 588 | endfor; |
589 | -fseek($jpexs_f,$lastPos); |
|
590 | -$parentRes["Subdir"]=$Res; |
|
589 | +fseek($jpexs_f, $lastPos); |
|
590 | +$parentRes["Subdir"] = $Res; |
|
591 | 591 | }; |
592 | 592 | |
593 | 593 | /** |
594 | 594 | * Creates ico file from image resource(s) |
595 | 595 | * @param resource|array $images Target Image resource (Can be array of image resources) |
596 | 596 | * @param string $filename Target ico file to save icon to, If ommited or "", image is written to snadard output - use header("Content-type: image/x-icon"); */ |
597 | -function imageIco($images,$filename="") |
|
597 | +function imageIco($images, $filename = "") |
|
598 | 598 | { |
599 | 599 | |
600 | -if(is_array($images)) |
|
600 | +if (is_array($images)) |
|
601 | 601 | { |
602 | -$ImageCount=count($images); |
|
603 | -$Image=$images; |
|
602 | +$ImageCount = count($images); |
|
603 | +$Image = $images; |
|
604 | 604 | } |
605 | 605 | else |
606 | 606 | { |
607 | -$Image[0]=$images; |
|
608 | -$ImageCount=1; |
|
607 | +$Image[0] = $images; |
|
608 | +$ImageCount = 1; |
|
609 | 609 | }; |
610 | 610 | |
611 | 611 | |
612 | -$WriteToFile=false; |
|
612 | +$WriteToFile = false; |
|
613 | 613 | |
614 | -if($filename!="") |
|
614 | +if ($filename != "") |
|
615 | 615 | { |
616 | -$WriteToFile=true; |
|
616 | +$WriteToFile = true; |
|
617 | 617 | }; |
618 | 618 | |
619 | 619 | |
620 | -$ret=""; |
|
620 | +$ret = ""; |
|
621 | 621 | |
622 | -$ret.=jpexs_inttoword(0); //PASSWORD |
|
623 | -$ret.=jpexs_inttoword(1); //SOURCE |
|
624 | -$ret.=jpexs_inttoword($ImageCount); //ICONCOUNT |
|
622 | +$ret .= jpexs_inttoword(0); //PASSWORD |
|
623 | +$ret .= jpexs_inttoword(1); //SOURCE |
|
624 | +$ret .= jpexs_inttoword($ImageCount); //ICONCOUNT |
|
625 | 625 | |
626 | 626 | |
627 | -for($q=0;$q<$ImageCount;$q++) |
|
627 | +for ($q = 0; $q < $ImageCount; $q++) |
|
628 | 628 | { |
629 | -$img=$Image[$q]; |
|
629 | +$img = $Image[$q]; |
|
630 | 630 | |
631 | -$Width=imagesx($img); |
|
632 | -$Height=imagesy($img); |
|
631 | +$Width = imagesx($img); |
|
632 | +$Height = imagesy($img); |
|
633 | 633 | |
634 | -$ColorCount=imagecolorstotal($img); |
|
634 | +$ColorCount = imagecolorstotal($img); |
|
635 | 635 | |
636 | -$Transparent=imagecolortransparent($img); |
|
637 | -$IsTransparent=$Transparent!=-1; |
|
636 | +$Transparent = imagecolortransparent($img); |
|
637 | +$IsTransparent = $Transparent != -1; |
|
638 | 638 | |
639 | 639 | |
640 | -if($IsTransparent) $ColorCount--; |
|
640 | +if ($IsTransparent) $ColorCount--; |
|
641 | 641 | |
642 | -if($ColorCount==0) {$ColorCount=0; $BitCount=24;}; |
|
643 | -if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;}; |
|
644 | -if(($ColorCount>2)and($ColorCount<=16)) { $ColorCount=16; $BitCount=4;}; |
|
645 | -if(($ColorCount>16)and($ColorCount<=256)) { $ColorCount=0; $BitCount=8;}; |
|
642 | +if ($ColorCount == 0) {$ColorCount = 0; $BitCount = 24; }; |
|
643 | +if (($ColorCount > 0) and ($ColorCount <= 2)) {$ColorCount = 2; $BitCount = 1; }; |
|
644 | +if (($ColorCount > 2) and ($ColorCount <= 16)) { $ColorCount = 16; $BitCount = 4; }; |
|
645 | +if (($ColorCount > 16) and ($ColorCount <= 256)) { $ColorCount = 0; $BitCount = 8; }; |
|
646 | 646 | |
647 | 647 | |
648 | 648 | |
649 | 649 | |
650 | 650 | |
651 | 651 | //ICONINFO: |
652 | -$ret.=jpexs_inttobyte($Width);// |
|
653 | -$ret.=jpexs_inttobyte($Height);// |
|
654 | -$ret.=jpexs_inttobyte($ColorCount);// |
|
655 | -$ret.=jpexs_inttobyte(0);//RESERVED |
|
656 | - |
|
657 | -$Planes=0; |
|
658 | -if($BitCount>=8) $Planes=1; |
|
659 | - |
|
660 | -$ret.=jpexs_inttoword($f,$Planes);//PLANES |
|
661 | -if($BitCount>=8) $WBitCount=$BitCount; |
|
662 | -if($BitCount==4) $WBitCount=0; |
|
663 | -if($BitCount==1) $WBitCount=0; |
|
664 | -$ret.=jpexs_inttoword($WBitCount);//BITS |
|
665 | - |
|
666 | -$Zbytek=(4-($Width/(8/$BitCount))%4)%4; |
|
667 | -$ZbytekMask=(4-($Width/8)%4)%4; |
|
668 | - |
|
669 | -$PalSize=0; |
|
670 | - |
|
671 | -$Size=40+($Width/(8/$BitCount)+$Zbytek)*$Height+(($Width/8+$ZbytekMask) * $Height); |
|
672 | -if($BitCount<24) |
|
673 | - $Size+=pow(2,$BitCount)*4; |
|
674 | -$IconId=1; |
|
675 | -$ret.=jpexs_inttodword($Size); //SIZE |
|
676 | -$OffSet=6+16*$ImageCount+$FullSize; |
|
677 | -$ret.=jpexs_inttodword(6+16*$ImageCount+$FullSize);//OFFSET |
|
678 | -$FullSize+=$Size; |
|
652 | +$ret .= jpexs_inttobyte($Width); // |
|
653 | +$ret .= jpexs_inttobyte($Height); // |
|
654 | +$ret .= jpexs_inttobyte($ColorCount); // |
|
655 | +$ret .= jpexs_inttobyte(0); //RESERVED |
|
656 | + |
|
657 | +$Planes = 0; |
|
658 | +if ($BitCount >= 8) $Planes = 1; |
|
659 | + |
|
660 | +$ret .= jpexs_inttoword($f, $Planes); //PLANES |
|
661 | +if ($BitCount >= 8) $WBitCount = $BitCount; |
|
662 | +if ($BitCount == 4) $WBitCount = 0; |
|
663 | +if ($BitCount == 1) $WBitCount = 0; |
|
664 | +$ret .= jpexs_inttoword($WBitCount); //BITS |
|
665 | + |
|
666 | +$Zbytek = (4 - ($Width / (8 / $BitCount)) % 4) % 4; |
|
667 | +$ZbytekMask = (4 - ($Width / 8) % 4) % 4; |
|
668 | + |
|
669 | +$PalSize = 0; |
|
670 | + |
|
671 | +$Size = 40 + ($Width / (8 / $BitCount) + $Zbytek) * $Height + (($Width / 8 + $ZbytekMask) * $Height); |
|
672 | +if ($BitCount < 24) |
|
673 | + $Size += pow(2, $BitCount) * 4; |
|
674 | +$IconId = 1; |
|
675 | +$ret .= jpexs_inttodword($Size); //SIZE |
|
676 | +$OffSet = 6 + 16 * $ImageCount + $FullSize; |
|
677 | +$ret .= jpexs_inttodword(6 + 16 * $ImageCount + $FullSize); //OFFSET |
|
678 | +$FullSize += $Size; |
|
679 | 679 | //------------- |
680 | 680 | |
681 | 681 | }; |
682 | 682 | |
683 | 683 | |
684 | -for($q=0;$q<$ImageCount;$q++) |
|
684 | +for ($q = 0; $q < $ImageCount; $q++) |
|
685 | 685 | { |
686 | -$img=$Image[$q]; |
|
687 | -$Width=imagesx($img); |
|
688 | -$Height=imagesy($img); |
|
689 | -$ColorCount=imagecolorstotal($img); |
|
686 | +$img = $Image[$q]; |
|
687 | +$Width = imagesx($img); |
|
688 | +$Height = imagesy($img); |
|
689 | +$ColorCount = imagecolorstotal($img); |
|
690 | 690 | |
691 | -$Transparent=imagecolortransparent($img); |
|
692 | -$IsTransparent=$Transparent!=-1; |
|
691 | +$Transparent = imagecolortransparent($img); |
|
692 | +$IsTransparent = $Transparent != -1; |
|
693 | 693 | |
694 | -if($IsTransparent) $ColorCount--; |
|
695 | -if($ColorCount==0) {$ColorCount=0; $BitCount=24;}; |
|
696 | -if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;}; |
|
697 | -if(($ColorCount>2)and($ColorCount<=16)) { $ColorCount=16; $BitCount=4;}; |
|
698 | -if(($ColorCount>16)and($ColorCount<=256)) { $ColorCount=0; $BitCount=8;}; |
|
694 | +if ($IsTransparent) $ColorCount--; |
|
695 | +if ($ColorCount == 0) {$ColorCount = 0; $BitCount = 24; }; |
|
696 | +if (($ColorCount > 0) and ($ColorCount <= 2)) {$ColorCount = 2; $BitCount = 1; }; |
|
697 | +if (($ColorCount > 2) and ($ColorCount <= 16)) { $ColorCount = 16; $BitCount = 4; }; |
|
698 | +if (($ColorCount > 16) and ($ColorCount <= 256)) { $ColorCount = 0; $BitCount = 8; }; |
|
699 | 699 | |
700 | 700 | |
701 | 701 | |
702 | 702 | //ICONS |
703 | -$ret.=jpexs_inttodword(40);//HEADSIZE |
|
704 | -$ret.=jpexs_inttodword($Width);// |
|
705 | -$ret.=jpexs_inttodword(2*$Height);// |
|
706 | -$ret.=jpexs_inttoword(1); //PLANES |
|
707 | -$ret.=jpexs_inttoword($BitCount); // |
|
708 | -$ret.=jpexs_inttodword(0);//Compress method |
|
703 | +$ret .= jpexs_inttodword(40); //HEADSIZE |
|
704 | +$ret .= jpexs_inttodword($Width); // |
|
705 | +$ret .= jpexs_inttodword(2 * $Height); // |
|
706 | +$ret .= jpexs_inttoword(1); //PLANES |
|
707 | +$ret .= jpexs_inttoword($BitCount); // |
|
708 | +$ret .= jpexs_inttodword(0); //Compress method |
|
709 | 709 | |
710 | 710 | |
711 | -$ZbytekMask=($Width/8)%4; |
|
711 | +$ZbytekMask = ($Width / 8) % 4; |
|
712 | 712 | |
713 | -$Zbytek=($Width/(8/$BitCount))%4; |
|
714 | -$Size=($Width/(8/$BitCount)+$Zbytek)*$Height+(($Width/8+$ZbytekMask) * $Height); |
|
713 | +$Zbytek = ($Width / (8 / $BitCount)) % 4; |
|
714 | +$Size = ($Width / (8 / $BitCount) + $Zbytek) * $Height + (($Width / 8 + $ZbytekMask) * $Height); |
|
715 | 715 | |
716 | -$ret.=jpexs_inttodword($Size);//SIZE |
|
716 | +$ret .= jpexs_inttodword($Size); //SIZE |
|
717 | 717 | |
718 | -$ret.=jpexs_inttodword(0);//HPIXEL_M |
|
719 | -$ret.=jpexs_inttodword(0);//V_PIXEL_M |
|
720 | -$ret.=jpexs_inttodword($ColorCount); //UCOLORS |
|
721 | -$ret.=jpexs_inttodword(0); //DCOLORS |
|
718 | +$ret .= jpexs_inttodword(0); //HPIXEL_M |
|
719 | +$ret .= jpexs_inttodword(0); //V_PIXEL_M |
|
720 | +$ret .= jpexs_inttodword($ColorCount); //UCOLORS |
|
721 | +$ret .= jpexs_inttodword(0); //DCOLORS |
|
722 | 722 | //--------------- |
723 | 723 | |
724 | 724 | |
725 | -$CC=$ColorCount; |
|
726 | -if($CC==0) $CC=256; |
|
725 | +$CC = $ColorCount; |
|
726 | +if ($CC == 0) $CC = 256; |
|
727 | 727 | |
728 | -if($BitCount<24) |
|
728 | +if ($BitCount < 24) |
|
729 | 729 | { |
730 | - $ColorTotal=imagecolorstotal($img); |
|
731 | - if($IsTransparent) $ColorTotal--; |
|
730 | + $ColorTotal = imagecolorstotal($img); |
|
731 | + if ($IsTransparent) $ColorTotal--; |
|
732 | 732 | |
733 | - for($p=0;$p<$ColorTotal;$p++) |
|
733 | + for ($p = 0; $p < $ColorTotal; $p++) |
|
734 | 734 | { |
735 | - $color=imagecolorsforindex($img,$p); |
|
736 | - $ret.=jpexs_inttobyte($color["blue"]); |
|
737 | - $ret.=jpexs_inttobyte($color["green"]); |
|
738 | - $ret.=jpexs_inttobyte($color["red"]); |
|
739 | - $ret.=jpexs_inttobyte(0); //RESERVED |
|
735 | + $color = imagecolorsforindex($img, $p); |
|
736 | + $ret .= jpexs_inttobyte($color["blue"]); |
|
737 | + $ret .= jpexs_inttobyte($color["green"]); |
|
738 | + $ret .= jpexs_inttobyte($color["red"]); |
|
739 | + $ret .= jpexs_inttobyte(0); //RESERVED |
|
740 | 740 | }; |
741 | 741 | |
742 | - $CT=$ColorTotal; |
|
743 | - for($p=$ColorTotal;$p<$CC;$p++) |
|
742 | + $CT = $ColorTotal; |
|
743 | + for ($p = $ColorTotal; $p < $CC; $p++) |
|
744 | 744 | { |
745 | - $ret.=jpexs_inttobyte(0); |
|
746 | - $ret.=jpexs_inttobyte(0); |
|
747 | - $ret.=jpexs_inttobyte(0); |
|
748 | - $ret.=jpexs_inttobyte(0); //RESERVED |
|
745 | + $ret .= jpexs_inttobyte(0); |
|
746 | + $ret .= jpexs_inttobyte(0); |
|
747 | + $ret .= jpexs_inttobyte(0); |
|
748 | + $ret .= jpexs_inttobyte(0); //RESERVED |
|
749 | 749 | }; |
750 | 750 | }; |
751 | 751 | |
@@ -754,88 +754,88 @@ discard block |
||
754 | 754 | |
755 | 755 | |
756 | 756 | |
757 | -if($BitCount<=8) |
|
757 | +if ($BitCount <= 8) |
|
758 | 758 | { |
759 | 759 | |
760 | - for($y=$Height-1;$y>=0;$y--) |
|
760 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
761 | 761 | { |
762 | - $bWrite=""; |
|
763 | - for($x=0;$x<$Width;$x++) |
|
762 | + $bWrite = ""; |
|
763 | + for ($x = 0; $x < $Width; $x++) |
|
764 | 764 | { |
765 | - $color=imagecolorat($img,$x,$y); |
|
766 | - if($color==$Transparent) |
|
767 | - $color=imagecolorexact($img,0,0,0); |
|
768 | - if($color==-1) $color=0; |
|
769 | - if($color>pow(2,$BitCount)-1) $color=0; |
|
770 | - |
|
771 | - $bWrite.=jpexs_decbinx($color,$BitCount); |
|
772 | - if(strlen($bWrite)==8) |
|
765 | + $color = imagecolorat($img, $x, $y); |
|
766 | + if ($color == $Transparent) |
|
767 | + $color = imagecolorexact($img, 0, 0, 0); |
|
768 | + if ($color == -1) $color = 0; |
|
769 | + if ($color > pow(2, $BitCount) - 1) $color = 0; |
|
770 | + |
|
771 | + $bWrite .= jpexs_decbinx($color, $BitCount); |
|
772 | + if (strlen($bWrite) == 8) |
|
773 | 773 | { |
774 | - $ret.=jpexs_inttobyte(bindec($bWrite)); |
|
775 | - $bWrite=""; |
|
774 | + $ret .= jpexs_inttobyte(bindec($bWrite)); |
|
775 | + $bWrite = ""; |
|
776 | 776 | }; |
777 | 777 | }; |
778 | 778 | |
779 | - if((strlen($bWrite)<8)and(strlen($bWrite)!=0)) |
|
779 | + if ((strlen($bWrite) < 8) and (strlen($bWrite) != 0)) |
|
780 | 780 | { |
781 | - $sl=strlen($bWrite); |
|
782 | - for($t=0;$t<8-$sl;$t++) |
|
783 | - $sl.="0"; |
|
784 | - $ret.=jpexs_inttobyte(bindec($bWrite)); |
|
781 | + $sl = strlen($bWrite); |
|
782 | + for ($t = 0; $t < 8 - $sl; $t++) |
|
783 | + $sl .= "0"; |
|
784 | + $ret .= jpexs_inttobyte(bindec($bWrite)); |
|
785 | 785 | }; |
786 | - for($z=0;$z<$Zbytek;$z++) |
|
787 | - $ret.=jpexs_inttobyte(0); |
|
786 | + for ($z = 0; $z < $Zbytek; $z++) |
|
787 | + $ret .= jpexs_inttobyte(0); |
|
788 | 788 | }; |
789 | 789 | }; |
790 | 790 | |
791 | 791 | |
792 | 792 | |
793 | -if($BitCount>=24) |
|
793 | +if ($BitCount >= 24) |
|
794 | 794 | { |
795 | - for($y=$Height-1;$y>=0;$y--) |
|
795 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
796 | 796 | { |
797 | - for($x=0;$x<$Width;$x++) |
|
797 | + for ($x = 0; $x < $Width; $x++) |
|
798 | 798 | { |
799 | - $color=imagecolorsforindex($img,imagecolorat($img,$x,$y)); |
|
800 | - $ret.=jpexs_inttobyte($color["blue"]); |
|
801 | - $ret.=jpexs_inttobyte($color["green"]); |
|
802 | - $ret.=jpexs_inttobyte($color["red"]); |
|
803 | - if($BitCount==32) |
|
804 | - $ret.=jpexs_inttobyte(0);//Alpha for ICO_XP_COLORS |
|
799 | + $color = imagecolorsforindex($img, imagecolorat($img, $x, $y)); |
|
800 | + $ret .= jpexs_inttobyte($color["blue"]); |
|
801 | + $ret .= jpexs_inttobyte($color["green"]); |
|
802 | + $ret .= jpexs_inttobyte($color["red"]); |
|
803 | + if ($BitCount == 32) |
|
804 | + $ret .= jpexs_inttobyte(0); //Alpha for ICO_XP_COLORS |
|
805 | 805 | }; |
806 | - for($z=0;$z<$Zbytek;$z++) |
|
807 | - $ret.=jpexs_inttobyte(0); |
|
806 | + for ($z = 0; $z < $Zbytek; $z++) |
|
807 | + $ret .= jpexs_inttobyte(0); |
|
808 | 808 | }; |
809 | 809 | }; |
810 | 810 | |
811 | 811 | |
812 | 812 | //MASK |
813 | 813 | |
814 | - for($y=$Height-1;$y>=0;$y--) |
|
814 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
815 | 815 | { |
816 | - $byteCount=0; |
|
817 | - $bOut=""; |
|
818 | - for($x=0;$x<$Width;$x++) |
|
816 | + $byteCount = 0; |
|
817 | + $bOut = ""; |
|
818 | + for ($x = 0; $x < $Width; $x++) |
|
819 | 819 | { |
820 | - if(($Transparent!=-1)and(imagecolorat($img,$x,$y)==$Transparent)) |
|
820 | + if (($Transparent != -1) and (imagecolorat($img, $x, $y) == $Transparent)) |
|
821 | 821 | { |
822 | - $bOut.="1"; |
|
822 | + $bOut .= "1"; |
|
823 | 823 | } |
824 | 824 | else |
825 | 825 | { |
826 | - $bOut.="0"; |
|
826 | + $bOut .= "0"; |
|
827 | 827 | }; |
828 | 828 | }; |
829 | - for($p=0;$p<strlen($bOut);$p+=8) |
|
829 | + for ($p = 0; $p < strlen($bOut); $p += 8) |
|
830 | 830 | { |
831 | - $byte=bindec(substr($bOut,$p,8)); |
|
831 | + $byte = bindec(substr($bOut, $p, 8)); |
|
832 | 832 | $byteCount++; |
833 | - $ret.=jpexs_inttobyte($byte); |
|
833 | + $ret .= jpexs_inttobyte($byte); |
|
834 | 834 | }; |
835 | - $Zbytek=$byteCount%4; |
|
836 | - for($z=0;$z<$Zbytek;$z++) |
|
835 | + $Zbytek = $byteCount % 4; |
|
836 | + for ($z = 0; $z < $Zbytek; $z++) |
|
837 | 837 | { |
838 | - $ret.=jpexs_inttobyte(0xff); |
|
838 | + $ret .= jpexs_inttobyte(0xff); |
|
839 | 839 | }; |
840 | 840 | }; |
841 | 841 | |
@@ -847,10 +847,10 @@ discard block |
||
847 | 847 | |
848 | 848 | |
849 | 849 | |
850 | -if($WriteToFile) |
|
850 | +if ($WriteToFile) |
|
851 | 851 | { |
852 | - $f=fopen($filename,"w"); |
|
853 | - fwrite($f,$ret); |
|
852 | + $f = fopen($filename, "w"); |
|
853 | + fwrite($f, $ret); |
|
854 | 854 | fclose($f); |
855 | 855 | } |
856 | 856 | else |
@@ -881,57 +881,57 @@ discard block |
||
881 | 881 | |
882 | 882 | function jpexs_decbin8($d) |
883 | 883 | { |
884 | -return jpexs_decbinx($d,8); |
|
884 | +return jpexs_decbinx($d, 8); |
|
885 | 885 | }; |
886 | 886 | |
887 | -function jpexs_decbinx($d,$n) |
|
887 | +function jpexs_decbinx($d, $n) |
|
888 | 888 | { |
889 | -$bin=decbin($d); |
|
890 | -$sbin=strlen($bin); |
|
891 | -for($j=0;$j<$n-$sbin;$j++) |
|
892 | - $bin="0$bin"; |
|
889 | +$bin = decbin($d); |
|
890 | +$sbin = strlen($bin); |
|
891 | +for ($j = 0; $j < $n - $sbin; $j++) |
|
892 | + $bin = "0$bin"; |
|
893 | 893 | return $bin; |
894 | 894 | }; |
895 | 895 | |
896 | -function jpexs_retBits($byte,$start,$len) |
|
896 | +function jpexs_retBits($byte, $start, $len) |
|
897 | 897 | { |
898 | -$bin=jpexs_decbin8($byte); |
|
899 | -$r=bindec(substr($bin,$start,$len)); |
|
898 | +$bin = jpexs_decbin8($byte); |
|
899 | +$r = bindec(substr($bin, $start, $len)); |
|
900 | 900 | return $r; |
901 | 901 | |
902 | 902 | }; |
903 | 903 | |
904 | 904 | |
905 | 905 | |
906 | -$jpexs_currentBit=0; |
|
907 | -function jpexs_freadbits($f,$count) |
|
906 | +$jpexs_currentBit = 0; |
|
907 | +function jpexs_freadbits($f, $count) |
|
908 | 908 | { |
909 | - global $jpexs_currentBit,$jpexs_SMode; |
|
910 | - $Byte=jpexs_freadbyte($f); |
|
911 | - $LastCBit=$jpexs_currentBit; |
|
912 | - $jpexs_currentBit+=$count; |
|
913 | - if($jpexs_currentBit==8) |
|
909 | + global $jpexs_currentBit, $jpexs_SMode; |
|
910 | + $Byte = jpexs_freadbyte($f); |
|
911 | + $LastCBit = $jpexs_currentBit; |
|
912 | + $jpexs_currentBit += $count; |
|
913 | + if ($jpexs_currentBit == 8) |
|
914 | 914 | { |
915 | - $jpexs_currentBit=0; |
|
915 | + $jpexs_currentBit = 0; |
|
916 | 916 | } |
917 | 917 | else |
918 | 918 | { |
919 | - fseek($f,ftell($f)-1); |
|
919 | + fseek($f, ftell($f) - 1); |
|
920 | 920 | }; |
921 | - return jpexs_retBits($Byte,$LastCBit,$count); |
|
921 | + return jpexs_retBits($Byte, $LastCBit, $count); |
|
922 | 922 | }; |
923 | 923 | |
924 | 924 | |
925 | 925 | function jpexs_freadbyte($f) |
926 | 926 | { |
927 | - return ord(fread($f,1)); |
|
927 | + return ord(fread($f, 1)); |
|
928 | 928 | }; |
929 | 929 | |
930 | 930 | function jpexs_freadword($f) |
931 | 931 | { |
932 | - $b1=jpexs_freadbyte($f); |
|
933 | - $b2=jpexs_freadbyte($f); |
|
934 | - return $b2*256+$b1; |
|
932 | + $b1 = jpexs_freadbyte($f); |
|
933 | + $b2 = jpexs_freadbyte($f); |
|
934 | + return $b2 * 256 + $b1; |
|
935 | 935 | }; |
936 | 936 | |
937 | 937 | |
@@ -942,9 +942,9 @@ discard block |
||
942 | 942 | |
943 | 943 | function jpexs_freaddword($f) |
944 | 944 | { |
945 | - $b1=jpexs_freadword($f); |
|
946 | - $b2=jpexs_freadword($f); |
|
947 | - return $b2*65536+$b1; |
|
945 | + $b1 = jpexs_freadword($f); |
|
946 | + $b2 = jpexs_freadword($f); |
|
947 | + return $b2 * 65536 + $b1; |
|
948 | 948 | }; |
949 | 949 | |
950 | 950 | function jpexs_inttobyte($n) |
@@ -954,12 +954,12 @@ discard block |
||
954 | 954 | |
955 | 955 | function jpexs_inttodword($n) |
956 | 956 | { |
957 | -return chr($n & 255).chr(($n >> 8) & 255).chr(($n >> 16) & 255).chr(($n >> 24) & 255); |
|
957 | +return chr($n&255).chr(($n >> 8)&255).chr(($n >> 16)&255).chr(($n >> 24)&255); |
|
958 | 958 | }; |
959 | 959 | |
960 | 960 | function jpexs_inttoword($n) |
961 | 961 | { |
962 | - return chr($n & 255).chr(($n >> 8) & 255); |
|
962 | + return chr($n&255).chr(($n >> 8)&255); |
|
963 | 963 | }; |
964 | 964 | |
965 | 965 | ?> |
966 | 966 | \ No newline at end of file |
@@ -36,165 +36,165 @@ discard block |
||
36 | 36 | * @param boolean $useRLE When true, file will be saved with RLE compression (EXPERIMENTAL) |
37 | 37 | * @return boolean True when successfully writen to specified file |
38 | 38 | */ |
39 | -function imagebmp($img,$file="",$useRLE=false) |
|
39 | +function imagebmp($img, $file = "", $useRLE = false) |
|
40 | 40 | { |
41 | 41 | |
42 | 42 | |
43 | - $ColorCount=imagecolorstotal($img); |
|
43 | + $ColorCount = imagecolorstotal($img); |
|
44 | 44 | |
45 | - $Transparent=imagecolortransparent($img); |
|
46 | - $IsTransparent=$Transparent!=-1; |
|
45 | + $Transparent = imagecolortransparent($img); |
|
46 | + $IsTransparent = $Transparent != -1; |
|
47 | 47 | |
48 | 48 | |
49 | - if($IsTransparent) $ColorCount--; |
|
49 | + if ($IsTransparent) $ColorCount--; |
|
50 | 50 | |
51 | - if($ColorCount==0) {$ColorCount=0; $BitCount=24; $palsize = 0; }; |
|
52 | - if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;}; |
|
53 | - if(($ColorCount>2)and($ColorCount<=16)) { $ColorCount=16; $BitCount=4;}; |
|
54 | - if(($ColorCount>16)and($ColorCount<=256)) { $ColorCount=0; $BitCount=8;}; |
|
51 | + if ($ColorCount == 0) {$ColorCount = 0; $BitCount = 24; $palsize = 0; }; |
|
52 | + if (($ColorCount > 0) and ($ColorCount <= 2)) {$ColorCount = 2; $BitCount = 1; }; |
|
53 | + if (($ColorCount > 2) and ($ColorCount <= 16)) { $ColorCount = 16; $BitCount = 4; }; |
|
54 | + if (($ColorCount > 16) and ($ColorCount <= 256)) { $ColorCount = 0; $BitCount = 8; }; |
|
55 | 55 | |
56 | - $Width=imagesx($img); |
|
57 | - $Height=imagesy($img); |
|
56 | + $Width = imagesx($img); |
|
57 | + $Height = imagesy($img); |
|
58 | 58 | |
59 | - $Zbytek=(4-($Width/(8/$BitCount))%4)%4; |
|
59 | + $Zbytek = (4 - ($Width / (8 / $BitCount)) % 4) % 4; |
|
60 | 60 | |
61 | - if($BitCount<24) $palsize=pow(2,$BitCount)*4; |
|
61 | + if ($BitCount < 24) $palsize = pow(2, $BitCount) * 4; |
|
62 | 62 | |
63 | - $size=(floor($Width/(8/$BitCount))+$Zbytek)*$Height+54; |
|
64 | - $size+=$palsize; |
|
65 | - $offset=54+$palsize; |
|
63 | + $size = (floor($Width / (8 / $BitCount)) + $Zbytek) * $Height + 54; |
|
64 | + $size += $palsize; |
|
65 | + $offset = 54 + $palsize; |
|
66 | 66 | |
67 | 67 | // Bitmap File Header |
68 | - $ret = 'BM'; // header (2b) |
|
69 | - $ret .= jpexs_int_to_dword($size); // size of file (4b) |
|
70 | - $ret .= jpexs_int_to_dword(0); // reserved (4b) |
|
71 | - $ret .= jpexs_int_to_dword($offset); // byte location in the file which is first byte of IMAGE (4b) |
|
68 | + $ret = 'BM'; // header (2b) |
|
69 | + $ret .= jpexs_int_to_dword($size); // size of file (4b) |
|
70 | + $ret .= jpexs_int_to_dword(0); // reserved (4b) |
|
71 | + $ret .= jpexs_int_to_dword($offset); // byte location in the file which is first byte of IMAGE (4b) |
|
72 | 72 | // Bitmap Info Header |
73 | - $ret .= jpexs_int_to_dword(40); // Size of BITMAPINFOHEADER (4b) |
|
74 | - $ret .= jpexs_int_to_dword($Width); // width of bitmap (4b) |
|
75 | - $ret .= jpexs_int_to_dword($Height); // height of bitmap (4b) |
|
76 | - $ret .= jpexs_int_to_word(1); // biPlanes = 1 (2b) |
|
77 | - $ret .= jpexs_int_to_word($BitCount); // biBitCount = {1 (mono) or 4 (16 clr ) or 8 (256 clr) or 24 (16 Mil)} (2b) |
|
78 | - $ret .= jpexs_int_to_dword($useRLE); // RLE COMPRESSION (4b) |
|
79 | - $ret .= jpexs_int_to_dword(0); // width x height (4b) |
|
80 | - $ret .= jpexs_int_to_dword(0); // biXPelsPerMeter (4b) |
|
81 | - $ret .= jpexs_int_to_dword(0); // biYPelsPerMeter (4b) |
|
82 | - $ret .= jpexs_int_to_dword(0); // Number of palettes used (4b) |
|
83 | - $ret .= jpexs_int_to_dword(0); // Number of important colour (4b) |
|
73 | + $ret .= jpexs_int_to_dword(40); // Size of BITMAPINFOHEADER (4b) |
|
74 | + $ret .= jpexs_int_to_dword($Width); // width of bitmap (4b) |
|
75 | + $ret .= jpexs_int_to_dword($Height); // height of bitmap (4b) |
|
76 | + $ret .= jpexs_int_to_word(1); // biPlanes = 1 (2b) |
|
77 | + $ret .= jpexs_int_to_word($BitCount); // biBitCount = {1 (mono) or 4 (16 clr ) or 8 (256 clr) or 24 (16 Mil)} (2b) |
|
78 | + $ret .= jpexs_int_to_dword($useRLE); // RLE COMPRESSION (4b) |
|
79 | + $ret .= jpexs_int_to_dword(0); // width x height (4b) |
|
80 | + $ret .= jpexs_int_to_dword(0); // biXPelsPerMeter (4b) |
|
81 | + $ret .= jpexs_int_to_dword(0); // biYPelsPerMeter (4b) |
|
82 | + $ret .= jpexs_int_to_dword(0); // Number of palettes used (4b) |
|
83 | + $ret .= jpexs_int_to_dword(0); // Number of important colour (4b) |
|
84 | 84 | // image data |
85 | 85 | |
86 | 86 | $retd = ""; |
87 | 87 | |
88 | - $CC=$ColorCount; |
|
89 | - $sl1=strlen($ret); |
|
90 | - if($CC==0) $CC=256; |
|
91 | - if($BitCount<24) |
|
88 | + $CC = $ColorCount; |
|
89 | + $sl1 = strlen($ret); |
|
90 | + if ($CC == 0) $CC = 256; |
|
91 | + if ($BitCount < 24) |
|
92 | 92 | { |
93 | - $ColorTotal=imagecolorstotal($img); |
|
94 | - if($IsTransparent) $ColorTotal--; |
|
93 | + $ColorTotal = imagecolorstotal($img); |
|
94 | + if ($IsTransparent) $ColorTotal--; |
|
95 | 95 | |
96 | - for($p=0;$p<$ColorTotal;$p++) |
|
96 | + for ($p = 0; $p < $ColorTotal; $p++) |
|
97 | 97 | { |
98 | - $color=imagecolorsforindex($img,$p); |
|
99 | - $ret.=jpexs_inttobyte($color["blue"]); |
|
100 | - $ret.=jpexs_inttobyte($color["green"]); |
|
101 | - $ret.=jpexs_inttobyte($color["red"]); |
|
102 | - $ret.=jpexs_inttobyte(0); //RESERVED |
|
98 | + $color = imagecolorsforindex($img, $p); |
|
99 | + $ret .= jpexs_inttobyte($color["blue"]); |
|
100 | + $ret .= jpexs_inttobyte($color["green"]); |
|
101 | + $ret .= jpexs_inttobyte($color["red"]); |
|
102 | + $ret .= jpexs_inttobyte(0); //RESERVED |
|
103 | 103 | }; |
104 | 104 | |
105 | - $CT=$ColorTotal; |
|
106 | - for($p=$ColorTotal;$p<$CC;$p++) |
|
105 | + $CT = $ColorTotal; |
|
106 | + for ($p = $ColorTotal; $p < $CC; $p++) |
|
107 | 107 | { |
108 | - $ret.=jpexs_inttobyte(0); |
|
109 | - $ret.=jpexs_inttobyte(0); |
|
110 | - $ret.=jpexs_inttobyte(0); |
|
111 | - $ret.=jpexs_inttobyte(0); //RESERVED |
|
108 | + $ret .= jpexs_inttobyte(0); |
|
109 | + $ret .= jpexs_inttobyte(0); |
|
110 | + $ret .= jpexs_inttobyte(0); |
|
111 | + $ret .= jpexs_inttobyte(0); //RESERVED |
|
112 | 112 | }; |
113 | 113 | }; |
114 | 114 | |
115 | 115 | |
116 | - if($BitCount<=8) |
|
116 | + if ($BitCount <= 8) |
|
117 | 117 | { |
118 | 118 | |
119 | - for($y=$Height-1;$y>=0;$y--) |
|
119 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
120 | 120 | { |
121 | - $bWrite=""; |
|
122 | - for($x=0;$x<$Width;$x++) |
|
121 | + $bWrite = ""; |
|
122 | + for ($x = 0; $x < $Width; $x++) |
|
123 | 123 | { |
124 | - $color=imagecolorat($img,$x,$y); |
|
125 | - $bWrite.=jpexs_decbinx($color,$BitCount); |
|
126 | - if(strlen($bWrite)==8) |
|
124 | + $color = imagecolorat($img, $x, $y); |
|
125 | + $bWrite .= jpexs_decbinx($color, $BitCount); |
|
126 | + if (strlen($bWrite) == 8) |
|
127 | 127 | { |
128 | - $retd.=jpexs_inttobyte(bindec($bWrite)); |
|
129 | - $bWrite=""; |
|
128 | + $retd .= jpexs_inttobyte(bindec($bWrite)); |
|
129 | + $bWrite = ""; |
|
130 | 130 | }; |
131 | 131 | }; |
132 | 132 | |
133 | - if((strlen($bWrite)<8)and(strlen($bWrite)!=0)) |
|
133 | + if ((strlen($bWrite) < 8) and (strlen($bWrite) != 0)) |
|
134 | 134 | { |
135 | - $sl=strlen($bWrite); |
|
136 | - for($t=0;$t<8-$sl;$t++) |
|
137 | - $sl.="0"; |
|
138 | - $retd.=jpexs_inttobyte(bindec($bWrite)); |
|
135 | + $sl = strlen($bWrite); |
|
136 | + for ($t = 0; $t < 8 - $sl; $t++) |
|
137 | + $sl .= "0"; |
|
138 | + $retd .= jpexs_inttobyte(bindec($bWrite)); |
|
139 | 139 | }; |
140 | - for($z=0;$z<$Zbytek;$z++) |
|
141 | - $retd.=jpexs_inttobyte(0); |
|
140 | + for ($z = 0; $z < $Zbytek; $z++) |
|
141 | + $retd .= jpexs_inttobyte(0); |
|
142 | 142 | }; |
143 | 143 | }; |
144 | 144 | |
145 | - if(($useRLE)and($BitCount==8)) |
|
145 | + if (($useRLE) and ($BitCount == 8)) |
|
146 | 146 | { |
147 | - for($t=0;$t<strlen($retd);$t+=4) |
|
147 | + for ($t = 0; $t < strlen($retd); $t += 4) |
|
148 | 148 | { |
149 | - if($t!=0) |
|
150 | - if(($t)%$Width==0) |
|
151 | - $ret.=chr(0).chr(0); |
|
149 | + if ($t != 0) |
|
150 | + if (($t) % $Width == 0) |
|
151 | + $ret .= chr(0).chr(0); |
|
152 | 152 | |
153 | - if(($t+5)%$Width==0) |
|
153 | + if (($t + 5) % $Width == 0) |
|
154 | 154 | { |
155 | - $ret.=chr(0).chr(5).substr($retd,$t,5).chr(0); |
|
156 | - $t+=1; |
|
155 | + $ret .= chr(0).chr(5).substr($retd, $t, 5).chr(0); |
|
156 | + $t += 1; |
|
157 | 157 | } |
158 | - if(($t+6)%$Width==0) |
|
158 | + if (($t + 6) % $Width == 0) |
|
159 | 159 | { |
160 | - $ret.=chr(0).chr(6).substr($retd,$t,6); |
|
161 | - $t+=2; |
|
160 | + $ret .= chr(0).chr(6).substr($retd, $t, 6); |
|
161 | + $t += 2; |
|
162 | 162 | } |
163 | 163 | else |
164 | 164 | { |
165 | - $ret.=chr(0).chr(4).substr($retd,$t,4); |
|
165 | + $ret .= chr(0).chr(4).substr($retd, $t, 4); |
|
166 | 166 | }; |
167 | 167 | }; |
168 | - $ret.=chr(0).chr(1); |
|
168 | + $ret .= chr(0).chr(1); |
|
169 | 169 | } |
170 | 170 | else |
171 | 171 | { |
172 | - $ret.=$retd; |
|
172 | + $ret .= $retd; |
|
173 | 173 | }; |
174 | 174 | |
175 | 175 | $Dopl = ""; |
176 | - if($BitCount==24) |
|
176 | + if ($BitCount == 24) |
|
177 | 177 | { |
178 | - for($z=0;$z<$Zbytek;$z++) |
|
179 | - $Dopl.=chr(0); |
|
178 | + for ($z = 0; $z < $Zbytek; $z++) |
|
179 | + $Dopl .= chr(0); |
|
180 | 180 | |
181 | - for($y=$Height-1;$y>=0;$y--) |
|
181 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
182 | 182 | { |
183 | - for($x=0;$x<$Width;$x++) |
|
183 | + for ($x = 0; $x < $Width; $x++) |
|
184 | 184 | { |
185 | - $color=imagecolorsforindex($img,ImageColorAt($img,$x,$y)); |
|
186 | - $ret.=chr($color["blue"]).chr($color["green"]).chr($color["red"]); |
|
185 | + $color = imagecolorsforindex($img, ImageColorAt($img, $x, $y)); |
|
186 | + $ret .= chr($color["blue"]).chr($color["green"]).chr($color["red"]); |
|
187 | 187 | } |
188 | - $ret.=$Dopl; |
|
188 | + $ret .= $Dopl; |
|
189 | 189 | }; |
190 | 190 | |
191 | 191 | }; |
192 | 192 | |
193 | - if($file!="") |
|
193 | + if ($file != "") |
|
194 | 194 | { |
195 | - $r=($f=fopen($file,"w")); |
|
196 | - $r=$r and fwrite($f,$ret); |
|
197 | - $r=$r and fclose($f); |
|
195 | + $r = ($f = fopen($file, "w")); |
|
196 | + $r = $r and fwrite($f, $ret); |
|
197 | + $r = $r and fclose($f); |
|
198 | 198 | return $r; |
199 | 199 | } |
200 | 200 | else |
@@ -218,58 +218,58 @@ discard block |
||
218 | 218 | { |
219 | 219 | global $jpexs_CurrentBit; |
220 | 220 | |
221 | - $f=fopen($file,"r"); |
|
222 | - $Header=fread($f,2); |
|
221 | + $f = fopen($file, "r"); |
|
222 | + $Header = fread($f, 2); |
|
223 | 223 | |
224 | - if($Header=="BM") |
|
224 | + if ($Header == "BM") |
|
225 | 225 | { |
226 | - $Size=jpexs_freaddword($f); |
|
227 | - $Reserved1=jpexs_freadword($f); |
|
228 | - $Reserved2=jpexs_freadword($f); |
|
229 | - $FirstByteOfImage=jpexs_freaddword($f); |
|
230 | - |
|
231 | - $SizeBITMAPINFOHEADER=jpexs_freaddword($f); |
|
232 | - $Width=jpexs_freaddword($f); |
|
233 | - $Height=jpexs_freaddword($f); |
|
234 | - $biPlanes=jpexs_freadword($f); |
|
235 | - $biBitCount=jpexs_freadword($f); |
|
236 | - $RLECompression=jpexs_freaddword($f); |
|
237 | - $WidthxHeight=jpexs_freaddword($f); |
|
238 | - $biXPelsPerMeter=jpexs_freaddword($f); |
|
239 | - $biYPelsPerMeter=jpexs_freaddword($f); |
|
240 | - $NumberOfPalettesUsed=jpexs_freaddword($f); |
|
241 | - $NumberOfImportantColors=jpexs_freaddword($f); |
|
242 | - |
|
243 | - if($biBitCount<24) |
|
226 | + $Size = jpexs_freaddword($f); |
|
227 | + $Reserved1 = jpexs_freadword($f); |
|
228 | + $Reserved2 = jpexs_freadword($f); |
|
229 | + $FirstByteOfImage = jpexs_freaddword($f); |
|
230 | + |
|
231 | + $SizeBITMAPINFOHEADER = jpexs_freaddword($f); |
|
232 | + $Width = jpexs_freaddword($f); |
|
233 | + $Height = jpexs_freaddword($f); |
|
234 | + $biPlanes = jpexs_freadword($f); |
|
235 | + $biBitCount = jpexs_freadword($f); |
|
236 | + $RLECompression = jpexs_freaddword($f); |
|
237 | + $WidthxHeight = jpexs_freaddword($f); |
|
238 | + $biXPelsPerMeter = jpexs_freaddword($f); |
|
239 | + $biYPelsPerMeter = jpexs_freaddword($f); |
|
240 | + $NumberOfPalettesUsed = jpexs_freaddword($f); |
|
241 | + $NumberOfImportantColors = jpexs_freaddword($f); |
|
242 | + |
|
243 | + if ($biBitCount < 24) |
|
244 | 244 | { |
245 | - $img=imagecreate($Width,$Height); |
|
246 | - $Colors=pow(2,$biBitCount); |
|
247 | - for($p=0;$p<$Colors;$p++) |
|
245 | + $img = imagecreate($Width, $Height); |
|
246 | + $Colors = pow(2, $biBitCount); |
|
247 | + for ($p = 0; $p < $Colors; $p++) |
|
248 | 248 | { |
249 | - $B=jpexs_freadbyte($f); |
|
250 | - $G=jpexs_freadbyte($f); |
|
251 | - $R=jpexs_freadbyte($f); |
|
252 | - $Reserved=jpexs_freadbyte($f); |
|
253 | - $Palette[]=imagecolorallocate($img,$R,$G,$B); |
|
249 | + $B = jpexs_freadbyte($f); |
|
250 | + $G = jpexs_freadbyte($f); |
|
251 | + $R = jpexs_freadbyte($f); |
|
252 | + $Reserved = jpexs_freadbyte($f); |
|
253 | + $Palette[] = imagecolorallocate($img, $R, $G, $B); |
|
254 | 254 | }; |
255 | 255 | |
256 | 256 | |
257 | 257 | |
258 | 258 | |
259 | - if($RLECompression==0) |
|
259 | + if ($RLECompression == 0) |
|
260 | 260 | { |
261 | - $Zbytek=(4-ceil(($Width/(8/$biBitCount)))%4)%4; |
|
261 | + $Zbytek = (4 - ceil(($Width / (8 / $biBitCount))) % 4) % 4; |
|
262 | 262 | |
263 | - for($y=$Height-1;$y>=0;$y--) |
|
263 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
264 | 264 | { |
265 | - $jpexs_CurrentBit=0; |
|
266 | - for($x=0;$x<$Width;$x++) |
|
265 | + $jpexs_CurrentBit = 0; |
|
266 | + for ($x = 0; $x < $Width; $x++) |
|
267 | 267 | { |
268 | - $C=jpexs_freadbits($f,$biBitCount); |
|
269 | - imagesetpixel($img,$x,$y,$Palette[$C]); |
|
268 | + $C = jpexs_freadbits($f, $biBitCount); |
|
269 | + imagesetpixel($img, $x, $y, $Palette[$C]); |
|
270 | 270 | }; |
271 | - if($jpexs_CurrentBit!=0) {jpexs_freadbyte($f);}; |
|
272 | - for($g=0;$g<$Zbytek;$g++) |
|
271 | + if ($jpexs_CurrentBit != 0) {jpexs_freadbyte($f); }; |
|
272 | + for ($g = 0; $g < $Zbytek; $g++) |
|
273 | 273 | jpexs_freadbyte($f); |
274 | 274 | }; |
275 | 275 | |
@@ -277,149 +277,149 @@ discard block |
||
277 | 277 | }; |
278 | 278 | |
279 | 279 | |
280 | - if($RLECompression==1) //$BI_RLE8 |
|
280 | + if ($RLECompression == 1) //$BI_RLE8 |
|
281 | 281 | { |
282 | - $y=$Height; |
|
282 | + $y = $Height; |
|
283 | 283 | |
284 | - $pocetb=0; |
|
284 | + $pocetb = 0; |
|
285 | 285 | |
286 | - while(true) |
|
286 | + while (true) |
|
287 | 287 | { |
288 | 288 | $y--; |
289 | - $prefix=jpexs_freadbyte($f); |
|
290 | - $suffix=jpexs_freadbyte($f); |
|
291 | - $pocetb+=2; |
|
289 | + $prefix = jpexs_freadbyte($f); |
|
290 | + $suffix = jpexs_freadbyte($f); |
|
291 | + $pocetb += 2; |
|
292 | 292 | |
293 | - $echoit=false; |
|
293 | + $echoit = false; |
|
294 | 294 | |
295 | - if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
296 | - if(($prefix==0)and($suffix==1)) break; |
|
297 | - if(feof($f)) break; |
|
295 | + if ($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
296 | + if (($prefix == 0) and ($suffix == 1)) break; |
|
297 | + if (feof($f)) break; |
|
298 | 298 | |
299 | - while(!(($prefix==0)and($suffix==0))) |
|
299 | + while (!(($prefix == 0) and ($suffix == 0))) |
|
300 | 300 | { |
301 | - if($prefix==0) |
|
301 | + if ($prefix == 0) |
|
302 | 302 | { |
303 | - $pocet=$suffix; |
|
304 | - $Data.=fread($f,$pocet); |
|
305 | - $pocetb+=$pocet; |
|
306 | - if($pocetb%2==1) {jpexs_freadbyte($f); $pocetb++;}; |
|
303 | + $pocet = $suffix; |
|
304 | + $Data .= fread($f, $pocet); |
|
305 | + $pocetb += $pocet; |
|
306 | + if ($pocetb % 2 == 1) {jpexs_freadbyte($f); $pocetb++; }; |
|
307 | 307 | }; |
308 | - if($prefix>0) |
|
308 | + if ($prefix > 0) |
|
309 | 309 | { |
310 | - $pocet=$prefix; |
|
311 | - for($r=0;$r<$pocet;$r++) |
|
312 | - $Data.=chr($suffix); |
|
310 | + $pocet = $prefix; |
|
311 | + for ($r = 0; $r < $pocet; $r++) |
|
312 | + $Data .= chr($suffix); |
|
313 | 313 | }; |
314 | - $prefix=jpexs_freadbyte($f); |
|
315 | - $suffix=jpexs_freadbyte($f); |
|
316 | - $pocetb+=2; |
|
317 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
314 | + $prefix = jpexs_freadbyte($f); |
|
315 | + $suffix = jpexs_freadbyte($f); |
|
316 | + $pocetb += 2; |
|
317 | + if ($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
318 | 318 | }; |
319 | 319 | |
320 | - for($x=0;$x<strlen($Data);$x++) |
|
320 | + for ($x = 0; $x < strlen($Data); $x++) |
|
321 | 321 | { |
322 | - imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
|
322 | + imagesetpixel($img, $x, $y, $Palette[ord($Data[$x])]); |
|
323 | 323 | }; |
324 | - $Data=""; |
|
324 | + $Data = ""; |
|
325 | 325 | |
326 | 326 | }; |
327 | 327 | |
328 | 328 | }; |
329 | 329 | |
330 | 330 | |
331 | - if($RLECompression==2) //$BI_RLE4 |
|
331 | + if ($RLECompression == 2) //$BI_RLE4 |
|
332 | 332 | { |
333 | - $y=$Height; |
|
334 | - $pocetb=0; |
|
333 | + $y = $Height; |
|
334 | + $pocetb = 0; |
|
335 | 335 | |
336 | 336 | /*while(!feof($f)) |
337 | 337 | echo freadbyte($f)."_".freadbyte($f)."<BR>";*/ |
338 | - while(true) |
|
338 | + while (true) |
|
339 | 339 | { |
340 | 340 | //break; |
341 | 341 | $y--; |
342 | - $prefix=jpexs_freadbyte($f); |
|
343 | - $suffix=jpexs_freadbyte($f); |
|
344 | - $pocetb+=2; |
|
342 | + $prefix = jpexs_freadbyte($f); |
|
343 | + $suffix = jpexs_freadbyte($f); |
|
344 | + $pocetb += 2; |
|
345 | 345 | |
346 | - $echoit=false; |
|
346 | + $echoit = false; |
|
347 | 347 | |
348 | - if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
349 | - if(($prefix==0)and($suffix==1)) break; |
|
350 | - if(feof($f)) break; |
|
348 | + if ($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
349 | + if (($prefix == 0) and ($suffix == 1)) break; |
|
350 | + if (feof($f)) break; |
|
351 | 351 | |
352 | - while(!(($prefix==0)and($suffix==0))) |
|
352 | + while (!(($prefix == 0) and ($suffix == 0))) |
|
353 | 353 | { |
354 | - if($prefix==0) |
|
354 | + if ($prefix == 0) |
|
355 | 355 | { |
356 | - $pocet=$suffix; |
|
357 | - |
|
358 | - $jpexs_CurrentBit=0; |
|
359 | - for($h=0;$h<$pocet;$h++) |
|
360 | - $Data.=chr(jpexs_freadbits($f,4)); |
|
361 | - if($jpexs_CurrentBit!=0) jpexs_freadbits($f,4); |
|
362 | - $pocetb+=ceil(($pocet/2)); |
|
363 | - if($pocetb%2==1) {jpexs_freadbyte($f); $pocetb++;}; |
|
356 | + $pocet = $suffix; |
|
357 | + |
|
358 | + $jpexs_CurrentBit = 0; |
|
359 | + for ($h = 0; $h < $pocet; $h++) |
|
360 | + $Data .= chr(jpexs_freadbits($f, 4)); |
|
361 | + if ($jpexs_CurrentBit != 0) jpexs_freadbits($f, 4); |
|
362 | + $pocetb += ceil(($pocet / 2)); |
|
363 | + if ($pocetb % 2 == 1) {jpexs_freadbyte($f); $pocetb++; }; |
|
364 | 364 | }; |
365 | - if($prefix>0) |
|
365 | + if ($prefix > 0) |
|
366 | 366 | { |
367 | - $pocet=$prefix; |
|
368 | - $i=0; |
|
369 | - for($r=0;$r<$pocet;$r++) |
|
367 | + $pocet = $prefix; |
|
368 | + $i = 0; |
|
369 | + for ($r = 0; $r < $pocet; $r++) |
|
370 | 370 | { |
371 | - if($i%2==0) |
|
371 | + if ($i % 2 == 0) |
|
372 | 372 | { |
373 | - $Data.=chr($suffix%16); |
|
373 | + $Data .= chr($suffix % 16); |
|
374 | 374 | } |
375 | 375 | else |
376 | 376 | { |
377 | - $Data.=chr(floor($suffix/16)); |
|
377 | + $Data .= chr(floor($suffix / 16)); |
|
378 | 378 | }; |
379 | 379 | $i++; |
380 | 380 | }; |
381 | 381 | }; |
382 | - $prefix=jpexs_freadbyte($f); |
|
383 | - $suffix=jpexs_freadbyte($f); |
|
384 | - $pocetb+=2; |
|
385 | - if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
382 | + $prefix = jpexs_freadbyte($f); |
|
383 | + $suffix = jpexs_freadbyte($f); |
|
384 | + $pocetb += 2; |
|
385 | + if ($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>"; |
|
386 | 386 | }; |
387 | 387 | |
388 | - for($x=0;$x<strlen($Data);$x++) |
|
388 | + for ($x = 0; $x < strlen($Data); $x++) |
|
389 | 389 | { |
390 | - imagesetpixel($img,$x,$y,$Palette[ord($Data[$x])]); |
|
390 | + imagesetpixel($img, $x, $y, $Palette[ord($Data[$x])]); |
|
391 | 391 | }; |
392 | - $Data=""; |
|
392 | + $Data = ""; |
|
393 | 393 | |
394 | 394 | }; |
395 | 395 | |
396 | 396 | }; |
397 | 397 | |
398 | 398 | |
399 | - if($biBitCount==24) |
|
399 | + if ($biBitCount == 24) |
|
400 | 400 | { |
401 | - $img=imagecreatetruecolor($Width,$Height); |
|
402 | - $Zbytek=$Width%4; |
|
401 | + $img = imagecreatetruecolor($Width, $Height); |
|
402 | + $Zbytek = $Width % 4; |
|
403 | 403 | |
404 | - for($y=$Height-1;$y>=0;$y--) |
|
404 | + for ($y = $Height - 1; $y >= 0; $y--) |
|
405 | 405 | { |
406 | - for($x=0;$x<$Width;$x++) |
|
406 | + for ($x = 0; $x < $Width; $x++) |
|
407 | 407 | { |
408 | - $B=jpexs_freadbyte($f); |
|
409 | - $G=jpexs_freadbyte($f); |
|
410 | - $R=jpexs_freadbyte($f); |
|
411 | - $color=imagecolorexact($img,$R,$G,$B); |
|
412 | - if($color==-1) $color=imagecolorallocate($img,$R,$G,$B); |
|
413 | - imagesetpixel($img,$x,$y,$color); |
|
408 | + $B = jpexs_freadbyte($f); |
|
409 | + $G = jpexs_freadbyte($f); |
|
410 | + $R = jpexs_freadbyte($f); |
|
411 | + $color = imagecolorexact($img, $R, $G, $B); |
|
412 | + if ($color == -1) $color = imagecolorallocate($img, $R, $G, $B); |
|
413 | + imagesetpixel($img, $x, $y, $color); |
|
414 | 414 | } |
415 | - for($z=0;$z<$Zbytek;$z++) |
|
415 | + for ($z = 0; $z < $Zbytek; $z++) |
|
416 | 416 | jpexs_freadbyte($f); |
417 | 417 | }; |
418 | 418 | }; |
419 | 419 | return $img; |
420 | 420 | |
421 | 421 | } |
422 | - else{ |
|
422 | + else { |
|
423 | 423 | return false; |
424 | 424 | } |
425 | 425 | |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | |
451 | 451 | function jpexs_freadbyte($f) |
452 | 452 | { |
453 | - return ord(fread($f,1)); |
|
453 | + return ord(fread($f, 1)); |
|
454 | 454 | }; |
455 | 455 | |
456 | 456 | function jpexs_freadword($f) |
457 | 457 | { |
458 | - $b1=jpexs_freadbyte($f); |
|
459 | - $b2=jpexs_freadbyte($f); |
|
460 | - return $b2*256+$b1; |
|
458 | + $b1 = jpexs_freadbyte($f); |
|
459 | + $b2 = jpexs_freadbyte($f); |
|
460 | + return $b2 * 256 + $b1; |
|
461 | 461 | }; |
462 | 462 | |
463 | 463 | |
@@ -468,64 +468,64 @@ discard block |
||
468 | 468 | |
469 | 469 | function jpexs_freaddword($f) |
470 | 470 | { |
471 | - $b1=jpexs_freadword($f); |
|
472 | - $b2=jpexs_freadword($f); |
|
473 | - return $b2*65536+$b1; |
|
471 | + $b1 = jpexs_freadword($f); |
|
472 | + $b2 = jpexs_freadword($f); |
|
473 | + return $b2 * 65536 + $b1; |
|
474 | 474 | }; |
475 | 475 | |
476 | 476 | |
477 | 477 | |
478 | -function jpexs_retBits($byte,$start,$len) |
|
478 | +function jpexs_retBits($byte, $start, $len) |
|
479 | 479 | { |
480 | - $bin=jpexs_decbin8($byte); |
|
481 | - $r=bindec(substr($bin,$start,$len)); |
|
480 | + $bin = jpexs_decbin8($byte); |
|
481 | + $r = bindec(substr($bin, $start, $len)); |
|
482 | 482 | return $r; |
483 | 483 | |
484 | 484 | }; |
485 | 485 | |
486 | 486 | |
487 | 487 | |
488 | -$jpexs_CurrentBit=0; |
|
489 | -function jpexs_freadbits($f,$count) |
|
488 | +$jpexs_CurrentBit = 0; |
|
489 | +function jpexs_freadbits($f, $count) |
|
490 | 490 | { |
491 | - global $jpexs_CurrentBit,$SMode; |
|
492 | - $Byte=jpexs_freadbyte($f); |
|
493 | - $LastCBit=$jpexs_CurrentBit; |
|
494 | - $jpexs_CurrentBit+=$count; |
|
495 | - if($jpexs_CurrentBit==8) |
|
491 | + global $jpexs_CurrentBit, $SMode; |
|
492 | + $Byte = jpexs_freadbyte($f); |
|
493 | + $LastCBit = $jpexs_CurrentBit; |
|
494 | + $jpexs_CurrentBit += $count; |
|
495 | + if ($jpexs_CurrentBit == 8) |
|
496 | 496 | { |
497 | - $jpexs_CurrentBit=0; |
|
497 | + $jpexs_CurrentBit = 0; |
|
498 | 498 | } |
499 | 499 | else |
500 | 500 | { |
501 | - fseek($f,ftell($f)-1); |
|
501 | + fseek($f, ftell($f) - 1); |
|
502 | 502 | }; |
503 | - return jpexs_retBits($Byte,$LastCBit,$count); |
|
503 | + return jpexs_retBits($Byte, $LastCBit, $count); |
|
504 | 504 | }; |
505 | 505 | |
506 | 506 | |
507 | 507 | |
508 | 508 | function jpexs_int_to_dword($n) |
509 | 509 | { |
510 | - return chr($n & 255).chr(($n >> 8) & 255).chr(($n >> 16) & 255).chr(($n >> 24) & 255); |
|
510 | + return chr($n&255).chr(($n >> 8)&255).chr(($n >> 16)&255).chr(($n >> 24)&255); |
|
511 | 511 | } |
512 | 512 | function jpexs_int_to_word($n) |
513 | 513 | { |
514 | - return chr($n & 255).chr(($n >> 8) & 255); |
|
514 | + return chr($n&255).chr(($n >> 8)&255); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | |
518 | 518 | function jpexs_decbin8($d) |
519 | 519 | { |
520 | - return jpexs_decbinx($d,8); |
|
520 | + return jpexs_decbinx($d, 8); |
|
521 | 521 | }; |
522 | 522 | |
523 | -function jpexs_decbinx($d,$n) |
|
523 | +function jpexs_decbinx($d, $n) |
|
524 | 524 | { |
525 | - $bin=decbin($d); |
|
526 | - $sbin=strlen($bin); |
|
527 | - for($j=0;$j<$n-$sbin;$j++) |
|
528 | - $bin="0$bin"; |
|
525 | + $bin = decbin($d); |
|
526 | + $sbin = strlen($bin); |
|
527 | + for ($j = 0; $j < $n - $sbin; $j++) |
|
528 | + $bin = "0$bin"; |
|
529 | 529 | return $bin; |
530 | 530 | }; |
531 | 531 |
@@ -164,7 +164,7 @@ |
||
164 | 164 | */ |
165 | 165 | protected function writeHeader($name, $data) |
166 | 166 | { |
167 | - header($name . ": " . $data); |
|
167 | + header($name.": ".$data); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | { |
57 | 57 | if ($match[1] == '') |
58 | 58 | $match[1] = '+'; |
59 | - return array('type' => 'abs', 'value' => $match[1] . $match[3]); |
|
59 | + return array('type' => 'abs', 'value' => $match[1].$match[3]); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | if (preg_match("/^([+-])?(\s+)?({$comp_regex})(\s+)?([+-])(\s+)?({$comp_regex})$/", $coord, $match)) |
63 | 63 | { |
64 | 64 | if ($match[1] == '') |
65 | 65 | $match[1] = '+'; |
66 | - return array('type' => 'cal', 'pivot' => $match[1] . $match[3], 'value' => $match[5] . $match[7]); |
|
66 | + return array('type' => 'cal', 'pivot' => $match[1].$match[3], 'value' => $match[5].$match[7]); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $comp_regex = implode('|', self::$coord_regex); |
80 | 80 | if (preg_match("/^([+-])?({$comp_regex})$/", $coord, $matches)) |
81 | 81 | { |
82 | - $sign = intval($matches[1] . "1"); |
|
82 | + $sign = intval($matches[1]."1"); |
|
83 | 83 | $val = $matches[2]; |
84 | 84 | if (substr($val, -1) === '%') |
85 | 85 | return intval(round($sign * $dim * floatval(str_replace('%', '', $val)) / 100)); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $radius = $radius * 2; |
51 | 51 | if ($threshold > 255) $threshold = 255; |
52 | 52 | |
53 | - $radius = abs(round($radius)); // Only integers make sense. |
|
53 | + $radius = abs(round($radius)); // Only integers make sense. |
|
54 | 54 | if ($radius == 0) { |
55 | 55 | return $image; |
56 | 56 | } |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | |
66 | 66 | $blurred = $image->applyConvolution($matrix, 16, 0); |
67 | 67 | |
68 | - if($threshold > 0) { |
|
68 | + if ($threshold > 0) { |
|
69 | 69 | // Calculate the difference between the blurred pixels and the original |
70 | 70 | // and set the pixels |
71 | - for ($x = 0; $x < $image->getWidth(); $x++) { // each row |
|
72 | - for ($y = 0; $y < $image->getHeight(); $y++) { // each pixel |
|
71 | + for ($x = 0; $x < $image->getWidth(); $x++) { // each row |
|
72 | + for ($y = 0; $y < $image->getHeight(); $y++) { // each pixel |
|
73 | 73 | $rgbOrig = $image->getRGBAt($x, $y); |
74 | 74 | $rOrig = $rgbOrig["red"]; |
75 | 75 | $gOrig = $rgbOrig["green"]; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | else { |
103 | 103 | $w = $image->getWidth(); |
104 | 104 | $h = $image->getHeight(); |
105 | - for ($x = 0; $x < $w; $x++) { // each row |
|
106 | - for ($y = 0; $y < $h; $y++) { // each pixel |
|
105 | + for ($x = 0; $x < $w; $x++) { // each row |
|
106 | + for ($y = 0; $y < $h; $y++) { // each pixel |
|
107 | 107 | $rgbOrig = $image->getRGBAt($x, $y); |
108 | 108 | $rOrig = $rgbOrig["red"]; |
109 | 109 | $gOrig = $rgbOrig["green"]; |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | $bBlur = $rgbBlur["blue"]; |
116 | 116 | |
117 | 117 | $rNew = ($amount * ($rOrig - $rBlur)) + $rOrig; |
118 | - if($rNew>255){$rNew=255;} |
|
119 | - elseif($rNew<0){$rNew=0;} |
|
118 | + if ($rNew > 255) {$rNew = 255; } |
|
119 | + elseif ($rNew < 0) {$rNew = 0; } |
|
120 | 120 | $gNew = ($amount * ($gOrig - $gBlur)) + $gOrig; |
121 | - if($gNew>255){$gNew=255;} |
|
122 | - elseif($gNew<0){$gNew=0;} |
|
121 | + if ($gNew > 255) {$gNew = 255; } |
|
122 | + elseif ($gNew < 0) {$gNew = 0; } |
|
123 | 123 | $bNew = ($amount * ($bOrig - $bBlur)) + $bOrig; |
124 | - if($bNew>255){$bNew=255;} |
|
125 | - elseif($bNew<0){$bNew=0;} |
|
124 | + if ($bNew > 255) {$bNew = 255; } |
|
125 | + elseif ($bNew < 0) {$bNew = 0; } |
|
126 | 126 | $rgbNew = array("red" => $rNew, "green" => $gNew, "blue" => $bNew, "alpha" => 0); |
127 | 127 | |
128 | 128 | $image->setRGBAt($x, $y, $rgbNew); |
@@ -61,10 +61,10 @@ |
||
61 | 61 | if (array_key_exists($format, self::$mappers)) |
62 | 62 | return self::$mappers[$format]; |
63 | 63 | |
64 | - $mapperClassName = 'WideImage_Mapper_' . $format; |
|
64 | + $mapperClassName = 'WideImage_Mapper_'.$format; |
|
65 | 65 | if (!class_exists($mapperClassName, false)) |
66 | 66 | { |
67 | - $mapperFileName = WideImage::path() . 'Mapper/' . $format . '.php'; |
|
67 | + $mapperFileName = WideImage::path().'Mapper/'.$format.'.php'; |
|
68 | 68 | if (file_exists($mapperFileName)) |
69 | 69 | require_once($mapperFileName); |
70 | 70 | } |