@@ -74,8 +74,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -64,12 +64,14 @@ discard block |
||
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 |
||
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 |
@@ -42,10 +42,11 @@ |
||
42 | 42 | // then trying to save an image to a '' location (which results in an |
43 | 43 | // error, of course). And the same thing works fine for imagepng() and |
44 | 44 | // imagejpeg(). It's a bug! ;) |
45 | - if ($uri) |
|
46 | - imagegif($handle, $uri); |
|
47 | - else |
|
48 | - imagegif($handle); |
|
45 | + if ($uri) { |
|
46 | + imagegif($handle, $uri); |
|
47 | + } else { |
|
48 | + imagegif($handle); |
|
49 | + } |
|
49 | 50 | } |
50 | 51 | } |
51 | 52 | ?> |
52 | 53 | \ No newline at end of file |
@@ -41,10 +41,11 @@ |
||
41 | 41 | |
42 | 42 | function save($handle, $uri = null) |
43 | 43 | { |
44 | - if ($uri == null) |
|
45 | - imagebmp($handle); |
|
46 | - else |
|
47 | - imagebmp($handle, $uri); |
|
44 | + if ($uri == null) { |
|
45 | + imagebmp($handle); |
|
46 | + } else { |
|
47 | + imagebmp($handle, $uri); |
|
48 | + } |
|
48 | 49 | } |
49 | 50 | } |
50 | 51 | ?> |
51 | 52 | \ No newline at end of file |
@@ -36,10 +36,11 @@ |
||
36 | 36 | |
37 | 37 | function save($handle, $uri = null) |
38 | 38 | { |
39 | - if ($uri == null) |
|
40 | - imagegd($handle); |
|
41 | - else |
|
42 | - imagegd($handle, $uri); |
|
39 | + if ($uri == null) { |
|
40 | + imagegd($handle); |
|
41 | + } else { |
|
42 | + imagegd($handle, $uri); |
|
43 | + } |
|
43 | 44 | } |
44 | 45 | } |
45 | 46 | ?> |
46 | 47 | \ No newline at end of file |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | */ |
49 | 49 | static function create($width, $height) |
50 | 50 | { |
51 | - if ($width * $height <= 0 || $width < 0) |
|
52 | - throw new WideImage_InvalidImageDimensionException("Can't create an image with dimensions [$width, $height]."); |
|
51 | + if ($width * $height <= 0 || $width < 0) { |
|
52 | + throw new WideImage_InvalidImageDimensionException("Can't create an image with dimensions [$width, $height]."); |
|
53 | + } |
|
53 | 54 | |
54 | 55 | return new WideImage_TrueColorImage(imagecreatetruecolor($width, $height)); |
55 | 56 | } |
@@ -101,10 +102,11 @@ discard block |
||
101 | 102 | */ |
102 | 103 | function allocateColorAlpha($R, $G = null, $B = null, $A = null) |
103 | 104 | { |
104 | - if (is_array($R)) |
|
105 | - return imageColorAllocateAlpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']); |
|
106 | - else |
|
107 | - return imageColorAllocateAlpha($this->handle, $R, $G, $B, $A); |
|
105 | + if (is_array($R)) { |
|
106 | + return imageColorAllocateAlpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']); |
|
107 | + } else { |
|
108 | + return imageColorAllocateAlpha($this->handle, $R, $G, $B, $A); |
|
109 | + } |
|
108 | 110 | } |
109 | 111 | |
110 | 112 | /** |
@@ -113,19 +115,22 @@ discard block |
||
113 | 115 | function asPalette($nColors = 255, $dither = null, $matchPalette = true) |
114 | 116 | { |
115 | 117 | $nColors = intval($nColors); |
116 | - if ($nColors < 1) |
|
117 | - $nColors = 1; |
|
118 | - elseif ($nColors > 255) |
|
119 | - $nColors = 255; |
|
118 | + if ($nColors < 1) { |
|
119 | + $nColors = 1; |
|
120 | + } elseif ($nColors > 255) { |
|
121 | + $nColors = 255; |
|
122 | + } |
|
120 | 123 | |
121 | - if ($dither === null) |
|
122 | - $dither = $this->isTransparent(); |
|
124 | + if ($dither === null) { |
|
125 | + $dither = $this->isTransparent(); |
|
126 | + } |
|
123 | 127 | |
124 | 128 | $temp = $this->copy(); |
125 | 129 | imagetruecolortopalette($temp->handle, $dither, $nColors); |
126 | 130 | |
127 | - if ($matchPalette == true) |
|
128 | - imagecolormatch($this->handle, $temp->handle); |
|
131 | + if ($matchPalette == true) { |
|
132 | + imagecolormatch($this->handle, $temp->handle); |
|
133 | + } |
|
129 | 134 | |
130 | 135 | if ($this->isTransparent()) |
131 | 136 | { |
@@ -153,10 +158,11 @@ discard block |
||
153 | 158 | */ |
154 | 159 | function getClosestColorAlpha($R, $G = null, $B = null, $A = null) |
155 | 160 | { |
156 | - if (is_array($R)) |
|
157 | - return imagecolorclosestalpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']); |
|
158 | - else |
|
159 | - return imagecolorclosestalpha($this->handle, $R, $G, $B, $A); |
|
161 | + if (is_array($R)) { |
|
162 | + return imagecolorclosestalpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']); |
|
163 | + } else { |
|
164 | + return imagecolorclosestalpha($this->handle, $R, $G, $B, $A); |
|
165 | + } |
|
160 | 166 | } |
161 | 167 | |
162 | 168 | /** |
@@ -174,10 +180,11 @@ discard block |
||
174 | 180 | */ |
175 | 181 | function getExactColorAlpha($R, $G = null, $B = null, $A = null) |
176 | 182 | { |
177 | - if (is_array($R)) |
|
178 | - return imagecolorexactalpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']); |
|
179 | - else |
|
180 | - return imagecolorexactalpha($this->handle, $R, $G, $B, $A); |
|
183 | + if (is_array($R)) { |
|
184 | + return imagecolorexactalpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']); |
|
185 | + } else { |
|
186 | + return imagecolorexactalpha($this->handle, $R, $G, $B, $A); |
|
187 | + } |
|
181 | 188 | } |
182 | 189 | |
183 | 190 | /** |
@@ -186,8 +193,9 @@ discard block |
||
186 | 193 | function getChannels() |
187 | 194 | { |
188 | 195 | $args = func_get_args(); |
189 | - if (count($args) == 1 && is_array($args[0])) |
|
190 | - $args = $args[0]; |
|
196 | + if (count($args) == 1 && is_array($args[0])) { |
|
197 | + $args = $args[0]; |
|
198 | + } |
|
191 | 199 | return WideImage_OperationFactory::get('CopyChannelsTrueColor')->execute($this, $args); |
192 | 200 | } |
193 | 201 |
@@ -87,37 +87,54 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | }; |
@@ -46,7 +46,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -83,8 +83,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |