Completed
Branch master (9528ad)
by Michael
04:32
created
class/wideimage/Canvas.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -41,6 +41,9 @@
 block discarded – undo
41 41
 		protected $image = null;
42 42
 		protected $font = null;
43 43
 		
44
+		/**
45
+		 * @param WideImage_Image $img
46
+		 */
44 47
 		function __construct($img)
45 48
 		{
46 49
 			$this->handle = $img->getHandle();
Please login to merge, or discard this patch.
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-    
22
-    * @package WideImage
23
-  **/
21
+	 * @package WideImage
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * @package Exceptions
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,10 +90,10 @@
 block discarded – undo
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}.");
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -64,12 +64,14 @@  discard block
 block discarded – undo
64 64
 		 */
65 65
 		function writeText($x, $y, $text, $angle = 0)
66 66
 		{
67
-			if ($this->font === null)
68
-				throw new WideImage_NoFontException("Can't write text without a font.");
67
+			if ($this->font === null) {
68
+							throw new WideImage_NoFontException("Can't write text without a font.");
69
+			}
69 70
 			
70 71
 			$angle = - floatval($angle);
71
-			if ($angle < 0)
72
-				$angle = 360 + $angle;
72
+			if ($angle < 0) {
73
+							$angle = 360 + $angle;
74
+			}
73 75
 			$angle = $angle % 360;
74 76
 			
75 77
 			$this->font->writeText($this->image, $x, $y, $text, $angle);
@@ -94,9 +96,9 @@  discard block
 block discarded – undo
94 96
 			{
95 97
 				array_unshift($params, $this->handle);
96 98
 				call_user_func_array('image' . $method, $params);
99
+			} else {
100
+							throw new WideImage_InvalidCanvasMethodException("Function doesn't exist: image{$method}.");
97 101
 			}
98
-			else
99
-				throw new WideImage_InvalidCanvasMethodException("Function doesn't exist: image{$method}.");
100 102
 		}
101 103
 	}
102 104
 ?>
103 105
\ No newline at end of file
Please login to merge, or discard this patch.
class/wideimage/Coordinate.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 		 * Parses a numeric or string representation of a corrdinate into a structure
42 42
 		 * 
43 43
 		 * @param string $coord Smart coordinate
44
-		 * @return array Parsed smart coordinate
44
+		 * @return integer Parsed smart coordinate
45 45
 		 */
46 46
 		static function parse($coord)
47 47
 		{
Please login to merge, or discard this patch.
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-	* @package Internals
23
-  **/
21
+	 * @package Internals
22
+	 **/
24 23
 	
25 24
 	
26 25
 	/**
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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));
Please login to merge, or discard this patch.
Braces   +38 added lines, -28 removed lines patch added patch discarded remove patch
@@ -47,22 +47,25 @@  discard block
 block discarded – undo
47 47
 		{
48 48
 			$coord = trim($coord);
49 49
 			
50
-			if (strlen($coord) == 0)
51
-				return array('type' => 'abs', 'value' => '+0');
50
+			if (strlen($coord) == 0) {
51
+							return array('type' => 'abs', 'value' => '+0');
52
+			}
52 53
 			
53 54
 			$comp_regex = implode('|', self::$coord_regex);
54 55
 			
55 56
 			if (preg_match("/^([+-])?(\s+)?({$comp_regex})$/", $coord, $match))
56 57
 			{
57
-				if ($match[1] == '')
58
-					$match[1] = '+';
58
+				if ($match[1] == '') {
59
+									$match[1] = '+';
60
+				}
59 61
 				return array('type' => 'abs', 'value' => $match[1] . $match[3]);
60 62
 			}
61 63
 			
62 64
 			if (preg_match("/^([+-])?(\s+)?({$comp_regex})(\s+)?([+-])(\s+)?({$comp_regex})$/", $coord, $match))
63 65
 			{
64
-				if ($match[1] == '')
65
-					$match[1] = '+';
66
+				if ($match[1] == '') {
67
+									$match[1] = '+';
68
+				}
66 69
 				return array('type' => 'cal', 'pivot' => $match[1] . $match[3], 'value' => $match[5] . $match[7]);
67 70
 			}
68 71
 		}
@@ -81,10 +84,11 @@  discard block
 block discarded – undo
81 84
 			{
82 85
 				$sign = intval($matches[1] . "1");
83 86
 				$val = $matches[2];
84
-				if (substr($val, -1) === '%')
85
-					return intval(round($sign * $dim * floatval(str_replace('%', '', $val)) / 100));
86
-				else
87
-					return $sign * intval(round($val));
87
+				if (substr($val, -1) === '%') {
88
+									return intval(round($sign * $dim * floatval(str_replace('%', '', $val)) / 100));
89
+				} else {
90
+									return $sign * intval(round($val));
91
+				}
88 92
 			}
89 93
 		}
90 94
 		
@@ -99,14 +103,14 @@  discard block
 block discarded – undo
99 103
 		static function fix($dim, $value, $clip = false)
100 104
 		{
101 105
 			$coord = self::parse($value);
102
-			if ($coord === null)
103
-				throw new WideImage_InvalidCoordinateException("Couldn't parse coordinate '$value' properly.");
106
+			if ($coord === null) {
107
+							throw new WideImage_InvalidCoordinateException("Couldn't parse coordinate '$value' properly.");
108
+			}
104 109
 			
105 110
 			if ($coord['type'] === 'abs')
106 111
 			{
107 112
 				$result = self::evaluate($coord['value'], $dim);
108
-			}
109
-			elseif ($coord['type'] === 'cal')
113
+			} elseif ($coord['type'] === 'cal')
110 114
 			{
111 115
 				$p = self::evaluate($coord['pivot'], $dim);
112 116
 				$v = self::evaluate($coord['value'], $dim);
@@ -115,10 +119,11 @@  discard block
 block discarded – undo
115 119
 			
116 120
 			if ($clip)
117 121
 			{
118
-				if ($result < 0)
119
-					return 0;
120
-				elseif ($result >= $dim)
121
-					return $dim;
122
+				if ($result < 0) {
123
+									return 0;
124
+				} elseif ($result >= $dim) {
125
+									return $dim;
126
+				}
122 127
 			}
123 128
 			return $result;
124 129
 		}
@@ -133,20 +138,25 @@  discard block
 block discarded – undo
133 138
 		 */
134 139
 		static function fixForResize($img, $width, $height)
135 140
 		{
136
-			if ($width === null && $height === null)
137
-				return array($img->getWidth(), $img->getHeight());
141
+			if ($width === null && $height === null) {
142
+							return array($img->getWidth(), $img->getHeight());
143
+			}
138 144
 			
139
-			if ($width !== null)
140
-				$width = self::fix($img->getWidth(), $width);
145
+			if ($width !== null) {
146
+							$width = self::fix($img->getWidth(), $width);
147
+			}
141 148
 			
142
-			if ($height !== null)
143
-				$height = self::fix($img->getHeight(), $height);
149
+			if ($height !== null) {
150
+							$height = self::fix($img->getHeight(), $height);
151
+			}
144 152
 			
145
-			if ($width === null)
146
-				$width = floor($img->getWidth() * $height / $img->getHeight());
153
+			if ($width === null) {
154
+							$width = floor($img->getWidth() * $height / $img->getHeight());
155
+			}
147 156
 			
148
-			if ($height === null)
149
-				$height = floor($img->getHeight() * $width / $img->getWidth());
157
+			if ($height === null) {
158
+							$height = floor($img->getHeight() * $width / $img->getWidth());
159
+			}
150 160
 			
151 161
 			return array($width, $height);
152 162
 		}
Please login to merge, or discard this patch.
class/wideimage/Image.php 4 patches
Doc Comments   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		/**
160 160
 		 * Output a header to browser.
161 161
 		 * 
162
-		 * @param $name Name of the header
162
+		 * @param string $name Name of the header
163 163
 		 * @param $data Data
164 164
 		 */
165 165
 		protected function writeHeader($name, $data)
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 		 * Copies transparency information from $sourceImage. Optionally fills
349 349
 		 * the image with the transparent color at (0, 0).
350 350
 		 * 
351
-		 * @param object $sourceImage
351
+		 * @param WideImage_Image $sourceImage
352 352
 		 * @param bool $fill True if you want to fill the image with transparent color
353 353
 		 */
354 354
 		function copyTransparencyFrom($sourceImage, $fill = true)
@@ -425,6 +425,8 @@  discard block
 block discarded – undo
425 425
 		 * @var mixed $height The new height (smart coordinate), or null.
426 426
 		 * @var string $fit 'inside', 'outside', 'fill'
427 427
 		 * @var string $scale 'down', 'up', 'any'
428
+		 * @param integer $width
429
+		 * @param integer $height
428 430
 		 * @return WideImage_Image resized image
429 431
 		 */
430 432
 		function resize($width = null, $height = null, $fit = 'inside', $scale = 'any')
@@ -479,8 +481,8 @@  discard block
 block discarded – undo
479 481
 		 * Hint: if the overlay is a truecolor image with alpha channel, you should leave $pct at 100.
480 482
 		 * 
481 483
 		 * @param WideImage_Image $overlay The overlay image
482
-		 * @param mixed $left Left position of the overlay, smart coordinate
483
-		 * @param mixed $top Top position of the overlay, smart coordinate
484
+		 * @param integer $left Left position of the overlay, smart coordinate
485
+		 * @param integer $top Top position of the overlay, smart coordinate
484 486
 		 * @param int $pct The opacity of the overlay
485 487
 		 * @return WideImage_Image The merged image
486 488
 		 */
@@ -496,8 +498,8 @@  discard block
 block discarded – undo
496 498
 		 * and white is fully opaque.
497 499
 		 * 
498 500
 		 * @param WideImage_Image $mask The mask image, greyscale
499
-		 * @param mixed $left Left coordinate, smart coordinate
500
-		 * @param mixed $top Top coordinate, smart coordinate
501
+		 * @param integer $left Left coordinate, smart coordinate
502
+		 * @param integer $top Top coordinate, smart coordinate
501 503
 		 * @return WideImage_Image The resulting image
502 504
 		 **/
503 505
 		function applyMask($mask, $left = 0, $top = 0)
Please login to merge, or discard this patch.
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-	* @package WideImage
23
-  **/
21
+	 * @package WideImage
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Thrown when an invalid dimension is passed for some operations
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@
 block discarded – undo
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
 		/**
Please login to merge, or discard this patch.
Braces   +34 added lines, -26 removed lines patch added patch discarded remove patch
@@ -83,8 +83,9 @@  discard block
 block discarded – undo
83 83
 		 */
84 84
 		function destroy()
85 85
 		{
86
-			if ($this->isValid() && !$this->handleReleased)
87
-				imagedestroy($this->handle);
86
+			if ($this->isValid() && !$this->handleReleased) {
87
+							imagedestroy($this->handle);
88
+			}
88 89
 			
89 90
 			$this->handle = null;
90 91
 		}
@@ -210,10 +211,11 @@  discard block
 block discarded – undo
210 211
 		 */
211 212
 		function allocateColor($R, $G = null, $B = null)
212 213
 		{
213
-			if (is_array($R))
214
-				return imageColorAllocate($this->handle, $R['red'], $R['green'], $R['blue']);
215
-			else
216
-				return imageColorAllocate($this->handle, $R, $G, $B);
214
+			if (is_array($R)) {
215
+							return imageColorAllocate($this->handle, $R['red'], $R['green'], $R['blue']);
216
+			} else {
217
+							return imageColorAllocate($this->handle, $R, $G, $B);
218
+			}
217 219
 		}
218 220
 		
219 221
 		/**
@@ -321,10 +323,11 @@  discard block
 block discarded – undo
321 323
 		 */
322 324
 		function getClosestColor($R, $G = null, $B = null)
323 325
 		{
324
-			if (is_array($R))
325
-				return imagecolorclosest($this->handle, $R['red'], $R['green'], $R['blue']);
326
-			else
327
-				return imagecolorclosest($this->handle, $R, $G, $B);
326
+			if (is_array($R)) {
327
+							return imagecolorclosest($this->handle, $R['red'], $R['green'], $R['blue']);
328
+			} else {
329
+							return imagecolorclosest($this->handle, $R, $G, $B);
330
+			}
328 331
 		}
329 332
 		
330 333
 		/**
@@ -338,10 +341,11 @@  discard block
 block discarded – undo
338 341
 		 */
339 342
 		function getExactColor($R, $G = null, $B = null)
340 343
 		{
341
-			if (is_array($R))
342
-				return imagecolorexact($this->handle, $R['red'], $R['green'], $R['blue']);
343
-			else
344
-				return imagecolorexact($this->handle, $R, $G, $B);
344
+			if (is_array($R)) {
345
+							return imagecolorexact($this->handle, $R['red'], $R['green'], $R['blue']);
346
+			} else {
347
+							return imagecolorexact($this->handle, $R, $G, $B);
348
+			}
345 349
 		}
346 350
 		
347 351
 		/**
@@ -358,8 +362,9 @@  discard block
 block discarded – undo
358 362
 				$rgba = $sourceImage->getTransparentColorRGB();
359 363
 				$color = $this->allocateColor($rgba);
360 364
 				$this->setTransparentColor($color);
361
-				if ($fill)
362
-					$this->fill(0, 0, $color);
365
+				if ($fill) {
366
+									$this->fill(0, 0, $color);
367
+				}
363 368
 			}
364 369
 		}
365 370
 		
@@ -591,10 +596,11 @@  discard block
 block discarded – undo
591 596
 		 */
592 597
 		function asNegative()
593 598
 		{
594
-			if ($this instanceof WideImage_PaletteImage && $this->isTransparent())
595
-				$trgb = $this->getTransparentColorRGB();
596
-			else
597
-				$trgb = null;
599
+			if ($this instanceof WideImage_PaletteImage && $this->isTransparent()) {
600
+							$trgb = $this->getTransparentColorRGB();
601
+			} else {
602
+							$trgb = null;
603
+			}
598 604
 			
599 605
 			$img = $this->getOperation('ApplyFilter')->execute($this, IMG_FILTER_NEGATE);
600 606
 			
@@ -689,10 +695,11 @@  discard block
 block discarded – undo
689 695
 		 */
690 696
 		function __toString()
691 697
 		{
692
-			if ($this->isTransparent())
693
-				return $this->asString('gif');
694
-			else
695
-				return $this->asString('png');
698
+			if ($this->isTransparent()) {
699
+							return $this->asString('gif');
700
+			} else {
701
+							return $this->asString('png');
702
+			}
696 703
 		}
697 704
 		
698 705
 		/**
@@ -739,8 +746,9 @@  discard block
 block discarded – undo
739 746
 		 **/
740 747
 		function getCanvas()
741 748
 		{
742
-			if ($this->canvas == null)
743
-				$this->canvas = new WideImage_Canvas($this);
749
+			if ($this->canvas == null) {
750
+							$this->canvas = new WideImage_Canvas($this);
751
+			}
744 752
 			return $this->canvas;
745 753
 		}
746 754
 		
Please login to merge, or discard this patch.
class/wideimage/MapperFactory.php 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -78,6 +78,10 @@  discard block
 block discarded – undo
78 78
 			throw new WideImage_UnsupportedFormatException("Format '{$format}' is not supported.");
79 79
 		}
80 80
 		
81
+		/**
82
+		 * @param string $uri
83
+		 * @param string $format
84
+		 */
81 85
 		static function determineFormat($uri, $format = null)
82 86
 		{
83 87
 			if ($format == null)
@@ -98,6 +102,9 @@  discard block
 block discarded – undo
98 102
 			return $format;
99 103
 		}
100 104
 		
105
+		/**
106
+		 * @param string $format
107
+		 */
101 108
 		static function mimeType($format)
102 109
 		{
103 110
 			return array_search(strtoupper($format), self::$mimeTable);
Please login to merge, or discard this patch.
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-    
22
-    * @package WideImage
23
-  **/
21
+	 * @package WideImage
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * Thrown when image format isn't supported
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,10 +61,10 @@
 block discarded – undo
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
 			}
Please login to merge, or discard this patch.
Braces   +20 added lines, -14 removed lines patch added patch discarded remove patch
@@ -58,15 +58,17 @@  discard block
 block discarded – undo
58 58
 		{
59 59
 			$format = self::determineFormat($uri, $format);
60 60
 			
61
-			if (array_key_exists($format, self::$mappers))
62
-				return self::$mappers[$format];
61
+			if (array_key_exists($format, self::$mappers)) {
62
+							return self::$mappers[$format];
63
+			}
63 64
 			
64 65
 			$mapperClassName = 'WideImage_Mapper_' . $format;
65 66
 			if (!class_exists($mapperClassName, false))
66 67
 			{
67 68
 				$mapperFileName = WideImage::path() . 'Mapper/' . $format . '.php';
68
-				if (file_exists($mapperFileName))
69
-					require_once($mapperFileName);
69
+				if (file_exists($mapperFileName)) {
70
+									require_once($mapperFileName);
71
+				}
70 72
 			}
71 73
 			
72 74
 			if (class_exists($mapperClassName, false))
@@ -80,20 +82,23 @@  discard block
 block discarded – undo
80 82
 		
81 83
 		static function determineFormat($uri, $format = null)
82 84
 		{
83
-			if ($format == null)
84
-				$format = self::extractExtension($uri);
85
+			if ($format == null) {
86
+							$format = self::extractExtension($uri);
87
+			}
85 88
 			
86 89
 			// mime-type match
87
-			if (preg_match('~[a-z]*/[a-z-]*~i', $format))
88
-				if (isset(self::$mimeTable[strtolower($format)]))
90
+			if (preg_match('~[a-z]*/[a-z-]*~i', $format)) {
91
+							if (isset(self::$mimeTable[strtolower($format)]))
89 92
 				{
90 93
 					return self::$mimeTable[strtolower($format)];
94
+			}
91 95
 				}
92 96
 			
93 97
 			// clean the string
94 98
 			$format = strtoupper(preg_replace('/[^a-z0-9_-]/i', '', $format));
95
-			if ($format == 'JPG')
96
-				$format = 'JPEG';
99
+			if ($format == 'JPG') {
100
+							$format = 'JPEG';
101
+			}
97 102
 			
98 103
 			return $format;
99 104
 		}
@@ -106,10 +111,11 @@  discard block
 block discarded – undo
106 111
 		static function extractExtension($uri)
107 112
 		{
108 113
 			$p = strrpos($uri, '.');
109
-			if ($p === false)
110
-				return '';
111
-			else
112
-				return substr($uri, $p + 1);
114
+			if ($p === false) {
115
+							return '';
116
+			} else {
117
+							return substr($uri, $p + 1);
118
+			}
113 119
 		}
114 120
 	}
115 121
 ?>
116 122
\ No newline at end of file
Please login to merge, or discard this patch.
class/wideimage/Operation/ApplyMask.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@
 block discarded – undo
34 34
 		 *
35 35
 		 * @param WideImage_Image $image
36 36
 		 * @param WideImage_Image $mask
37
-		 * @param smart_coordinate $left
38
-		 * @param smart_coordinate $top
37
+		 * @param integer $left
38
+		 * @param integer $top
39 39
 		 * @return WideImage_Image
40 40
 		 */
41 41
 		function execute($image, $mask, $left = 0, $top = 0)
Please login to merge, or discard this patch.
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-    * @package Internal/Operations
23
-  **/
21
+	 * @package Internal/Operations
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * ApplyMask operation class
Please login to merge, or discard this patch.
Braces   +27 added lines, -21 removed lines patch added patch discarded remove patch
@@ -44,12 +44,14 @@  discard block
 block discarded – undo
44 44
 			$top = WideImage_Coordinate::fix($image->getHeight(), $top);
45 45
 			
46 46
 			$width = $image->getWidth();
47
-			if ($width > $mask->getWidth())
48
-				$width = $mask->getWidth();
47
+			if ($width > $mask->getWidth()) {
48
+							$width = $mask->getWidth();
49
+			}
49 50
 			
50 51
 			$height = $image->getHeight();
51
-			if ($height > $mask->getHeight())
52
-				$height = $mask->getHeight();
52
+			if ($height > $mask->getHeight()) {
53
+							$height = $mask->getHeight();
54
+			}
53 55
 			
54 56
 			$result = $image->asTrueColor();
55 57
 			$result->alphaBlending(false);
@@ -62,34 +64,38 @@  discard block
 block discarded – undo
62 64
 				$trgb['alpha'] = 127;
63 65
 				$destTransparentColor = $result->allocateColorAlpha($trgb);
64 66
 				$result->setTransparentColor($destTransparentColor);
67
+			} else {
68
+							$destTransparentColor = $result->allocateColorAlpha(255, 255, 255, 127);
65 69
 			}
66
-			else
67
-				$destTransparentColor = $result->allocateColorAlpha(255, 255, 255, 127);
68 70
 			
69
-			for ($x = 0; $x < $width; $x++)
70
-				for ($y = 0; $y < $height; $y++)
71
-					if ($left + $x < $image->getWidth() && $top + $y < $image->getHeight())
71
+			for ($x = 0; $x < $width; $x++) {
72
+							for ($y = 0;
73
+			}
74
+			$y < $height; $y++) {
75
+									if ($left + $x < $image->getWidth() && $top + $y < $image->getHeight())
72 76
 					{
73 77
 						$srcColor = $image->getColorAt($left + $x, $top + $y);
74
-						if ($srcColor == $srcTransparentColor)
75
-							$destColor = $destTransparentColor;
76
-						else
78
+				}
79
+						if ($srcColor == $srcTransparentColor) {
80
+													$destColor = $destTransparentColor;
81
+						} else
77 82
 						{
78 83
 							$maskRGB = $mask->getRGBAt($x, $y);
79
-							if ($maskRGB['red'] == 0)
80
-								$destColor = $destTransparentColor;
81
-							elseif ($srcColor >= 0)
84
+							if ($maskRGB['red'] == 0) {
85
+															$destColor = $destTransparentColor;
86
+							} elseif ($srcColor >= 0)
82 87
 							{
83 88
 								$imageRGB = $image->getRGBAt($left + $x, $top + $y);
84 89
 								$level = ($maskRGB['red'] / 255) * (1 - $imageRGB['alpha'] / 127);
85 90
 								$imageRGB['alpha'] = 127 - round($level * 127);
86
-								if ($imageRGB['alpha'] == 127)
87
-									$destColor = $destTransparentColor;
88
-								else
89
-									$destColor = $result->allocateColorAlpha($imageRGB);
91
+								if ($imageRGB['alpha'] == 127) {
92
+																	$destColor = $destTransparentColor;
93
+								} else {
94
+																	$destColor = $result->allocateColorAlpha($imageRGB);
95
+								}
96
+							} else {
97
+															$destColor = $destTransparentColor;
90 98
 							}
91
-							else
92
-								$destColor = $destTransparentColor;
93 99
 						}
94 100
 						$result->setColorAt($left + $x, $top + $y, $destColor);
95 101
 					}
Please login to merge, or discard this patch.
class/wideimage/OperationFactory.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -36,6 +36,9 @@
 block discarded – undo
36 36
 	{
37 37
 		static protected $cache = array();
38 38
 		
39
+		/**
40
+		 * @param string $operationName
41
+		 */
39 42
 		static function get($operationName)
40 43
 		{
41 44
 			if (!isset(self::$cache[$operationName]))
Please login to merge, or discard this patch.
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-
22
-	* @package Internals
23
-  **/
21
+	 * @package Internals
22
+	 **/
24 23
 	
25 24
 	/**
26 25
 	 * @package Exceptions
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@
 block discarded – undo
40 40
 		{
41 41
 			if (!isset(self::$cache[$operationName]))
42 42
 			{
43
-				$opClassName = "WideImage_Operation_" . $operationName;
43
+				$opClassName = "WideImage_Operation_".$operationName;
44 44
 				if (!class_exists($opClassName, false))
45 45
 				{
46
-					$fileName = WideImage::path() . 'Operation/' . $operationName . '.php';
46
+					$fileName = WideImage::path().'Operation/'.$operationName.'.php';
47 47
 					if (file_exists($fileName))
48 48
 						require_once($fileName);
49 49
 					else
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,10 +44,11 @@
 block discarded – undo
44 44
 				if (!class_exists($opClassName, false))
45 45
 				{
46 46
 					$fileName = WideImage::path() . 'Operation/' . $operationName . '.php';
47
-					if (file_exists($fileName))
48
-						require_once($fileName);
49
-					else
50
-						throw new WideImage_UnknownImageOperationException("Can't load '{$operationName}' operation.");
47
+					if (file_exists($fileName)) {
48
+											require_once($fileName);
49
+					} else {
50
+											throw new WideImage_UnknownImageOperationException("Can't load '{$operationName}' operation.");
51
+					}
51 52
 				}
52 53
 				self::$cache[$operationName] = new $opClassName();
53 54
 			}
Please login to merge, or discard this patch.
class/wideimage/vendor/JPEXS/bmp.php 3 patches
Doc Comments   +16 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @param resource $img Image resource to convert
35 35
  * @param string $file File to save image to. If ommited or "", file is written to standard output
36 36
  * @param boolean $useRLE When true, file will be saved with RLE compression (EXPERIMENTAL)
37
- * @return boolean True when successfully writen to specified file
37
+ * @return resource|null True when successfully writen to specified file
38 38
  */
39 39
 function imagebmp($img,$file="",$useRLE=false)
40 40
 {
@@ -461,6 +461,9 @@  discard block
 block discarded – undo
461 461
 };
462 462
 
463 463
 
464
+/**
465
+ * @param resource $f
466
+ */
464 467
 function jpexs_freadlngint($f)
465 468
 {
466 469
 	return jpexs_freaddword($f);
@@ -475,6 +478,9 @@  discard block
 block discarded – undo
475 478
 
476 479
 
477 480
 
481
+/**
482
+ * @param integer $byte
483
+ */
478 484
 function jpexs_retBits($byte,$start,$len)
479 485
 {
480 486
 	$bin=jpexs_decbin8($byte);
@@ -486,6 +492,9 @@  discard block
 block discarded – undo
486 492
 
487 493
 
488 494
 $jpexs_CurrentBit=0;
495
+/**
496
+ * @param resource $f
497
+ */
489 498
 function jpexs_freadbits($f,$count)
490 499
 {
491 500
 	global $jpexs_CurrentBit,$SMode;
@@ -509,6 +518,9 @@  discard block
 block discarded – undo
509 518
 {
510 519
 	return chr($n & 255).chr(($n >> 8) & 255).chr(($n >> 16) & 255).chr(($n >> 24) & 255);
511 520
 }
521
+/**
522
+ * @param integer $n
523
+ */
512 524
 function jpexs_int_to_word($n)
513 525
 {
514 526
 	return chr($n & 255).chr(($n >> 8) & 255);
@@ -520,6 +532,9 @@  discard block
 block discarded – undo
520 532
 	return jpexs_decbinx($d,8);
521 533
 };
522 534
 
535
+/**
536
+ * @param integer $n
537
+ */
523 538
 function jpexs_decbinx($d,$n)
524 539
 {
525 540
 	$bin=decbin($d);
Please login to merge, or discard this patch.
Spacing   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -36,165 +36,165 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +81 added lines, -46 removed lines patch added patch discarded remove patch
@@ -46,7 +46,9 @@  discard block
 block discarded – undo
46 46
 	$IsTransparent=$Transparent!=-1;
47 47
 
48 48
 
49
-	if($IsTransparent) $ColorCount--;
49
+	if($IsTransparent) {
50
+		$ColorCount--;
51
+	}
50 52
 
51 53
 	if($ColorCount==0) {$ColorCount=0; $BitCount=24; $palsize = 0; };
52 54
 	if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;};
@@ -58,7 +60,9 @@  discard block
 block discarded – undo
58 60
 
59 61
 	$Zbytek=(4-($Width/(8/$BitCount))%4)%4;
60 62
 
61
-	if($BitCount<24) $palsize=pow(2,$BitCount)*4;
63
+	if($BitCount<24) {
64
+		$palsize=pow(2,$BitCount)*4;
65
+	}
62 66
 
63 67
 	$size=(floor($Width/(8/$BitCount))+$Zbytek)*$Height+54;
64 68
 	$size+=$palsize;
@@ -87,11 +91,15 @@  discard block
 block discarded – undo
87 91
 	
88 92
 	$CC=$ColorCount;
89 93
 	$sl1=strlen($ret);
90
-	if($CC==0) $CC=256;
94
+	if($CC==0) {
95
+		$CC=256;
96
+	}
91 97
 	if($BitCount<24)
92 98
 	{
93 99
 		$ColorTotal=imagecolorstotal($img);
94
-		if($IsTransparent) $ColorTotal--;
100
+		if($IsTransparent) {
101
+			$ColorTotal--;
102
+		}
95 103
 
96 104
 		for($p=0;$p<$ColorTotal;$p++)
97 105
 		{
@@ -133,12 +141,14 @@  discard block
 block discarded – undo
133 141
 			if((strlen($bWrite)<8)and(strlen($bWrite)!=0))
134 142
 			{
135 143
 				$sl=strlen($bWrite);
136
-				for($t=0;$t<8-$sl;$t++)
137
-				$sl.="0";
144
+				for($t=0;$t<8-$sl;$t++) {
145
+								$sl.="0";
146
+				}
138 147
 				$retd.=jpexs_inttobyte(bindec($bWrite));
139 148
 			};
140
-			for($z=0;$z<$Zbytek;$z++)
141
-			$retd.=jpexs_inttobyte(0);
149
+			for($z=0;$z<$Zbytek;$z++) {
150
+						$retd.=jpexs_inttobyte(0);
151
+			}
142 152
 		};
143 153
 	};
144 154
 
@@ -146,9 +156,10 @@  discard block
 block discarded – undo
146 156
 	{
147 157
 		for($t=0;$t<strlen($retd);$t+=4)
148 158
 		{
149
-			if($t!=0)
150
-			if(($t)%$Width==0)
159
+			if($t!=0) {
160
+						if(($t)%$Width==0)
151 161
 			$ret.=chr(0).chr(0);
162
+			}
152 163
 
153 164
 			if(($t+5)%$Width==0)
154 165
 			{
@@ -159,15 +170,13 @@  discard block
 block discarded – undo
159 170
 			{
160 171
 				$ret.=chr(0).chr(6).substr($retd,$t,6);
161 172
 				$t+=2;
162
-			}
163
-			else
173
+			} else
164 174
 			{
165 175
 				$ret.=chr(0).chr(4).substr($retd,$t,4);
166 176
 			};
167 177
 		};
168 178
 		$ret.=chr(0).chr(1);
169
-	}
170
-	else
179
+	} else
171 180
 	{
172 181
 		$ret.=$retd;
173 182
 	};
@@ -175,8 +184,9 @@  discard block
 block discarded – undo
175 184
 	$Dopl = "";
176 185
 	if($BitCount==24)
177 186
 	{
178
-		for($z=0;$z<$Zbytek;$z++)
179
-		$Dopl.=chr(0);
187
+		for($z=0;$z<$Zbytek;$z++) {
188
+				$Dopl.=chr(0);
189
+		}
180 190
 
181 191
 		for($y=$Height-1;$y>=0;$y--)
182 192
 		{
@@ -196,8 +206,7 @@  discard block
 block discarded – undo
196 206
 		$r=$r and fwrite($f,$ret);
197 207
 		$r=$r and fclose($f);
198 208
 		return $r;
199
-	}
200
-	else
209
+	} else
201 210
 	{
202 211
 		echo $ret;
203 212
 	};
@@ -269,17 +278,20 @@  discard block
 block discarded – undo
269 278
 						imagesetpixel($img,$x,$y,$Palette[$C]);
270 279
 					};
271 280
 					if($jpexs_CurrentBit!=0) {jpexs_freadbyte($f);};
272
-					for($g=0;$g<$Zbytek;$g++)
273
-					jpexs_freadbyte($f);
281
+					for($g=0;$g<$Zbytek;$g++) {
282
+										jpexs_freadbyte($f);
283
+					}
274 284
 				};
275 285
 
276 286
 			};
277 287
 		};
278 288
 
279 289
 
280
-		if($RLECompression==1) //$BI_RLE8
290
+		if($RLECompression==1) {
291
+			//$BI_RLE8
281 292
 		{
282 293
 			$y=$Height;
294
+		}
283 295
 
284 296
 			$pocetb=0;
285 297
 
@@ -292,9 +304,15 @@  discard block
 block discarded – undo
292 304
 
293 305
 				$echoit=false;
294 306
 
295
-				if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>";
296
-				if(($prefix==0)and($suffix==1)) break;
297
-				if(feof($f)) break;
307
+				if($echoit) {
308
+					echo "Prefix: $prefix Suffix: $suffix<BR>";
309
+				}
310
+				if(($prefix==0)and($suffix==1)) {
311
+					break;
312
+				}
313
+				if(feof($f)) {
314
+					break;
315
+				}
298 316
 
299 317
 				while(!(($prefix==0)and($suffix==0)))
300 318
 				{
@@ -308,13 +326,16 @@  discard block
 block discarded – undo
308 326
 					if($prefix>0)
309 327
 					{
310 328
 						$pocet=$prefix;
311
-						for($r=0;$r<$pocet;$r++)
312
-						$Data.=chr($suffix);
329
+						for($r=0;$r<$pocet;$r++) {
330
+												$Data.=chr($suffix);
331
+						}
313 332
 					};
314 333
 					$prefix=jpexs_freadbyte($f);
315 334
 					$suffix=jpexs_freadbyte($f);
316 335
 					$pocetb+=2;
317
-					if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>";
336
+					if($echoit) {
337
+						echo "Prefix: $prefix Suffix: $suffix<BR>";
338
+					}
318 339
 				};
319 340
 
320 341
 				for($x=0;$x<strlen($Data);$x++)
@@ -328,9 +349,11 @@  discard block
 block discarded – undo
328 349
 		};
329 350
 
330 351
 
331
-		if($RLECompression==2) //$BI_RLE4
352
+		if($RLECompression==2) {
353
+			//$BI_RLE4
332 354
 		{
333 355
 			$y=$Height;
356
+		}
334 357
 			$pocetb=0;
335 358
 
336 359
 			/*while(!feof($f))
@@ -345,9 +368,15 @@  discard block
 block discarded – undo
345 368
 
346 369
 				$echoit=false;
347 370
 
348
-				if($echoit)echo "Prefix: $prefix Suffix: $suffix<BR>";
349
-				if(($prefix==0)and($suffix==1)) break;
350
-				if(feof($f)) break;
371
+				if($echoit) {
372
+					echo "Prefix: $prefix Suffix: $suffix<BR>";
373
+				}
374
+				if(($prefix==0)and($suffix==1)) {
375
+					break;
376
+				}
377
+				if(feof($f)) {
378
+					break;
379
+				}
351 380
 
352 381
 				while(!(($prefix==0)and($suffix==0)))
353 382
 				{
@@ -356,9 +385,12 @@  discard block
 block discarded – undo
356 385
 						$pocet=$suffix;
357 386
 
358 387
 						$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);
388
+						for($h=0;$h<$pocet;$h++) {
389
+												$Data.=chr(jpexs_freadbits($f,4));
390
+						}
391
+						if($jpexs_CurrentBit!=0) {
392
+							jpexs_freadbits($f,4);
393
+						}
362 394
 						$pocetb+=ceil(($pocet/2));
363 395
 						if($pocetb%2==1) {jpexs_freadbyte($f); $pocetb++;};
364 396
 					};
@@ -371,8 +403,7 @@  discard block
 block discarded – undo
371 403
 							if($i%2==0)
372 404
 							{
373 405
 								$Data.=chr($suffix%16);
374
-							}
375
-							else
406
+							} else
376 407
 							{
377 408
 								$Data.=chr(floor($suffix/16));
378 409
 							};
@@ -382,7 +413,9 @@  discard block
 block discarded – undo
382 413
 					$prefix=jpexs_freadbyte($f);
383 414
 					$suffix=jpexs_freadbyte($f);
384 415
 					$pocetb+=2;
385
-					if($echoit) echo "Prefix: $prefix Suffix: $suffix<BR>";
416
+					if($echoit) {
417
+						echo "Prefix: $prefix Suffix: $suffix<BR>";
418
+					}
386 419
 				};
387 420
 
388 421
 				for($x=0;$x<strlen($Data);$x++)
@@ -409,17 +442,19 @@  discard block
 block discarded – undo
409 442
 					$G=jpexs_freadbyte($f);
410 443
 					$R=jpexs_freadbyte($f);
411 444
 					$color=imagecolorexact($img,$R,$G,$B);
412
-					if($color==-1) $color=imagecolorallocate($img,$R,$G,$B);
445
+					if($color==-1) {
446
+						$color=imagecolorallocate($img,$R,$G,$B);
447
+					}
413 448
 					imagesetpixel($img,$x,$y,$color);
414 449
 				}
415
-				for($z=0;$z<$Zbytek;$z++)
416
-				jpexs_freadbyte($f);
450
+				for($z=0;$z<$Zbytek;$z++) {
451
+								jpexs_freadbyte($f);
452
+				}
417 453
 			};
418 454
 		};
419 455
 		return $img;
420 456
 
421
-	}
422
-	else{
457
+	} else{
423 458
 		return false;
424 459
 	}
425 460
 
@@ -495,8 +530,7 @@  discard block
 block discarded – undo
495 530
 	if($jpexs_CurrentBit==8)
496 531
 	{
497 532
 		$jpexs_CurrentBit=0;
498
-	}
499
-	else
533
+	} else
500 534
 	{
501 535
 		fseek($f,ftell($f)-1);
502 536
 	};
@@ -524,8 +558,9 @@  discard block
 block discarded – undo
524 558
 {
525 559
 	$bin=decbin($d);
526 560
 	$sbin=strlen($bin);
527
-	for($j=0;$j<$n-$sbin;$j++)
528
-	$bin="0$bin";
561
+	for($j=0;$j<$n-$sbin;$j++) {
562
+		$bin="0$bin";
563
+	}
529 564
 	return $bin;
530 565
 };
531 566
 
Please login to merge, or discard this patch.
class/wideimage/vendor/JPEXS/ico.php 4 patches
Doc Comments   +22 added lines, -2 removed lines patch added patch discarded remove patch
@@ -225,6 +225,10 @@  discard block
 block discarded – undo
225 225
 
226 226
 
227 227
 
228
+/**
229
+ * @param string $filename
230
+ * @param integer $id
231
+ */
228 232
 function jpexs_readIcon($filename,$id,&$Ikona)
229 233
 {
230 234
 global $jpexs_currentBit;
@@ -348,6 +352,9 @@  discard block
 block discarded – undo
348 352
 
349 353
 };
350 354
 
355
+/**
356
+ * @param string $filename
357
+ */
351 358
 function jpexs_GetIconsInfo($filename)
352 359
 {
353 360
 global $jpexs_currentBit;
@@ -414,8 +421,8 @@  discard block
 block discarded – undo
414 421
  * @global int $jpexs_ResVirtualAddress Internal reserved variable
415 422
  * @param string $filename Target exefile
416 423
  * @param string $icoFileNameOrPath Filename to save ico or path (Default "") Path if you want more than 1 icon. If "", the filename is "$icoIndex.ico"
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
- * @return boolean True on successful save
424
+ * @param integer $iconIndex Index(es) of the icon in exefile  (Default -1) If -1, all icons are saved, Can be an array of indexes.
425
+ * @return boolean|null True on successful save
419 426
  */
420 427
 function saveExeIcon($filename,$icoFileNameOrPath="",$iconIndex=-1) /*-1 for all,or can be array*/
421 428
 {
@@ -539,6 +546,7 @@  discard block
 block discarded – undo
539 546
 
540 547
 /**
541 548
  * Internal function for reading exe icons
549
+ * @param integer $offset
542 550
  */
543 551
 function jpexs_readResDirectoryEntry(&$parentRes,$offset)
544 552
 {
@@ -884,6 +892,9 @@  discard block
 block discarded – undo
884 892
 return jpexs_decbinx($d,8);
885 893
 };
886 894
 
895
+/**
896
+ * @param integer $n
897
+ */
887 898
 function jpexs_decbinx($d,$n)
888 899
 {
889 900
 $bin=decbin($d);
@@ -893,6 +904,9 @@  discard block
 block discarded – undo
893 904
 return $bin;
894 905
 };
895 906
 
907
+/**
908
+ * @param integer $byte
909
+ */
896 910
 function jpexs_retBits($byte,$start,$len)
897 911
 {
898 912
 $bin=jpexs_decbin8($byte);
@@ -904,6 +918,9 @@  discard block
 block discarded – undo
904 918
 
905 919
 
906 920
 $jpexs_currentBit=0;
921
+/**
922
+ * @param resource $f
923
+ */
907 924
 function jpexs_freadbits($f,$count)
908 925
 {
909 926
  global $jpexs_currentBit,$jpexs_SMode;
@@ -935,6 +952,9 @@  discard block
 block discarded – undo
935 952
 };
936 953
 
937 954
 
955
+/**
956
+ * @param resource $f
957
+ */
938 958
 function jpexs_freadlngint($f)
939 959
 {
940 960
 return jpexs_freaddword($f);
Please login to merge, or discard this patch.
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 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)
214
-       {
215
-        imagesetpixel($img,$x,$y,$Pruhledna);
216
-       };
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
+	   {
215
+		imagesetpixel($img,$x,$y,$Pruhledna);
216
+	   };
217 217
   imagecolortransparent($img,$Pruhledna);
218 218
  };
219 219
 
@@ -261,29 +261,29 @@  discard block
 block discarded – undo
261 261
  $barev=pow(2,$biBitCount);
262 262
 
263 263
   for($b=0;$b<$barev;$b++)
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);
268
-    jpexs_freadbyte($f);
269
-    };
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);
268
+	jpexs_freadbyte($f);
269
+	};
270 270
 
271 271
 $Zbytek=(4-ceil(($Width/(8/$biBitCount)))%4)%4;
272 272
 
273 273
 
274 274
 for($y=$Height-1;$y>=0;$y--)
275
-    {
276
-     $jpexs_currentBit=0;
277
-     for($x=0;$x<$Width;$x++)
278
-      {
279
-         $C=jpexs_freadbits($f,$biBitCount);
280
-         $Ikona[$p]["Data"][$x][$y]=$C;
281
-      };
282
-
283
-    if($jpexs_currentBit!=0) {jpexs_freadbyte($f);};
284
-    for($g=0;$g<$Zbytek;$g++)
285
-     jpexs_freadbyte($f);
286
-     };
275
+	{
276
+	 $jpexs_currentBit=0;
277
+	 for($x=0;$x<$Width;$x++)
278
+	  {
279
+		 $C=jpexs_freadbits($f,$biBitCount);
280
+		 $Ikona[$p]["Data"][$x][$y]=$C;
281
+	  };
282
+
283
+	if($jpexs_currentBit!=0) {jpexs_freadbyte($f);};
284
+	for($g=0;$g<$Zbytek;$g++)
285
+	 jpexs_freadbyte($f);
286
+	 };
287 287
 
288 288
 }
289 289
 elseif($biBitCount==24)
@@ -291,18 +291,18 @@  discard block
 block discarded – undo
291 291
  $Zbytek=$Width%4;
292 292
 
293 293
    for($y=$Height-1;$y>=0;$y--)
294
-    {
295
-     for($x=0;$x<$Width;$x++)
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;
303
-      }
304
-    for($z=0;$z<$Zbytek;$z++)
305
-     jpexs_freadbyte($f);
294
+	{
295
+	 for($x=0;$x<$Width;$x++)
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;
303
+	  }
304
+	for($z=0;$z<$Zbytek;$z++)
305
+	 jpexs_freadbyte($f);
306 306
    };
307 307
 }
308 308
 elseif($biBitCount==32)
@@ -310,20 +310,20 @@  discard block
 block discarded – undo
310 310
  $Zbytek=$Width%4;
311 311
 
312 312
    for($y=$Height-1;$y>=0;$y--)
313
-    {
314
-     for($x=0;$x<$Width;$x++)
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;
324
-      }
325
-    for($z=0;$z<$Zbytek;$z++)
326
-     jpexs_freadbyte($f);
313
+	{
314
+	 for($x=0;$x<$Width;$x++)
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;
324
+	  }
325
+	for($z=0;$z<$Zbytek;$z++)
326
+	 jpexs_freadbyte($f);
327 327
    };
328 328
 };
329 329
 
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
 //Maska
332 332
 $Zbytek=(4-ceil(($Width/(8)))%4)%4;
333 333
 for($y=$Height-1;$y>=0;$y--)
334
-    {
335
-     $jpexs_currentBit=0;
336
-     for($x=0;$x<$Width;$x++)
337
-      {
338
-         $C=jpexs_freadbits($f,1);
339
-         $Ikona[$p]["Maska"][$x][$y]=$C;
340
-      };
341
-    if($jpexs_currentBit!=0) {jpexs_freadbyte($f);};
342
-    for($g=0;$g<$Zbytek;$g++)
343
-     jpexs_freadbyte($f);
344
-     };
334
+	{
335
+	 $jpexs_currentBit=0;
336
+	 for($x=0;$x<$Width;$x++)
337
+	  {
338
+		 $C=jpexs_freadbits($f,1);
339
+		 $Ikona[$p]["Maska"][$x][$y]=$C;
340
+	  };
341
+	if($jpexs_currentBit!=0) {jpexs_freadbyte($f);};
342
+	for($g=0;$g<$Zbytek;$g++)
343
+	 jpexs_freadbyte($f);
344
+	 };
345 345
 //--------------
346 346
 
347 347
 fclose($f);
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 if(!feof($f)):
373 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);
@@ -436,102 +436,102 @@  discard block
 block discarded – undo
436 436
   fseek($jpexs_f,$PosMagic+$SizeOfOptionalHeader);
437 437
 
438 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
-                {
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
-                };
472
-               fseek($jpexs_f,$val3["DataOffset"]);
473
-               $r++;
474
-             endwhile;
475
-          endwhile;
476
-        endif;
477
-      endwhile;
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"];
491
-               endif;
492
-             endwhile;
493
-           endfor;
494
-           endfor;
495
-          endwhile;
496
-        endif;
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=="")
503
-           {
504
-             $savefile="$r.ico";
505
-           }
506
-           else
507
-           {
508
-            if(($iconIndex==-1)or(is_array($iconIndex)))
509
-              $savefile=$icoFileNameOrPath."$r.ico";
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"];
525
-          endfor;
526
-          for($s=0;$s<count($Ikona[$r]);$s++):
527
-            fwrite($f2,$Ikona[$r][$s]["Data"]);
528
-          endfor;
529
-          fclose($f2);
530
-          $ok=true;
531
-        endif;
532
-      endfor;
533
-      return $ok;
534
-    endif;
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
+				{
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
+				};
472
+			   fseek($jpexs_f,$val3["DataOffset"]);
473
+			   $r++;
474
+			 endwhile;
475
+		  endwhile;
476
+		endif;
477
+	  endwhile;
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"];
491
+			   endif;
492
+			 endwhile;
493
+		   endfor;
494
+		   endfor;
495
+		  endwhile;
496
+		endif;
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=="")
503
+		   {
504
+			 $savefile="$r.ico";
505
+		   }
506
+		   else
507
+		   {
508
+			if(($iconIndex==-1)or(is_array($iconIndex)))
509
+			  $savefile=$icoFileNameOrPath."$r.ico";
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"];
525
+		  endfor;
526
+		  for($s=0;$s<count($Ikona[$r]);$s++):
527
+			fwrite($f2,$Ikona[$r][$s]["Data"]);
528
+		  endfor;
529
+		  fclose($f2);
530
+		  $ok=true;
531
+		endif;
532
+	  endfor;
533
+	  return $ok;
534
+	endif;
535 535
   endfor;
536 536
 
537 537
   fclose($jpexs_f);
@@ -547,45 +547,45 @@  discard block
 block discarded – undo
547 547
 $Res=null;
548 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++):
557
-        //IMAGE_RESOURCE_DIRECTORY_ENTRY
558
-        $ResName=jpexs_freaddword($jpexs_f);
559
-        $lastPos2=ftell($jpexs_f);
560
-        if($ResName>=0x80000000):
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);
567
-        else:
568
-          //Integer Id
569
-          $Identificator=$ResName;
570
-        endif;
571
-
572
-        $ResOffsetToData=jpexs_freaddword($jpexs_f);
573
-        if($ResOffsetToData>=0x80000000):
574
-          $SubResOffset=$ResOffsetToData-0x80000000;
575
-          jpexs_readResDirectoryEntry($Res["$Identificator"],$jpexs_StartOfRsrc+$SubResOffset);
576
-        else:
577
-          $RawDataOffset=$ResOffsetToData;
578
-          $lastPos2=ftell($jpexs_f);
579
-          fseek($jpexs_f,$jpexs_StartOfRsrc+$RawDataOffset);
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);
587
-        endif;
588
-      endfor;
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
+		//IMAGE_RESOURCE_DIRECTORY_ENTRY
558
+		$ResName=jpexs_freaddword($jpexs_f);
559
+		$lastPos2=ftell($jpexs_f);
560
+		if($ResName>=0x80000000):
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);
567
+		else:
568
+		  //Integer Id
569
+		  $Identificator=$ResName;
570
+		endif;
571
+
572
+		$ResOffsetToData=jpexs_freaddword($jpexs_f);
573
+		if($ResOffsetToData>=0x80000000):
574
+		  $SubResOffset=$ResOffsetToData-0x80000000;
575
+		  jpexs_readResDirectoryEntry($Res["$Identificator"],$jpexs_StartOfRsrc+$SubResOffset);
576
+		else:
577
+		  $RawDataOffset=$ResOffsetToData;
578
+		  $lastPos2=ftell($jpexs_f);
579
+		  fseek($jpexs_f,$jpexs_StartOfRsrc+$RawDataOffset);
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);
587
+		endif;
588
+	  endfor;
589 589
 fseek($jpexs_f,$lastPos);
590 590
 $parentRes["Subdir"]=$Res;
591 591
 };
@@ -764,25 +764,25 @@  discard block
 block discarded – undo
764 764
    {
765 765
    $color=imagecolorat($img,$x,$y);
766 766
    if($color==$Transparent)
767
-    $color=imagecolorexact($img,0,0,0);
767
+	$color=imagecolorexact($img,0,0,0);
768 768
    if($color==-1) $color=0;
769 769
    if($color>pow(2,$BitCount)-1) $color=0;
770 770
 
771 771
    $bWrite.=jpexs_decbinx($color,$BitCount);
772 772
    if(strlen($bWrite)==8)
773
-    {
774
-     $ret.=jpexs_inttobyte(bindec($bWrite));
775
-     $bWrite="";
776
-    };
773
+	{
774
+	 $ret.=jpexs_inttobyte(bindec($bWrite));
775
+	 $bWrite="";
776
+	};
777 777
    };
778 778
 
779 779
   if((strlen($bWrite)<8)and(strlen($bWrite)!=0))
780
-    {
781
-     $sl=strlen($bWrite);
782
-     for($t=0;$t<8-$sl;$t++)
783
-      $sl.="0";
784
-     $ret.=jpexs_inttobyte(bindec($bWrite));
785
-    };
780
+	{
781
+	 $sl=strlen($bWrite);
782
+	 for($t=0;$t<8-$sl;$t++)
783
+	  $sl.="0";
784
+	 $ret.=jpexs_inttobyte(bindec($bWrite));
785
+	};
786 786
   for($z=0;$z<$Zbytek;$z++)
787 787
    $ret.=jpexs_inttobyte(0);
788 788
  };
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
    $ret.=jpexs_inttobyte($color["green"]);
802 802
    $ret.=jpexs_inttobyte($color["red"]);
803 803
    if($BitCount==32)
804
-    $ret.=jpexs_inttobyte(0);//Alpha for ICO_XP_COLORS
804
+	$ret.=jpexs_inttobyte(0);//Alpha for ICO_XP_COLORS
805 805
    };
806 806
   for($z=0;$z<$Zbytek;$z++)
807 807
    $ret.=jpexs_inttobyte(0);
@@ -817,14 +817,14 @@  discard block
 block discarded – undo
817 817
   $bOut="";
818 818
   for($x=0;$x<$Width;$x++)
819 819
    {
820
-    if(($Transparent!=-1)and(imagecolorat($img,$x,$y)==$Transparent))
821
-     {
822
-      $bOut.="1";
823
-     }
824
-     else
825
-     {
826
-      $bOut.="0";
827
-     };
820
+	if(($Transparent!=-1)and(imagecolorat($img,$x,$y)==$Transparent))
821
+	 {
822
+	  $bOut.="1";
823
+	 }
824
+	 else
825
+	 {
826
+	  $bOut.="0";
827
+	 };
828 828
    };
829 829
   for($p=0;$p<strlen($bOut);$p+=8)
830 830
   {
Please login to merge, or discard this patch.
Spacing   +460 added lines, -460 removed lines patch added patch discarded remove patch
@@ -69,152 +69,152 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +158 added lines, -85 removed lines patch added patch discarded remove patch
@@ -87,37 +87,54 @@  discard block
 block discarded – undo
87 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 93
   $ColMax=$p;
94
+}
94 95
  };
95 96
 
96
-if(($SizeMax==-1)or($Ikona[$p]["Width"]>=$Ikona[$SizeMax]["Width"]))
97
-if(($icoColorCount==$Ikona[$p]["NumberOfColors"])or($icoColorCount==ICO_MAX_COLOR))
97
+if(($SizeMax==-1)or($Ikona[$p]["Width"]>=$Ikona[$SizeMax]["Width"])) {
98
+	if(($icoColorCount==$Ikona[$p]["NumberOfColors"])or($icoColorCount==ICO_MAX_COLOR))
98 99
  {
99 100
    $SizeMax=$p;
101
+}
100 102
  };
101 103
 
102 104
 
103
-if($Ikona[$p]["NumberOfColors"]==$icoColorCount)
104
-if($Ikona[$p]["Width"]==$icoSize)
105
+if($Ikona[$p]["NumberOfColors"]==$icoColorCount) {
106
+	if($Ikona[$p]["Width"]==$icoSize)
105 107
  {
106 108
 
107 109
  $IconID=$p;
110
+}
108 111
  };
109 112
 };
110 113
 
111
-  if($icoColorCount==ICO_MAX_COLOR) $IconID=$ColMax;
112
-  if($icoSize==ICO_MAX_SIZE) $IconID=$SizeMax;
114
+  if($icoColorCount==ICO_MAX_COLOR) {
115
+  	$IconID=$ColMax;
116
+  }
117
+  if($icoSize==ICO_MAX_SIZE) {
118
+  	$IconID=$SizeMax;
119
+  }
113 120
 
114 121
 $ColName=$icoColorCount;
115 122
 
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!");
123
+if($icoSize==ICO_MAX_SIZE) {
124
+	$icoSize="Max";
125
+}
126
+if($ColName==ICO_TRUE_COLOR) {
127
+	$ColName="True";
128
+}
129
+if($ColName==ICO_XP_COLOR) {
130
+	$ColName="XP";
131
+}
132
+if($ColName==ICO_MAX_COLOR) {
133
+	$ColName="Max";
134
+}
135
+if($IconID==-1) {
136
+	die("Icon with $ColName colors and $icoSize x $icoSize size doesn't exist in this file!");
137
+}
121 138
 
122 139
 
123 140
 jpexs_readIcon($filename,$IconID,$Ikona);
@@ -131,7 +148,9 @@  discard block
 block discarded – undo
131 148
   };
132 149
 
133 150
  $biBitCount=$Ikona[$IconID]["Info"]["BitsPerPixel"];
134
- if($biBitCount==0) $biBitCount=1;
151
+ if($biBitCount==0) {
152
+ 	$biBitCount=1;
153
+ }
135 154
 
136 155
 
137 156
 $Ikona[$IconID]["BitCount"]=$Ikona[$IconID]["Info"]["BitsPerPixel"];
@@ -145,8 +164,10 @@  discard block
 block discarded – undo
145 164
   $backcolor=imagecolorallocate($img,$alphaBgR,$alphaBgG,$alphaBgB);
146 165
   imagefilledrectangle($img,0,0,$Ikona[$IconID]["Width"]-1,$Ikona[$IconID]["Height"]-1,$backcolor);
147 166
 endif;
148
-for($y=0;$y<$Ikona[$IconID]["Height"];$y++)
149
-for($x=0;$x<$Ikona[$IconID]["Width"];$x++)
167
+for($y=0;$y<$Ikona[$IconID]["Height"];$y++) {
168
+	for($x=0;
169
+}
170
+$x<$Ikona[$IconID]["Width"];$x++)
150 171
  {
151 172
  $R=$Ikona[$IconID]["Data"][$x][$y]["r"];
152 173
  $G=$Ikona[$IconID]["Data"][$x][$y]["g"];
@@ -154,47 +175,58 @@  discard block
 block discarded – undo
154 175
  if($Ikona[$IconID]["BitCount"]==32)
155 176
  {
156 177
  $Alpha=127-round($Ikona[$IconID]["Data"][$x][$y]["alpha"]*127/255);
157
- if($Ikona[$IconID]["Maska"][$x][$y]==1) $Alpha=127;
178
+ if($Ikona[$IconID]["Maska"][$x][$y]==1) {
179
+ 	$Alpha=127;
180
+ }
158 181
  $color=imagecolorexactalpha($img,$R,$G,$B,$Alpha);
159
- if($color==-1) $color=imagecolorallocatealpha($img,$R,$G,$B,$Alpha);
182
+ if($color==-1) {
183
+ 	$color=imagecolorallocatealpha($img,$R,$G,$B,$Alpha);
160 184
  }
161
- else
185
+ } else
162 186
  {
163 187
  $color=imagecolorexact($img,$R,$G,$B);
164
- if($color==-1) $color=imagecolorallocate($img,$R,$G,$B);
188
+ if($color==-1) {
189
+ 	$color=imagecolorallocate($img,$R,$G,$B);
190
+ }
165 191
  };
166 192
 
167 193
  imagesetpixel($img,$x,$y,$color);
168 194
 
169 195
  };
170 196
 
171
-}
172
-else
197
+} else
173 198
 {
174 199
 $img=imagecreate($Ikona[$IconID]["Width"],$Ikona[$IconID]["Height"]);
175
-for($p=0;$p<count($Ikona[$IconID]["Paleta"]);$p++)
200
+for($p=0;$p<count($Ikona[$IconID]["Paleta"]);$p++) {
176 201
  $Paleta[$p]=imagecolorallocate($img,$Ikona[$IconID]["Paleta"][$p]["r"],$Ikona[$IconID]["Paleta"][$p]["g"],$Ikona[$IconID]["Paleta"][$p]["b"]);
202
+}
177 203
 
178
-for($y=0;$y<$Ikona[$IconID]["Height"];$y++)
179
-for($x=0;$x<$Ikona[$IconID]["Width"];$x++)
204
+for($y=0;$y<$Ikona[$IconID]["Height"];$y++) {
205
+	for($x=0;
206
+}
207
+$x<$Ikona[$IconID]["Width"];$x++)
180 208
  {
181 209
  imagesetpixel($img,$x,$y,$Paleta[$Ikona[$IconID]["Data"][$x][$y]]);
182 210
  };
183 211
 };
184 212
 $IsTransparent=false;  
185
-for($y=0;$y<$Ikona[$IconID]["Height"];$y++)
186
-for($x=0;$x<$Ikona[$IconID]["Width"];$x++)
213
+for($y=0;$y<$Ikona[$IconID]["Height"];$y++) {
214
+	for($x=0;
215
+}
216
+$x<$Ikona[$IconID]["Width"];$x++) {
187 217
  if($Ikona[$IconID]["Maska"][$x][$y]==1)
188 218
   {
189 219
    $IsTransparent=true;
220
+}
190 221
    break;
191 222
   };
192 223
 if($Ikona[$IconID]["BitCount"]==32)
193 224
 {
194 225
  imagealphablending($img, false);
195
- if(function_exists("imagesavealpha"))
196
-  imagesavealpha($img,true);
197
-};
226
+ if(function_exists("imagesavealpha")) {
227
+   imagesavealpha($img,true);
228
+ }
229
+ };
198 230
 
199 231
 if($IsTransparent)
200 232
  {
@@ -208,11 +240,14 @@  discard block
 block discarded – undo
208 240
 
209 241
    };
210 242
     $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)
243
+    for($y=0;$y<$Ikona[$IconID]["Height"];$y++) {
244
+         for($x=0;
245
+    }
246
+    $x<$Ikona[$IconID]["Width"];$x++) {
247
+           if($Ikona[$IconID]["Maska"][$x][$y]==1)
214 248
        {
215 249
         imagesetpixel($img,$x,$y,$Pruhledna);
250
+     }
216 251
        };
217 252
   imagecolortransparent($img,$Pruhledna);
218 253
  };
@@ -281,12 +316,12 @@  discard block
 block discarded – undo
281 316
       };
282 317
 
283 318
     if($jpexs_currentBit!=0) {jpexs_freadbyte($f);};
284
-    for($g=0;$g<$Zbytek;$g++)
285
-     jpexs_freadbyte($f);
319
+    for($g=0;$g<$Zbytek;$g++) {
320
+         jpexs_freadbyte($f);
321
+    }
286 322
      };
287 323
 
288
-}
289
-elseif($biBitCount==24)
324
+} elseif($biBitCount==24)
290 325
 {
291 326
  $Zbytek=$Width%4;
292 327
 
@@ -301,11 +336,11 @@  discard block
 block discarded – undo
301 336
        $Ikona[$p]["Data"][$x][$y]["g"]=$G;
302 337
        $Ikona[$p]["Data"][$x][$y]["b"]=$B;
303 338
       }
304
-    for($z=0;$z<$Zbytek;$z++)
305
-     jpexs_freadbyte($f);
339
+    for($z=0;$z<$Zbytek;$z++) {
340
+         jpexs_freadbyte($f);
341
+    }
306 342
    };
307
-}
308
-elseif($biBitCount==32)
343
+} elseif($biBitCount==32)
309 344
 {
310 345
  $Zbytek=$Width%4;
311 346
 
@@ -322,8 +357,9 @@  discard block
 block discarded – undo
322 357
        $Ikona[$p]["Data"][$x][$y]["b"]=$B;
323 358
        $Ikona[$p]["Data"][$x][$y]["alpha"]=$Alpha;
324 359
       }
325
-    for($z=0;$z<$Zbytek;$z++)
326
-     jpexs_freadbyte($f);
360
+    for($z=0;$z<$Zbytek;$z++) {
361
+         jpexs_freadbyte($f);
362
+    }
327 363
    };
328 364
 };
329 365
 
@@ -339,8 +375,9 @@  discard block
 block discarded – undo
339 375
          $Ikona[$p]["Maska"][$x][$y]=$C;
340 376
       };
341 377
     if($jpexs_currentBit!=0) {jpexs_freadbyte($f);};
342
-    for($g=0;$g<$Zbytek;$g++)
343
-     jpexs_freadbyte($f);
378
+    for($g=0;$g<$Zbytek;$g++) {
379
+         jpexs_freadbyte($f);
380
+    }
344 381
      };
345 382
 //--------------
346 383
 
@@ -362,7 +399,9 @@  discard block
 block discarded – undo
362 399
   $Ikona[$p]["Width"]=jpexs_freadbyte($f);
363 400
   $Ikona[$p]["Height"]=jpexs_freadbyte($f);
364 401
   $Ikona[$p]["ColorCount"]=jpexs_freadword($f);
365
- if($Ikona[$p]["ColorCount"]==0) $Ikona[$p]["ColorCount"]=256;
402
+ if($Ikona[$p]["ColorCount"]==0) {
403
+ 	$Ikona[$p]["ColorCount"]=256;
404
+ }
366 405
   $Ikona[$p]["Planes"]=jpexs_freadword($f);
367 406
   $Ikona[$p]["BitCount"]=jpexs_freadword($f);
368 407
   $Ikona[$p]["BytesInRes"]=jpexs_freaddword($f);
@@ -399,8 +438,10 @@  discard block
 block discarded – undo
399 438
  $ok=saveExeIcon($filename,"icotemp.dat",$icoIndex);
400 439
  if(!$ok):
401 440
   $im=false;
402
- else:
441
+ else {
442
+ 	:
403 443
    $im=imageCreateFromIco("icotemp.dat",$icoColorCount,$icoSize,$alphaBgR,$alphaBgG,$alphaBgB);
444
+ }
404 445
    unlink("icotemp.dat");
405 446
  endif;
406 447
  return $im;
@@ -422,12 +463,16 @@  discard block
 block discarded – undo
422 463
   global $jpexs_f,$jpexs_StartOfRsrc,$jpexs_ImageBase,$jpexs_ResVirtualAddress;
423 464
   $jpexs_f=fopen($filename,"r");
424 465
   $MZ=fread($jpexs_f,2);
425
-  if($MZ!="MZ") NotValidExe();
466
+  if($MZ!="MZ") {
467
+  	NotValidExe();
468
+  }
426 469
   fseek($jpexs_f,60);
427 470
   $OffsetToNewHeader=jpexs_freaddword($jpexs_f);
428 471
   fseek($jpexs_f,$OffsetToNewHeader);
429 472
   $PE=fread($jpexs_f,2);
430
-  if($PE!="PE") NotValidExe();
473
+  if($PE!="PE") {
474
+  	NotValidExe();
475
+  }
431 476
   fread($jpexs_f,4);
432 477
   $NumberOfSections=jpexs_freadword($jpexs_f);
433 478
   fseek($jpexs_f,ftell($jpexs_f)+12);
@@ -502,11 +547,11 @@  discard block
 block discarded – undo
502 547
           if($icoFileNameOrPath=="")
503 548
            {
504 549
              $savefile="$r.ico";
505
-           }
506
-           else
550
+           } else
507 551
            {
508
-            if(($iconIndex==-1)or(is_array($iconIndex)))
509
-              $savefile=$icoFileNameOrPath."$r.ico";
552
+            if(($iconIndex==-1)or(is_array($iconIndex))) {
553
+                          $savefile=$icoFileNameOrPath."$r.ico";
554
+            }
510 555
            };
511 556
           $f2=fopen($savefile,"w");
512 557
           fwrite($f2,jpexs_inttoword(0));
@@ -564,17 +609,21 @@  discard block
 block discarded – undo
564 609
           $StringLength=jpexs_freadword($jpexs_f);
565 610
           $Identificator=(fread($jpexs_f,$StringLength*2));
566 611
           fseek($jpexs_f,$lastPos2);
567
-        else:
612
+        else {
613
+        	:
568 614
           //Integer Id
569 615
           $Identificator=$ResName;
616
+        }
570 617
         endif;
571 618
 
572 619
         $ResOffsetToData=jpexs_freaddword($jpexs_f);
573 620
         if($ResOffsetToData>=0x80000000):
574 621
           $SubResOffset=$ResOffsetToData-0x80000000;
575 622
           jpexs_readResDirectoryEntry($Res["$Identificator"],$jpexs_StartOfRsrc+$SubResOffset);
576
-        else:
623
+        else {
624
+        	:
577 625
           $RawDataOffset=$ResOffsetToData;
626
+        }
578 627
           $lastPos2=ftell($jpexs_f);
579 628
           fseek($jpexs_f,$jpexs_StartOfRsrc+$RawDataOffset);
580 629
           //IMAGE_RESOURCE_DATA_ENTRY
@@ -601,8 +650,7 @@  discard block
 block discarded – undo
601 650
 {
602 651
 $ImageCount=count($images);
603 652
 $Image=$images;
604
-}
605
-else
653
+} else
606 654
 {
607 655
 $Image[0]=$images;
608 656
 $ImageCount=1;
@@ -637,7 +685,9 @@  discard block
 block discarded – undo
637 685
 $IsTransparent=$Transparent!=-1;
638 686
 
639 687
 
640
-if($IsTransparent) $ColorCount--;
688
+if($IsTransparent) {
689
+	$ColorCount--;
690
+}
641 691
 
642 692
 if($ColorCount==0) {$ColorCount=0; $BitCount=24;};
643 693
 if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;};
@@ -655,12 +705,20 @@  discard block
 block discarded – undo
655 705
 $ret.=jpexs_inttobyte(0);//RESERVED
656 706
 
657 707
 $Planes=0;
658
-if($BitCount>=8) $Planes=1;
708
+if($BitCount>=8) {
709
+	$Planes=1;
710
+}
659 711
 
660 712
 $ret.=jpexs_inttoword($f,$Planes);//PLANES
661
-if($BitCount>=8) $WBitCount=$BitCount;
662
-if($BitCount==4) $WBitCount=0;
663
-if($BitCount==1) $WBitCount=0;
713
+if($BitCount>=8) {
714
+	$WBitCount=$BitCount;
715
+}
716
+if($BitCount==4) {
717
+	$WBitCount=0;
718
+}
719
+if($BitCount==1) {
720
+	$WBitCount=0;
721
+}
664 722
 $ret.=jpexs_inttoword($WBitCount);//BITS
665 723
 
666 724
 $Zbytek=(4-($Width/(8/$BitCount))%4)%4;
@@ -669,8 +727,9 @@  discard block
 block discarded – undo
669 727
 $PalSize=0;
670 728
 
671 729
 $Size=40+($Width/(8/$BitCount)+$Zbytek)*$Height+(($Width/8+$ZbytekMask) * $Height);
672
-if($BitCount<24)
730
+if($BitCount<24) {
673 731
  $Size+=pow(2,$BitCount)*4;
732
+}
674 733
 $IconId=1;
675 734
 $ret.=jpexs_inttodword($Size); //SIZE
676 735
 $OffSet=6+16*$ImageCount+$FullSize;
@@ -691,7 +750,9 @@  discard block
 block discarded – undo
691 750
 $Transparent=imagecolortransparent($img);
692 751
 $IsTransparent=$Transparent!=-1;
693 752
 
694
-if($IsTransparent) $ColorCount--;
753
+if($IsTransparent) {
754
+	$ColorCount--;
755
+}
695 756
 if($ColorCount==0) {$ColorCount=0; $BitCount=24;};
696 757
 if(($ColorCount>0)and($ColorCount<=2)) {$ColorCount=2; $BitCount=1;};
697 758
 if(($ColorCount>2)and($ColorCount<=16)) { $ColorCount=16; $BitCount=4;};
@@ -723,12 +784,16 @@  discard block
 block discarded – undo
723 784
 
724 785
 
725 786
 $CC=$ColorCount;
726
-if($CC==0) $CC=256;
787
+if($CC==0) {
788
+	$CC=256;
789
+}
727 790
 
728 791
 if($BitCount<24)
729 792
 {
730 793
  $ColorTotal=imagecolorstotal($img);
731
- if($IsTransparent) $ColorTotal--;
794
+ if($IsTransparent) {
795
+ 	$ColorTotal--;
796
+ }
732 797
 
733 798
  for($p=0;$p<$ColorTotal;$p++)
734 799
   {
@@ -763,10 +828,15 @@  discard block
 block discarded – undo
763 828
   for($x=0;$x<$Width;$x++)
764 829
    {
765 830
    $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;
831
+   if($color==$Transparent) {
832
+       $color=imagecolorexact($img,0,0,0);
833
+   }
834
+   if($color==-1) {
835
+   	$color=0;
836
+   }
837
+   if($color>pow(2,$BitCount)-1) {
838
+   	$color=0;
839
+   }
770 840
 
771 841
    $bWrite.=jpexs_decbinx($color,$BitCount);
772 842
    if(strlen($bWrite)==8)
@@ -779,12 +849,14 @@  discard block
 block discarded – undo
779 849
   if((strlen($bWrite)<8)and(strlen($bWrite)!=0))
780 850
     {
781 851
      $sl=strlen($bWrite);
782
-     for($t=0;$t<8-$sl;$t++)
783
-      $sl.="0";
852
+     for($t=0;$t<8-$sl;$t++) {
853
+           $sl.="0";
854
+     }
784 855
      $ret.=jpexs_inttobyte(bindec($bWrite));
785 856
     };
786
-  for($z=0;$z<$Zbytek;$z++)
787
-   $ret.=jpexs_inttobyte(0);
857
+  for($z=0;$z<$Zbytek;$z++) {
858
+     $ret.=jpexs_inttobyte(0);
859
+  }
788 860
  };
789 861
 };
790 862
 
@@ -800,11 +872,14 @@  discard block
 block discarded – undo
800 872
    $ret.=jpexs_inttobyte($color["blue"]);
801 873
    $ret.=jpexs_inttobyte($color["green"]);
802 874
    $ret.=jpexs_inttobyte($color["red"]);
803
-   if($BitCount==32)
804
-    $ret.=jpexs_inttobyte(0);//Alpha for ICO_XP_COLORS
875
+   if($BitCount==32) {
876
+       $ret.=jpexs_inttobyte(0);
877
+   }
878
+   //Alpha for ICO_XP_COLORS
805 879
    };
806
-  for($z=0;$z<$Zbytek;$z++)
807
-   $ret.=jpexs_inttobyte(0);
880
+  for($z=0;$z<$Zbytek;$z++) {
881
+     $ret.=jpexs_inttobyte(0);
882
+  }
808 883
  };
809 884
 };
810 885
 
@@ -820,8 +895,7 @@  discard block
 block discarded – undo
820 895
     if(($Transparent!=-1)and(imagecolorat($img,$x,$y)==$Transparent))
821 896
      {
822 897
       $bOut.="1";
823
-     }
824
-     else
898
+     } else
825 899
      {
826 900
       $bOut.="0";
827 901
      };
@@ -852,8 +926,7 @@  discard block
 block discarded – undo
852 926
  $f=fopen($filename,"w");
853 927
  fwrite($f,$ret);
854 928
  fclose($f);
855
-}
856
-else
929
+} else
857 930
 {
858 931
  echo $ret;
859 932
 };
@@ -888,8 +961,9 @@  discard block
 block discarded – undo
888 961
 {
889 962
 $bin=decbin($d);
890 963
 $sbin=strlen($bin);
891
-for($j=0;$j<$n-$sbin;$j++)
964
+for($j=0;$j<$n-$sbin;$j++) {
892 965
  $bin="0$bin";
966
+}
893 967
 return $bin;
894 968
 };
895 969
 
@@ -913,8 +987,7 @@  discard block
 block discarded – undo
913 987
  if($jpexs_currentBit==8)
914 988
   {
915 989
    $jpexs_currentBit=0;
916
-  }
917
- else
990
+  } else
918 991
   {
919 992
    fseek($f,ftell($f)-1);
920 993
   };
Please login to merge, or discard this patch.
class/wideimage/WideImage.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		 * $img = WideImage::load($string);
96 96
 		 * </code>
97 97
 		 * 
98
-		 * @param mixed $source File name, url, binary string, or GD image resource
98
+		 * @param string $source File name, url, binary string, or GD image resource
99 99
 		 * @param string $format Hint for image format
100 100
 		 * @return WideImage_Image WideImage_PaletteImage or WideImage_TrueColorImage instance
101 101
 		 */
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		/**
227 227
 		 * Throws exception if the handle isn't a valid GD resource
228 228
 		 * 
229
-		 * @param mixed $handle The variable to check
229
+		 * @param resource $handle The variable to check
230 230
 		 */
231 231
 		static function assertValidImageHandle($handle)
232 232
 		{
Please login to merge, or discard this patch.
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	/**
3
- * @author Gasper Kozak
4
- * @copyright 2007, 2008, 2009
3
+	 * @author Gasper Kozak
4
+	 * @copyright 2007, 2008, 2009
5 5
 
6 6
     This file is part of WideImage.
7 7
 		
@@ -18,9 +18,8 @@  discard block
 block discarded – undo
18 18
     You should have received a copy of the GNU Lesser General Public License
19 19
     along with WideImage; if not, write to the Free Software
20 20
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
-    
22
-    * @package WideImage
23
-  **/
21
+	 * @package WideImage
22
+	 **/
24 23
 	
25 24
 	require_once(WideImage::path() . 'Exception.php');
26 25
 	require_once(WideImage::path() . 'Image.php');
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		/**
Please login to merge, or discard this patch.
Braces   +35 added lines, -24 removed lines patch added patch discarded remove patch
@@ -74,8 +74,9 @@  discard block
 block discarded – undo
74 74
 		 */
75 75
 		static function path()
76 76
 		{
77
-			if (self::$path === null)
78
-				self::$path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
77
+			if (self::$path === null) {
78
+							self::$path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
79
+			}
79 80
 			return self::$path;
80 81
 		}
81 82
 		
@@ -103,8 +104,9 @@  discard block
 block discarded – undo
103 104
 		{
104 105
 			$predictedSourceType = '';
105 106
 			
106
-			if (!$predictedSourceType && self::isValidImageHandle($source))
107
-				$predictedSourceType = 'Handle';
107
+			if (!$predictedSourceType && self::isValidImageHandle($source)) {
108
+							$predictedSourceType = 'Handle';
109
+			}
108 110
 			
109 111
 			if (!$predictedSourceType)
110 112
 			{
@@ -112,19 +114,22 @@  discard block
 block discarded – undo
112 114
 				$binLength = 64;
113 115
 				$sourceLength = strlen($source);
114 116
 				$maxlen = ($sourceLength > $binLength) ? $binLength : $sourceLength;
115
-				for ($i = 0; $i < $maxlen; $i++)
116
-					if (ord($source[$i]) < 32)
117
+				for ($i = 0; $i < $maxlen; $i++) {
118
+									if (ord($source[$i]) < 32)
117 119
 					{
118 120
 						$predictedSourceType = 'String';
121
+				}
119 122
 						break;
120 123
 					}
121 124
 			}
122 125
 			
123
-			if (isset($_FILES[$source]) && isset($_FILES[$source]['tmp_name']))
124
-				$predictedSourceType = 'Upload';
126
+			if (isset($_FILES[$source]) && isset($_FILES[$source]['tmp_name'])) {
127
+							$predictedSourceType = 'Upload';
128
+			}
125 129
 			
126
-			if (!$predictedSourceType)
127
-				$predictedSourceType = 'File';
130
+			if (!$predictedSourceType) {
131
+							$predictedSourceType = 'File';
132
+			}
128 133
 			
129 134
 			return call_user_func(array('WideImage', 'loadFrom' . $predictedSourceType), $source, $format);
130 135
 		}			
@@ -146,8 +151,9 @@  discard block
 block discarded – undo
146 151
 				$mapper = WideImage_MapperFactory::selectMapper($uri, $format);
147 152
 				$handle = $mapper->load($uri);
148 153
 			}
149
-			if (!self::isValidImageHandle($handle))
150
-				throw new WideImage_InvalidImageSourceException("File '{$uri}' appears to be an invalid image source.");
154
+			if (!self::isValidImageHandle($handle)) {
155
+							throw new WideImage_InvalidImageSourceException("File '{$uri}' appears to be an invalid image source.");
156
+			}
151 157
 			
152 158
 			return self::loadFromHandle($handle);
153 159
 		}
@@ -161,8 +167,9 @@  discard block
 block discarded – undo
161 167
 		static function loadFromString($string)
162 168
 		{
163 169
 			$handle = imagecreatefromstring($string);
164
-			if (!self::isValidImageHandle($handle))
165
-				throw new WideImage_InvalidImageSourceException("String doesn't contain valid image data.");
170
+			if (!self::isValidImageHandle($handle)) {
171
+							throw new WideImage_InvalidImageSourceException("String doesn't contain valid image data.");
172
+			}
166 173
 			
167 174
 			return self::loadFromHandle($handle);
168 175
 		}
@@ -187,13 +194,15 @@  discard block
 block discarded – undo
187 194
 		 */
188 195
 		static function loadFromHandle($handle)
189 196
 		{
190
-			if (!self::isValidImageHandle($handle))
191
-				throw new WideImage_InvalidImageSourceException("Handle is not a valid GD image resource.");
197
+			if (!self::isValidImageHandle($handle)) {
198
+							throw new WideImage_InvalidImageSourceException("Handle is not a valid GD image resource.");
199
+			}
192 200
 			
193
-			if (imageistruecolor($handle))
194
-				return new WideImage_TrueColorImage($handle);
195
-			else
196
-				return new WideImage_PaletteImage($handle);
201
+			if (imageistruecolor($handle)) {
202
+							return new WideImage_TrueColorImage($handle);
203
+			} else {
204
+							return new WideImage_PaletteImage($handle);
205
+			}
197 206
 		}
198 207
 		
199 208
 		/**
@@ -206,8 +215,9 @@  discard block
 block discarded – undo
206 215
 		 */
207 216
 		static function loadFromUpload($field_name)
208 217
 		{
209
-			if (!array_key_exists($field_name, $_FILES) || !file_exists($_FILES[$field_name]['tmp_name']))
210
-				throw new WideImage_InvalidImageSourceException("Upload field '{$field_name}' or file doesn't exist.");
218
+			if (!array_key_exists($field_name, $_FILES) || !file_exists($_FILES[$field_name]['tmp_name'])) {
219
+							throw new WideImage_InvalidImageSourceException("Upload field '{$field_name}' or file doesn't exist.");
220
+			}
211 221
 			
212 222
 			return self::loadFromFile($_FILES[$field_name]['tmp_name'], $_FILES[$field_name]['type']);
213 223
 		}
@@ -230,8 +240,9 @@  discard block
 block discarded – undo
230 240
 		 */
231 241
 		static function assertValidImageHandle($handle)
232 242
 		{
233
-			if (!self::isValidImageHandle($handle))
234
-				throw new WideImage_InvalidImageHandleException("{$handle} is not a valid image handle.");
243
+			if (!self::isValidImageHandle($handle)) {
244
+							throw new WideImage_InvalidImageHandleException("{$handle} is not a valid image handle.");
245
+			}
235 246
 		}
236 247
 		
237 248
 	}
Please login to merge, or discard this patch.