Test Failed
Push — master ( 398493...d4ef72 )
by Michael
11:04
created
libraries/vendor/smottt/wideimage/lib/WideImage/Operation/ApplyMask.php 1 patch
Indentation   +60 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	/**
2
+    /**
3 3
 ##DOC-SIGNATURE##
4 4
 
5 5
     This file is part of WideImage.
@@ -17,9 +17,8 @@  discard block
 block discarded – undo
17 17
     You should have received a copy of the GNU Lesser General Public License
18 18
     along with WideImage; if not, write to the Free Software
19 19
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
-
21
-    * @package Internal/Operations
22
-  **/
20
+     * @package Internal/Operations
21
+     **/
23 22
 
24 23
 namespace WideImage\Operation;
25 24
 
@@ -32,74 +31,74 @@  discard block
 block discarded – undo
32 31
  */
33 32
 class ApplyMask
34 33
 {
35
-	/**
36
-	 * Applies a mask on the copy of source image
37
-	 *
38
-	 * @param \WideImage\Image $image
39
-	 * @param \WideImage\Image $mask
40
-	 * @param smart_coordinate $left
41
-	 * @param smart_coordinate $top
42
-	 * @return \WideImage\Image
43
-	 */
44
-	public function execute($image, $mask, $left = 0, $top = 0)
45
-	{
46
-		$left = Coordinate::fix($left, $image->getWidth(), $mask->getWidth());
47
-		$top  = Coordinate::fix($top, $image->getHeight(), $mask->getHeight());
34
+    /**
35
+     * Applies a mask on the copy of source image
36
+     *
37
+     * @param \WideImage\Image $image
38
+     * @param \WideImage\Image $mask
39
+     * @param smart_coordinate $left
40
+     * @param smart_coordinate $top
41
+     * @return \WideImage\Image
42
+     */
43
+    public function execute($image, $mask, $left = 0, $top = 0)
44
+    {
45
+        $left = Coordinate::fix($left, $image->getWidth(), $mask->getWidth());
46
+        $top  = Coordinate::fix($top, $image->getHeight(), $mask->getHeight());
48 47
 		
49
-		$width      = $image->getWidth();
50
-		$mask_width = $mask->getWidth();
48
+        $width      = $image->getWidth();
49
+        $mask_width = $mask->getWidth();
51 50
 		
52
-		$height      = $image->getHeight();
53
-		$mask_height = $mask->getHeight();
51
+        $height      = $image->getHeight();
52
+        $mask_height = $mask->getHeight();
54 53
 		
55
-		$result = $image->asTrueColor();
54
+        $result = $image->asTrueColor();
56 55
 		
57
-		$result->alphaBlending(false);
58
-		$result->saveAlpha(true);
56
+        $result->alphaBlending(false);
57
+        $result->saveAlpha(true);
59 58
 		
60
-		$srcTransparentColor = $result->getTransparentColor();
59
+        $srcTransparentColor = $result->getTransparentColor();
61 60
 		
62
-		if ($srcTransparentColor >= 0) {
63
-			$destTransparentColor = $srcTransparentColor;
64
-		} else {
65
-			$destTransparentColor = $result->allocateColorAlpha(255, 255, 255, 127);
66
-		}
61
+        if ($srcTransparentColor >= 0) {
62
+            $destTransparentColor = $srcTransparentColor;
63
+        } else {
64
+            $destTransparentColor = $result->allocateColorAlpha(255, 255, 255, 127);
65
+        }
67 66
 		
68
-		for ($x = 0; $x < $width; $x++) {
69
-			for ($y = 0; $y < $height; $y++) {
70
-				$mx = $x - $left;
71
-				$my = $y - $top;
67
+        for ($x = 0; $x < $width; $x++) {
68
+            for ($y = 0; $y < $height; $y++) {
69
+                $mx = $x - $left;
70
+                $my = $y - $top;
72 71
 				
73
-				if ($mx >= 0 && $mx < $mask_width && $my >= 0 && $my < $mask_height) {
74
-					$srcColor = $image->getColorAt($x, $y);
72
+                if ($mx >= 0 && $mx < $mask_width && $my >= 0 && $my < $mask_height) {
73
+                    $srcColor = $image->getColorAt($x, $y);
75 74
 					
76
-					if ($srcColor == $srcTransparentColor) {
77
-						$destColor = $destTransparentColor;
78
-					} else {
79
-						$maskRGB = $mask->getRGBAt($mx, $my);
75
+                    if ($srcColor == $srcTransparentColor) {
76
+                        $destColor = $destTransparentColor;
77
+                    } else {
78
+                        $maskRGB = $mask->getRGBAt($mx, $my);
80 79
 						
81
-						if ($maskRGB['red'] == 0) {
82
-							$destColor = $destTransparentColor;
83
-						} elseif ($srcColor >= 0) {
84
-							$imageRGB          = $image->getRGBAt($x, $y);
85
-							$level             = ($maskRGB['red'] / 255) * (1 - $imageRGB['alpha'] / 127);
86
-							$imageRGB['alpha'] = 127 - round($level * 127);
80
+                        if ($maskRGB['red'] == 0) {
81
+                            $destColor = $destTransparentColor;
82
+                        } elseif ($srcColor >= 0) {
83
+                            $imageRGB          = $image->getRGBAt($x, $y);
84
+                            $level             = ($maskRGB['red'] / 255) * (1 - $imageRGB['alpha'] / 127);
85
+                            $imageRGB['alpha'] = 127 - round($level * 127);
87 86
 							
88
-							if ($imageRGB['alpha'] == 127) {
89
-								$destColor = $destTransparentColor;
90
-							} else {
91
-								$destColor = $result->allocateColorAlpha($imageRGB);
92
-							}
93
-						} else {
94
-							$destColor = $destTransparentColor;
95
-						}
96
-					}
87
+                            if ($imageRGB['alpha'] == 127) {
88
+                                $destColor = $destTransparentColor;
89
+                            } else {
90
+                                $destColor = $result->allocateColorAlpha($imageRGB);
91
+                            }
92
+                        } else {
93
+                            $destColor = $destTransparentColor;
94
+                        }
95
+                    }
97 96
 					
98
-					$result->setColorAt($x, $y, $destColor);
99
-				}
100
-			}
101
-		}
97
+                    $result->setColorAt($x, $y, $destColor);
98
+                }
99
+            }
100
+        }
102 101
 		
103
-		return $result;
104
-	}
102
+        return $result;
103
+    }
105 104
 }
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/MapperFactory.php 2 patches
Indentation   +77 added lines, -78 removed lines patch added patch discarded remove patch
@@ -18,7 +18,6 @@  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 21
  * @package WideImage
23 22
  **/
24 23
 
@@ -34,99 +33,99 @@  discard block
 block discarded – undo
34 33
  **/
35 34
 abstract class MapperFactory
36 35
 {
37
-	static protected $mappers       = array();
38
-	static protected $customMappers = array();
36
+    static protected $mappers       = array();
37
+    static protected $customMappers = array();
39 38
 	
40
-	static protected $mimeTable = array(
41
-		'image/jpg'   => 'JPEG', 
42
-		'image/jpeg'  => 'JPEG', 
43
-		'image/pjpeg' => 'JPEG', 
44
-		'image/gif'   => 'GIF', 
45
-		'image/png'   => 'PNG',
46
-		'image/webp'  => 'WEBP'
47
-	);
39
+    static protected $mimeTable = array(
40
+        'image/jpg'   => 'JPEG', 
41
+        'image/jpeg'  => 'JPEG', 
42
+        'image/pjpeg' => 'JPEG', 
43
+        'image/gif'   => 'GIF', 
44
+        'image/png'   => 'PNG',
45
+        'image/webp'  => 'WEBP'
46
+    );
48 47
 	
49
-	/**
50
-	 * Returns a mapper, based on the $uri and $format
51
-	 * 
52
-	 * @param string $uri File URI
53
-	 * @param string $format File format (extension or mime-type) or null
54
-	 * @return mixed
55
-	 **/
56
-	public static function selectMapper($uri, $format = null)
57
-	{
58
-		$format = self::determineFormat($uri, $format);
48
+    /**
49
+     * Returns a mapper, based on the $uri and $format
50
+     * 
51
+     * @param string $uri File URI
52
+     * @param string $format File format (extension or mime-type) or null
53
+     * @return mixed
54
+     **/
55
+    public static function selectMapper($uri, $format = null)
56
+    {
57
+        $format = self::determineFormat($uri, $format);
59 58
 		
60
-		if (array_key_exists($format, self::$mappers)) {
61
-			return self::$mappers[$format];
62
-		}
59
+        if (array_key_exists($format, self::$mappers)) {
60
+            return self::$mappers[$format];
61
+        }
63 62
 		
64
-		$mapperClassName = '\\WideImage\\Mapper\\' . $format;
63
+        $mapperClassName = '\\WideImage\\Mapper\\' . $format;
65 64
 		
66
-		// why not use autoloading?
67
-		// if (!class_exists($mapperClassName, false)) {
68
-		if (!class_exists($mapperClassName)) {
69
-			throw new UnsupportedFormatException("Format '{$format}' is not supported.");
70
-		}
65
+        // why not use autoloading?
66
+        // if (!class_exists($mapperClassName, false)) {
67
+        if (!class_exists($mapperClassName)) {
68
+            throw new UnsupportedFormatException("Format '{$format}' is not supported.");
69
+        }
71 70
 		
72
-		if (class_exists($mapperClassName)) {
73
-			self::$mappers[$format] = new $mapperClassName();
74
-			return self::$mappers[$format];
75
-		}
76
-	}
71
+        if (class_exists($mapperClassName)) {
72
+            self::$mappers[$format] = new $mapperClassName();
73
+            return self::$mappers[$format];
74
+        }
75
+    }
77 76
 	
78
-	public static function registerMapper($mapper_class_name, $mime_type, $extension)
79
-	{
80
-		self::$customMappers[$mime_type] = $mapper_class_name;
81
-		self::$mimeTable[$mime_type] = $extension;
82
-	}
77
+    public static function registerMapper($mapper_class_name, $mime_type, $extension)
78
+    {
79
+        self::$customMappers[$mime_type] = $mapper_class_name;
80
+        self::$mimeTable[$mime_type] = $extension;
81
+    }
83 82
 	
84
-	public static function getCustomMappers()
85
-	{
86
-		return self::$customMappers;
87
-	}
83
+    public static function getCustomMappers()
84
+    {
85
+        return self::$customMappers;
86
+    }
88 87
 	
89
-	public static function determineFormat($uri, $format = null)
90
-	{
91
-		if ($format == null) {
92
-			$format = self::extractExtension($uri);
93
-		}
88
+    public static function determineFormat($uri, $format = null)
89
+    {
90
+        if ($format == null) {
91
+            $format = self::extractExtension($uri);
92
+        }
94 93
 		
95
-		// mime-type match
96
-		if (preg_match('~[a-z]*/[a-z-]*~i', $format)) {
97
-			if (isset(self::$mimeTable[strtolower($format)])) {
98
-				return self::$mimeTable[strtolower($format)];
99
-			}
100
-		}
94
+        // mime-type match
95
+        if (preg_match('~[a-z]*/[a-z-]*~i', $format)) {
96
+            if (isset(self::$mimeTable[strtolower($format)])) {
97
+                return self::$mimeTable[strtolower($format)];
98
+            }
99
+        }
101 100
 		
102
-		// clean the string
103
-		$format = strtoupper(preg_replace('/[^a-z0-9_-]/i', '', $format));
104
-		if ($format == 'JPG') {
105
-			$format = 'JPEG';
106
-		}
101
+        // clean the string
102
+        $format = strtoupper(preg_replace('/[^a-z0-9_-]/i', '', $format));
103
+        if ($format == 'JPG') {
104
+            $format = 'JPEG';
105
+        }
107 106
 		
108
-		return $format;
109
-	}
107
+        return $format;
108
+    }
110 109
 	
111
-	public static function mimeType($format)
112
-	{
113
-		$format = strtoupper($format);
110
+    public static function mimeType($format)
111
+    {
112
+        $format = strtoupper($format);
114 113
 		
115
-		if ($format == 'JPG') {
116
-			$format = 'JPEG';
117
-		}
114
+        if ($format == 'JPG') {
115
+            $format = 'JPEG';
116
+        }
118 117
 		
119
-		return array_search($format, self::$mimeTable);
120
-	}
118
+        return array_search($format, self::$mimeTable);
119
+    }
121 120
 	
122
-	public static function extractExtension($uri)
123
-	{
124
-		$p = strrpos($uri, '.');
121
+    public static function extractExtension($uri)
122
+    {
123
+        $p = strrpos($uri, '.');
125 124
 		
126
-		if ($p === false) {
127
-			return '';
128
-		}
125
+        if ($p === false) {
126
+            return '';
127
+        }
129 128
 		
130
-		return substr($uri, $p + 1);
131
-	}
129
+        return substr($uri, $p + 1);
130
+    }
132 131
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 			return self::$mappers[$format];
62 62
 		}
63 63
 		
64
-		$mapperClassName = '\\WideImage\\Mapper\\' . $format;
64
+		$mapperClassName = '\\WideImage\\Mapper\\'.$format;
65 65
 		
66 66
 		// why not use autoloading?
67 67
 		// if (!class_exists($mapperClassName, false)) {
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/vendor/de77/TGA.php 2 patches
Indentation   +154 added lines, -155 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	/**
2
+    /**
3 3
 ##DOC-SIGNATURE##
4 4
 
5 5
     This file is part of WideImage.
@@ -17,9 +17,8 @@  discard block
 block discarded – undo
17 17
     You should have received a copy of the GNU Lesser General Public License
18 18
     along with WideImage; if not, write to the Free Software
19 19
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
-
21
-    * @package Internal/Mappers
22
-  **/
20
+     * @package Internal/Mappers
21
+     **/
23 22
 
24 23
 /**
25 24
  * External code for TGA
@@ -39,155 +38,155 @@  discard block
 block discarded – undo
39 38
 
40 39
 class TGA
41 40
 {
42
-	public static function rle_decode($data, $datalen)
43
-	{
44
-		$len = strlen($data);
45
-
46
-		$out = '';
47
-
48
-		$i = 0;
49
-		$k = 0;
50
-
51
-		while ($i < $len) {
52
-			static::dec_bits(ord($data[$i]), $type, $value);
53
-
54
-			if ($k >= $datalen) {
55
-				break;
56
-			}
57
-
58
-			$i++;
59
-
60
-			if ($type == 0) { //raw
61
-				for ($j = 0; $j < (3 * $value); $j++) {
62
-					$out .= $data[$j+$i];
63
-					$k++;
64
-				}
65
-
66
-				$i += $value * 3;
67
-			} else { //rle
68
-				for ($j = 0; $j < $value; $j++) {
69
-					$out .= $data[$i] . $data[$i+1] . $data[$i+2];
70
-					$k++;
71
-				}
72
-
73
-				$i += 3;
74
-			}
75
-		}
76
-
77
-		return $out;
78
-	}
79
-
80
-	public static function dec_bits($byte, &$type, &$value)
81
-	{
82
-		$type  = ($byte & 0x80) >> 7;
83
-		$value = 1 + ($byte & 0x7F);
84
-	}
85
-
86
-	public static function imagecreatefromstring($bin_data)
87
-	{
88
-		if (!trim($bin_data)) {
89
-			return false;
90
-		}
91
-
92
-		$bin_pos  = 0;
93
-		$header   = substr($bin_data, $bin_pos, 18);
94
-		$bin_pos += 18;
95
-		$header   = unpack(	"cimage_id_len/ccolor_map_type/cimage_type/vcolor_map_origin/vcolor_map_len/" .
96
-							"ccolor_map_entry_size/vx_origin/vy_origin/vwidth/vheight/" .
97
-							"cpixel_size/cdescriptor", $header);
98
-
99
-		switch ($header['image_type']) {
100
-			case 2:		//no palette, uncompressed
101
-			case 10:	//no palette, rle
102
-						break;
103
-			default:	return false;
104
-		}
105
-
106
-		if ($header['pixel_size'] != 24) {
107
-			return false;
108
-			//die('Unsupported TGA color depth');
109
-		}
110
-
111
-		$bytes = $header['pixel_size'] / 8;
112
-
113
-		if ($header['image_id_len'] > 0) {
114
-			$header['image_id'] = substr($bin_data, $bin_pos, $header['image_id_len']);
115
-			$bin_pos += $header['image_id_len'];
116
-		} else {
117
-			$header['image_id'] = '';
118
-		}
119
-
120
-		$im = imagecreatetruecolor($header['width'], $header['height']);
121
-
122
-		$size = $header['width'] * $header['height'] * 3;
123
-
124
-		//-- check whether this is NEW TGA or not
125
-		$pos     = $bin_pos;
126
-		$bin_pos = strlen($bin_data) - 26;
127
-		$newtga  = substr($bin_data, $bin_pos, 26);
128
-
129
-		if (substr($newtga, 8, 16) != 'TRUEVISION-XFILE') {
130
-			$newtga = false;
131
-		}
132
-
133
-		$bin_pos  = strlen($bin_data);
134
-		$datasize = $bin_pos - $pos;
135
-
136
-		if ($newtga) {
137
-			$datasize -= 26;
138
-		}
139
-
140
-		$bin_pos = $pos;
141
-
142
-		//-- end of check
143
-		$data     = substr($bin_data, $bin_pos, $datasize);
144
-		$bin_pos += $datasize;
145
-
146
-		if ($header['image_type'] == 10) {
147
-			$data = self::rle_decode($data, $size);
148
-		}
149
-
150
-		$reverse = self::bit5($header['descriptor']) == 1;
151
-		$pixels  = str_split($data, 3);
152
-
153
-		$i = 0;
154
-
155
-		//read pixels
156
-		if ($reverse) {
157
-		    for ($y = 0; $y < $header['height']; $y++) {
158
-		    	for ($x = 0; $x < $header['width']; $x++) {
159
-		    		imagesetpixel($im, $x, $y, self::dwordize($pixels[$i]));
160
-		    		$i++;
161
-		    	}
162
-		    }
163
-	    } else {
164
-	        for ($y = $header['height']-1; $y >= 0; $y--) {
165
-		    	for ($x=0; $x<$header['width']; $x++) {
166
-		    		imagesetpixel($im, $x, $y, self::dwordize($pixels[$i]));
167
-		    		$i++;
168
-		    	}
169
-		    }
170
-	    }
171
-
172
-		return $im;
173
-	}
174
-
175
-	public static function imagecreatefromtga($filename)
176
-	{
177
-		return self::imagecreatefromstring(file_get_contents($filename));
178
-	}
179
-
180
-	public static function dwordize($str)
181
-	{
182
-		$a = ord($str[0]);
183
-		$b = ord($str[1]);
184
-		$c = ord($str[2]);
185
-
186
-		return $c*256*256 + $b*256 + $a;
187
-	}
188
-
189
-	public static function bit5($x)
190
-	{
191
-		return ($x & 32) >> 5;
192
-	}
41
+    public static function rle_decode($data, $datalen)
42
+    {
43
+        $len = strlen($data);
44
+
45
+        $out = '';
46
+
47
+        $i = 0;
48
+        $k = 0;
49
+
50
+        while ($i < $len) {
51
+            static::dec_bits(ord($data[$i]), $type, $value);
52
+
53
+            if ($k >= $datalen) {
54
+                break;
55
+            }
56
+
57
+            $i++;
58
+
59
+            if ($type == 0) { //raw
60
+                for ($j = 0; $j < (3 * $value); $j++) {
61
+                    $out .= $data[$j+$i];
62
+                    $k++;
63
+                }
64
+
65
+                $i += $value * 3;
66
+            } else { //rle
67
+                for ($j = 0; $j < $value; $j++) {
68
+                    $out .= $data[$i] . $data[$i+1] . $data[$i+2];
69
+                    $k++;
70
+                }
71
+
72
+                $i += 3;
73
+            }
74
+        }
75
+
76
+        return $out;
77
+    }
78
+
79
+    public static function dec_bits($byte, &$type, &$value)
80
+    {
81
+        $type  = ($byte & 0x80) >> 7;
82
+        $value = 1 + ($byte & 0x7F);
83
+    }
84
+
85
+    public static function imagecreatefromstring($bin_data)
86
+    {
87
+        if (!trim($bin_data)) {
88
+            return false;
89
+        }
90
+
91
+        $bin_pos  = 0;
92
+        $header   = substr($bin_data, $bin_pos, 18);
93
+        $bin_pos += 18;
94
+        $header   = unpack(	"cimage_id_len/ccolor_map_type/cimage_type/vcolor_map_origin/vcolor_map_len/" .
95
+                            "ccolor_map_entry_size/vx_origin/vy_origin/vwidth/vheight/" .
96
+                            "cpixel_size/cdescriptor", $header);
97
+
98
+        switch ($header['image_type']) {
99
+            case 2:		//no palette, uncompressed
100
+            case 10:	//no palette, rle
101
+                        break;
102
+            default:	return false;
103
+        }
104
+
105
+        if ($header['pixel_size'] != 24) {
106
+            return false;
107
+            //die('Unsupported TGA color depth');
108
+        }
109
+
110
+        $bytes = $header['pixel_size'] / 8;
111
+
112
+        if ($header['image_id_len'] > 0) {
113
+            $header['image_id'] = substr($bin_data, $bin_pos, $header['image_id_len']);
114
+            $bin_pos += $header['image_id_len'];
115
+        } else {
116
+            $header['image_id'] = '';
117
+        }
118
+
119
+        $im = imagecreatetruecolor($header['width'], $header['height']);
120
+
121
+        $size = $header['width'] * $header['height'] * 3;
122
+
123
+        //-- check whether this is NEW TGA or not
124
+        $pos     = $bin_pos;
125
+        $bin_pos = strlen($bin_data) - 26;
126
+        $newtga  = substr($bin_data, $bin_pos, 26);
127
+
128
+        if (substr($newtga, 8, 16) != 'TRUEVISION-XFILE') {
129
+            $newtga = false;
130
+        }
131
+
132
+        $bin_pos  = strlen($bin_data);
133
+        $datasize = $bin_pos - $pos;
134
+
135
+        if ($newtga) {
136
+            $datasize -= 26;
137
+        }
138
+
139
+        $bin_pos = $pos;
140
+
141
+        //-- end of check
142
+        $data     = substr($bin_data, $bin_pos, $datasize);
143
+        $bin_pos += $datasize;
144
+
145
+        if ($header['image_type'] == 10) {
146
+            $data = self::rle_decode($data, $size);
147
+        }
148
+
149
+        $reverse = self::bit5($header['descriptor']) == 1;
150
+        $pixels  = str_split($data, 3);
151
+
152
+        $i = 0;
153
+
154
+        //read pixels
155
+        if ($reverse) {
156
+            for ($y = 0; $y < $header['height']; $y++) {
157
+                for ($x = 0; $x < $header['width']; $x++) {
158
+                    imagesetpixel($im, $x, $y, self::dwordize($pixels[$i]));
159
+                    $i++;
160
+                }
161
+            }
162
+        } else {
163
+            for ($y = $header['height']-1; $y >= 0; $y--) {
164
+                for ($x=0; $x<$header['width']; $x++) {
165
+                    imagesetpixel($im, $x, $y, self::dwordize($pixels[$i]));
166
+                    $i++;
167
+                }
168
+            }
169
+        }
170
+
171
+        return $im;
172
+    }
173
+
174
+    public static function imagecreatefromtga($filename)
175
+    {
176
+        return self::imagecreatefromstring(file_get_contents($filename));
177
+    }
178
+
179
+    public static function dwordize($str)
180
+    {
181
+        $a = ord($str[0]);
182
+        $b = ord($str[1]);
183
+        $c = ord($str[2]);
184
+
185
+        return $c*256*256 + $b*256 + $a;
186
+    }
187
+
188
+    public static function bit5($x)
189
+    {
190
+        return ($x & 32) >> 5;
191
+    }
193 192
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
 
60 60
 			if ($type == 0) { //raw
61 61
 				for ($j = 0; $j < (3 * $value); $j++) {
62
-					$out .= $data[$j+$i];
62
+					$out .= $data[$j + $i];
63 63
 					$k++;
64 64
 				}
65 65
 
66 66
 				$i += $value * 3;
67 67
 			} else { //rle
68 68
 				for ($j = 0; $j < $value; $j++) {
69
-					$out .= $data[$i] . $data[$i+1] . $data[$i+2];
69
+					$out .= $data[$i].$data[$i + 1].$data[$i + 2];
70 70
 					$k++;
71 71
 				}
72 72
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 		$bin_pos  = 0;
93 93
 		$header   = substr($bin_data, $bin_pos, 18);
94 94
 		$bin_pos += 18;
95
-		$header   = unpack(	"cimage_id_len/ccolor_map_type/cimage_type/vcolor_map_origin/vcolor_map_len/" .
96
-							"ccolor_map_entry_size/vx_origin/vy_origin/vwidth/vheight/" .
95
+		$header   = unpack("cimage_id_len/ccolor_map_type/cimage_type/vcolor_map_origin/vcolor_map_len/".
96
+							"ccolor_map_entry_size/vx_origin/vy_origin/vwidth/vheight/".
97 97
 							"cpixel_size/cdescriptor", $header);
98 98
 
99 99
 		switch ($header['image_type']) {
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 		    	}
162 162
 		    }
163 163
 	    } else {
164
-	        for ($y = $header['height']-1; $y >= 0; $y--) {
165
-		    	for ($x=0; $x<$header['width']; $x++) {
164
+	        for ($y = $header['height'] - 1; $y >= 0; $y--) {
165
+		    	for ($x = 0; $x < $header['width']; $x++) {
166 166
 		    		imagesetpixel($im, $x, $y, self::dwordize($pixels[$i]));
167 167
 		    		$i++;
168 168
 		    	}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		$b = ord($str[1]);
184 184
 		$c = ord($str[2]);
185 185
 
186
-		return $c*256*256 + $b*256 + $a;
186
+		return $c * 256 * 256 + $b * 256 + $a;
187 187
 	}
188 188
 
189 189
 	public static function bit5($x)
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/vendor/de77/BMP.php 2 patches
Indentation   +216 added lines, -217 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-	/**
3
+    /**
4 4
 ##DOC-SIGNATURE##
5 5
 
6 6
     This file is part of WideImage.
@@ -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/Mappers
23
-  **/
21
+     * @package Internal/Mappers
22
+     **/
24 23
 
25 24
 /**
26 25
  * External code for BMP
@@ -40,217 +39,217 @@  discard block
 block discarded – undo
40 39
 
41 40
 class BMP
42 41
 {
43
-	public static function imagebmp(&$img, $filename = false)
44
-	{
45
-		$wid     = imagesx($img);
46
-		$hei     = imagesy($img);
47
-		$wid_pad = str_pad('', $wid % 4, "\0");
48
-
49
-		$size = 54 + ($wid + $wid_pad) * $hei * 3; //fixed
50
-
51
-		//prepare & save header
52
-		$header['identifier']		= 'BM';
53
-		$header['file_size']		= self::dword($size);
54
-		$header['reserved']			= self::dword(0);
55
-		$header['bitmap_data']		= self::dword(54);
56
-		$header['header_size']		= self::dword(40);
57
-		$header['width']			= self::dword($wid);
58
-		$header['height']			= self::dword($hei);
59
-		$header['planes']			= self::word(1);
60
-		$header['bits_per_pixel']	= self::word(24);
61
-		$header['compression']		= self::dword(0);
62
-		$header['data_size']		= self::dword(0);
63
-		$header['h_resolution']		= self::dword(0);
64
-		$header['v_resolution']		= self::dword(0);
65
-		$header['colors']			= self::dword(0);
66
-		$header['important_colors']	= self::dword(0);
67
-
68
-		if ($filename) {
69
-		    $f = fopen($filename, "wb");
70
-
71
-		    foreach ($header as $h) {
72
-		    	fwrite($f, $h);
73
-		    }
74
-
75
-			//save pixels
76
-			for ($y = $hei-1; $y >= 0; $y--) {
77
-				for ($x = 0; $x < $wid; $x++) {
78
-					$rgb = imagecolorat($img, $x, $y);
79
-					fwrite($f, self::byte3($rgb));
80
-				}
81
-
82
-				fwrite($f, $wid_pad);
83
-			}
84
-
85
-			fclose($f);
86
-		} else {
87
-		    foreach ($header as $h) {
88
-		    	echo $h;
89
-		    }
90
-
91
-			//save pixels
92
-			for ($y = $hei-1; $y >= 0; $y--) {
93
-				for ($x = 0; $x < $wid; $x++) {
94
-					$rgb = imagecolorat($img, $x, $y);
95
-					echo self::byte3($rgb);
96
-				}
97
-
98
-				echo $wid_pad;
99
-			}
100
-		}
101
-
102
-		return true;
103
-	}
104
-
105
-	public static function imagecreatefromstring($data)
106
-	{
107
-		//read header
108
-		$pos    = 0;
109
-		$header = substr($data, 0, 54);
110
-		$pos    = 54;
111
-
112
-		if (strlen($header) < 54) {
113
-			return false;
114
-		}
115
-
116
-	    $header = unpack(	'c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' .
117
-							'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/'.
118
-							'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header);
119
-
120
-	    if ($header['identifier1'] != 66 or $header['identifier2'] != 77) {
121
-	    	return false;
122
-	    }
123
-
124
-	    if (!in_array($header['bits_per_pixel'], array(24, 32, 8, 4, 1))) {
125
-	    	return false;
126
-	    }
127
-
128
-		$bps    = $header['bits_per_pixel']; //bits per pixel
129
-	    $wid2   = ceil(($bps/8 * $header['width']) / 4) * 4;
130
-		$colors = $header['colors'];
131
-
132
-	    $wid = $header['width'];
133
-	    $hei = $header['height'];
134
-
135
-	    $img = imagecreatetruecolor($header['width'], $header['height']);
136
-
137
-		//read palette
138
-		if ($bps < 9) {
139
-			for ($i = 0; $i < $colors; $i++) {
140
-				$palette[] = self::undword(substr($data, $pos, 4));
141
-				$pos += 4;
142
-			}
143
-		} else {
144
-			if ($bps == 32) {
145
-				imagealphablending($img, false);
146
-				imagesavealpha($img, true);
147
-			}
148
-
149
-			$palette = array();
150
-		}
151
-
152
-		//read pixels
153
-	    for ($y = $hei-1; $y >= 0; $y--) {
154
-			$row    = substr($data, $pos, $wid2);
155
-			$pos   += $wid2;
156
-			$pixels = self::str_split2($row, $bps, $palette);
157
-
158
-	    	for ($x = 0; $x < $wid; $x++) {
159
-	    		self::makepixel($img, $x, $y, $pixels[$x], $bps);
160
-	    	}
161
-	    }
162
-
163
-		return $img;
164
-	}
165
-
166
-	public static function imagecreatefrombmp($filename)
167
-	{
168
-		return self::imagecreatefromstring(file_get_contents($filename));
169
-	}
170
-
171
-	private static function str_split2($row, $bps, $palette)
172
-	{
173
-		switch ($bps) {
174
-			case 32:
175
-			case 24:	return str_split($row, $bps / 8);
176
-			case  8:	$out   = array();
177
-						$count = strlen($row);
178
-
179
-						for ($i = 0; $i < $count; $i++) {
180
-							$out[] = $palette[	ord($row[$i])		];
181
-						}
182
-
183
-						return $out;
184
-			case  4:	$out   = array();
185
-						$count = strlen($row);
186
-
187
-						for ($i = 0; $i < $count; $i++) {
188
-							$roww  = ord($row[$i]);
189
-							$out[] = $palette[	($roww & 240) >> 4	];
190
-							$out[] = $palette[	($roww & 15) 		];
191
-						}
192
-
193
-						return $out;
194
-			case  1:	$out   = array();
195
-						$count = strlen($row);
196
-
197
-						for ($i = 0; $i < $count; $i++) {
198
-							$roww  = ord($row[$i]);
199
-							$out[] = $palette[	($roww & 128) >> 7	];
200
-							$out[] = $palette[	($roww & 64) >> 6	];
201
-							$out[] = $palette[	($roww & 32) >> 5	];
202
-							$out[] = $palette[	($roww & 16) >> 4	];
203
-							$out[] = $palette[	($roww & 8) >> 3	];
204
-							$out[] = $palette[	($roww & 4) >> 2	];
205
-							$out[] = $palette[	($roww & 2) >> 1	];
206
-							$out[] = $palette[	($roww & 1)			];
207
-						}
208
-
209
-						return $out;
210
-		}
211
-	}
212
-
213
-	private static function makepixel($img, $x, $y, $str, $bps)
214
-	{
215
-		switch ($bps) {
216
-			case 32 :	$a = ord($str[0]);
217
-						$b = ord($str[1]);
218
-						$c = ord($str[2]);
219
-						$d = 256 - ord($str[3]); //TODO: gives imperfect results
220
-						$pixel = $d*256*256*256 + $c*256*256 + $b*256 + $a;
221
-						imagesetpixel($img, $x, $y, $pixel);
222
-						break;
223
-			case 24 :	$a = ord($str[0]);
224
-						$b = ord($str[1]);
225
-						$c = ord($str[2]);
226
-						$pixel = $c*256*256 + $b*256 + $a;
227
-						imagesetpixel($img, $x, $y, $pixel);
228
-						break;
229
-			case 8 :
230
-			case 4 :
231
-			case 1 :	imagesetpixel($img, $x, $y, $str);
232
-						break;
233
-		}
234
-	}
235
-
236
-	private static function byte3($n)
237
-	{
238
-		return chr($n & 255) . chr(($n >> 8) & 255) . chr(($n >> 16) & 255);
239
-	}
240
-
241
-	private static function undword($n)
242
-	{
243
-		$r = unpack("V", $n);
244
-		return $r[1];
245
-	}
246
-
247
-	private static function dword($n)
248
-	{
249
-		return pack("V", $n);
250
-	}
251
-
252
-	private static function word($n)
253
-	{
254
-		return pack("v", $n);
255
-	}
42
+    public static function imagebmp(&$img, $filename = false)
43
+    {
44
+        $wid     = imagesx($img);
45
+        $hei     = imagesy($img);
46
+        $wid_pad = str_pad('', $wid % 4, "\0");
47
+
48
+        $size = 54 + ($wid + $wid_pad) * $hei * 3; //fixed
49
+
50
+        //prepare & save header
51
+        $header['identifier']		= 'BM';
52
+        $header['file_size']		= self::dword($size);
53
+        $header['reserved']			= self::dword(0);
54
+        $header['bitmap_data']		= self::dword(54);
55
+        $header['header_size']		= self::dword(40);
56
+        $header['width']			= self::dword($wid);
57
+        $header['height']			= self::dword($hei);
58
+        $header['planes']			= self::word(1);
59
+        $header['bits_per_pixel']	= self::word(24);
60
+        $header['compression']		= self::dword(0);
61
+        $header['data_size']		= self::dword(0);
62
+        $header['h_resolution']		= self::dword(0);
63
+        $header['v_resolution']		= self::dword(0);
64
+        $header['colors']			= self::dword(0);
65
+        $header['important_colors']	= self::dword(0);
66
+
67
+        if ($filename) {
68
+            $f = fopen($filename, "wb");
69
+
70
+            foreach ($header as $h) {
71
+                fwrite($f, $h);
72
+            }
73
+
74
+            //save pixels
75
+            for ($y = $hei-1; $y >= 0; $y--) {
76
+                for ($x = 0; $x < $wid; $x++) {
77
+                    $rgb = imagecolorat($img, $x, $y);
78
+                    fwrite($f, self::byte3($rgb));
79
+                }
80
+
81
+                fwrite($f, $wid_pad);
82
+            }
83
+
84
+            fclose($f);
85
+        } else {
86
+            foreach ($header as $h) {
87
+                echo $h;
88
+            }
89
+
90
+            //save pixels
91
+            for ($y = $hei-1; $y >= 0; $y--) {
92
+                for ($x = 0; $x < $wid; $x++) {
93
+                    $rgb = imagecolorat($img, $x, $y);
94
+                    echo self::byte3($rgb);
95
+                }
96
+
97
+                echo $wid_pad;
98
+            }
99
+        }
100
+
101
+        return true;
102
+    }
103
+
104
+    public static function imagecreatefromstring($data)
105
+    {
106
+        //read header
107
+        $pos    = 0;
108
+        $header = substr($data, 0, 54);
109
+        $pos    = 54;
110
+
111
+        if (strlen($header) < 54) {
112
+            return false;
113
+        }
114
+
115
+        $header = unpack(	'c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' .
116
+                            'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/'.
117
+                            'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header);
118
+
119
+        if ($header['identifier1'] != 66 or $header['identifier2'] != 77) {
120
+            return false;
121
+        }
122
+
123
+        if (!in_array($header['bits_per_pixel'], array(24, 32, 8, 4, 1))) {
124
+            return false;
125
+        }
126
+
127
+        $bps    = $header['bits_per_pixel']; //bits per pixel
128
+        $wid2   = ceil(($bps/8 * $header['width']) / 4) * 4;
129
+        $colors = $header['colors'];
130
+
131
+        $wid = $header['width'];
132
+        $hei = $header['height'];
133
+
134
+        $img = imagecreatetruecolor($header['width'], $header['height']);
135
+
136
+        //read palette
137
+        if ($bps < 9) {
138
+            for ($i = 0; $i < $colors; $i++) {
139
+                $palette[] = self::undword(substr($data, $pos, 4));
140
+                $pos += 4;
141
+            }
142
+        } else {
143
+            if ($bps == 32) {
144
+                imagealphablending($img, false);
145
+                imagesavealpha($img, true);
146
+            }
147
+
148
+            $palette = array();
149
+        }
150
+
151
+        //read pixels
152
+        for ($y = $hei-1; $y >= 0; $y--) {
153
+            $row    = substr($data, $pos, $wid2);
154
+            $pos   += $wid2;
155
+            $pixels = self::str_split2($row, $bps, $palette);
156
+
157
+            for ($x = 0; $x < $wid; $x++) {
158
+                self::makepixel($img, $x, $y, $pixels[$x], $bps);
159
+            }
160
+        }
161
+
162
+        return $img;
163
+    }
164
+
165
+    public static function imagecreatefrombmp($filename)
166
+    {
167
+        return self::imagecreatefromstring(file_get_contents($filename));
168
+    }
169
+
170
+    private static function str_split2($row, $bps, $palette)
171
+    {
172
+        switch ($bps) {
173
+            case 32:
174
+            case 24:	return str_split($row, $bps / 8);
175
+            case  8:	$out   = array();
176
+                        $count = strlen($row);
177
+
178
+                        for ($i = 0; $i < $count; $i++) {
179
+                            $out[] = $palette[	ord($row[$i])		];
180
+                        }
181
+
182
+                        return $out;
183
+            case  4:	$out   = array();
184
+                        $count = strlen($row);
185
+
186
+                        for ($i = 0; $i < $count; $i++) {
187
+                            $roww  = ord($row[$i]);
188
+                            $out[] = $palette[	($roww & 240) >> 4	];
189
+                            $out[] = $palette[	($roww & 15) 		];
190
+                        }
191
+
192
+                        return $out;
193
+            case  1:	$out   = array();
194
+                        $count = strlen($row);
195
+
196
+                        for ($i = 0; $i < $count; $i++) {
197
+                            $roww  = ord($row[$i]);
198
+                            $out[] = $palette[	($roww & 128) >> 7	];
199
+                            $out[] = $palette[	($roww & 64) >> 6	];
200
+                            $out[] = $palette[	($roww & 32) >> 5	];
201
+                            $out[] = $palette[	($roww & 16) >> 4	];
202
+                            $out[] = $palette[	($roww & 8) >> 3	];
203
+                            $out[] = $palette[	($roww & 4) >> 2	];
204
+                            $out[] = $palette[	($roww & 2) >> 1	];
205
+                            $out[] = $palette[	($roww & 1)			];
206
+                        }
207
+
208
+                        return $out;
209
+        }
210
+    }
211
+
212
+    private static function makepixel($img, $x, $y, $str, $bps)
213
+    {
214
+        switch ($bps) {
215
+            case 32 :	$a = ord($str[0]);
216
+                        $b = ord($str[1]);
217
+                        $c = ord($str[2]);
218
+                        $d = 256 - ord($str[3]); //TODO: gives imperfect results
219
+                        $pixel = $d*256*256*256 + $c*256*256 + $b*256 + $a;
220
+                        imagesetpixel($img, $x, $y, $pixel);
221
+                        break;
222
+            case 24 :	$a = ord($str[0]);
223
+                        $b = ord($str[1]);
224
+                        $c = ord($str[2]);
225
+                        $pixel = $c*256*256 + $b*256 + $a;
226
+                        imagesetpixel($img, $x, $y, $pixel);
227
+                        break;
228
+            case 8 :
229
+            case 4 :
230
+            case 1 :	imagesetpixel($img, $x, $y, $str);
231
+                        break;
232
+        }
233
+    }
234
+
235
+    private static function byte3($n)
236
+    {
237
+        return chr($n & 255) . chr(($n >> 8) & 255) . chr(($n >> 16) & 255);
238
+    }
239
+
240
+    private static function undword($n)
241
+    {
242
+        $r = unpack("V", $n);
243
+        return $r[1];
244
+    }
245
+
246
+    private static function dword($n)
247
+    {
248
+        return pack("V", $n);
249
+    }
250
+
251
+    private static function word($n)
252
+    {
253
+        return pack("v", $n);
254
+    }
256 255
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
 		$size = 54 + ($wid + $wid_pad) * $hei * 3; //fixed
50 50
 
51 51
 		//prepare & save header
52
-		$header['identifier']		= 'BM';
52
+		$header['identifier'] = 'BM';
53 53
 		$header['file_size']		= self::dword($size);
54 54
 		$header['reserved']			= self::dword(0);
55 55
 		$header['bitmap_data']		= self::dword(54);
56 56
 		$header['header_size']		= self::dword(40);
57
-		$header['width']			= self::dword($wid);
57
+		$header['width'] = self::dword($wid);
58 58
 		$header['height']			= self::dword($hei);
59 59
 		$header['planes']			= self::word(1);
60
-		$header['bits_per_pixel']	= self::word(24);
61
-		$header['compression']		= self::dword(0);
62
-		$header['data_size']		= self::dword(0);
60
+		$header['bits_per_pixel'] = self::word(24);
61
+		$header['compression'] = self::dword(0);
62
+		$header['data_size'] = self::dword(0);
63 63
 		$header['h_resolution']		= self::dword(0);
64 64
 		$header['v_resolution']		= self::dword(0);
65
-		$header['colors']			= self::dword(0);
66
-		$header['important_colors']	= self::dword(0);
65
+		$header['colors'] = self::dword(0);
66
+		$header['important_colors'] = self::dword(0);
67 67
 
68 68
 		if ($filename) {
69 69
 		    $f = fopen($filename, "wb");
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		    }
74 74
 
75 75
 			//save pixels
76
-			for ($y = $hei-1; $y >= 0; $y--) {
76
+			for ($y = $hei - 1; $y >= 0; $y--) {
77 77
 				for ($x = 0; $x < $wid; $x++) {
78 78
 					$rgb = imagecolorat($img, $x, $y);
79 79
 					fwrite($f, self::byte3($rgb));
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		    }
90 90
 
91 91
 			//save pixels
92
-			for ($y = $hei-1; $y >= 0; $y--) {
92
+			for ($y = $hei - 1; $y >= 0; $y--) {
93 93
 				for ($x = 0; $x < $wid; $x++) {
94 94
 					$rgb = imagecolorat($img, $x, $y);
95 95
 					echo self::byte3($rgb);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			return false;
114 114
 		}
115 115
 
116
-	    $header = unpack(	'c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' .
116
+	    $header = unpack('c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/'.
117 117
 							'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/'.
118 118
 							'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header);
119 119
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	    }
127 127
 
128 128
 		$bps    = $header['bits_per_pixel']; //bits per pixel
129
-	    $wid2   = ceil(($bps/8 * $header['width']) / 4) * 4;
129
+	    $wid2 = ceil(($bps / 8 * $header['width']) / 4) * 4;
130 130
 		$colors = $header['colors'];
131 131
 
132 132
 	    $wid = $header['width'];
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		}
151 151
 
152 152
 		//read pixels
153
-	    for ($y = $hei-1; $y >= 0; $y--) {
153
+	    for ($y = $hei - 1; $y >= 0; $y--) {
154 154
 			$row    = substr($data, $pos, $wid2);
155 155
 			$pos   += $wid2;
156 156
 			$pixels = self::str_split2($row, $bps, $palette);
@@ -173,37 +173,37 @@  discard block
 block discarded – undo
173 173
 		switch ($bps) {
174 174
 			case 32:
175 175
 			case 24:	return str_split($row, $bps / 8);
176
-			case  8:	$out   = array();
176
+			case  8:	$out = array();
177 177
 						$count = strlen($row);
178 178
 
179 179
 						for ($i = 0; $i < $count; $i++) {
180
-							$out[] = $palette[	ord($row[$i])		];
180
+							$out[] = $palette[ord($row[$i])];
181 181
 						}
182 182
 
183 183
 						return $out;
184
-			case  4:	$out   = array();
184
+			case  4:	$out = array();
185 185
 						$count = strlen($row);
186 186
 
187 187
 						for ($i = 0; $i < $count; $i++) {
188 188
 							$roww  = ord($row[$i]);
189
-							$out[] = $palette[	($roww & 240) >> 4	];
190
-							$out[] = $palette[	($roww & 15) 		];
189
+							$out[] = $palette[($roww & 240) >> 4];
190
+							$out[] = $palette[($roww & 15)];
191 191
 						}
192 192
 
193 193
 						return $out;
194
-			case  1:	$out   = array();
194
+			case  1:	$out = array();
195 195
 						$count = strlen($row);
196 196
 
197 197
 						for ($i = 0; $i < $count; $i++) {
198 198
 							$roww  = ord($row[$i]);
199
-							$out[] = $palette[	($roww & 128) >> 7	];
200
-							$out[] = $palette[	($roww & 64) >> 6	];
201
-							$out[] = $palette[	($roww & 32) >> 5	];
202
-							$out[] = $palette[	($roww & 16) >> 4	];
203
-							$out[] = $palette[	($roww & 8) >> 3	];
204
-							$out[] = $palette[	($roww & 4) >> 2	];
205
-							$out[] = $palette[	($roww & 2) >> 1	];
206
-							$out[] = $palette[	($roww & 1)			];
199
+							$out[] = $palette[($roww & 128) >> 7];
200
+							$out[] = $palette[($roww & 64) >> 6];
201
+							$out[] = $palette[($roww & 32) >> 5];
202
+							$out[] = $palette[($roww & 16) >> 4];
203
+							$out[] = $palette[($roww & 8) >> 3];
204
+							$out[] = $palette[($roww & 4) >> 2];
205
+							$out[] = $palette[($roww & 2) >> 1];
206
+							$out[] = $palette[($roww & 1)];
207 207
 						}
208 208
 
209 209
 						return $out;
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 						$b = ord($str[1]);
218 218
 						$c = ord($str[2]);
219 219
 						$d = 256 - ord($str[3]); //TODO: gives imperfect results
220
-						$pixel = $d*256*256*256 + $c*256*256 + $b*256 + $a;
220
+						$pixel = $d * 256 * 256 * 256 + $c * 256 * 256 + $b * 256 + $a;
221 221
 						imagesetpixel($img, $x, $y, $pixel);
222 222
 						break;
223 223
 			case 24 :	$a = ord($str[0]);
224 224
 						$b = ord($str[1]);
225 225
 						$c = ord($str[2]);
226
-						$pixel = $c*256*256 + $b*256 + $a;
226
+						$pixel = $c * 256 * 256 + $b * 256 + $a;
227 227
 						imagesetpixel($img, $x, $y, $pixel);
228 228
 						break;
229 229
 			case 8 :
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
 	private static function byte3($n)
237 237
 	{
238
-		return chr($n & 255) . chr(($n >> 8) & 255) . chr(($n >> 16) & 255);
238
+		return chr($n & 255).chr(($n >> 8) & 255).chr(($n >> 16) & 255);
239 239
 	}
240 240
 
241 241
 	private static function undword($n)
Please login to merge, or discard this patch.
libraries/vendor/smottt/wideimage/lib/WideImage/Exception/Exception.php 1 patch
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,6 @@
 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 21
  * @package WideImage
23 22
 **/
24 23
 
Please login to merge, or discard this patch.
class/libraries/vendor/smottt/wideimage/lib/WideImage/OperationFactory.php 2 patches
Indentation   +18 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	/**
2
+    /**
3 3
 ##DOC-SIGNATURE##
4 4
 
5 5
     This file is part of WideImage.
@@ -17,9 +17,8 @@  discard block
 block discarded – undo
17 17
     You should have received a copy of the GNU Lesser General Public License
18 18
     along with WideImage; if not, write to the Free Software
19 19
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
-
21
-	* @package Internals
22
-  **/
20
+     * @package Internals
21
+     **/
23 22
 
24 23
 namespace WideImage;
25 24
 
@@ -33,24 +32,24 @@  discard block
 block discarded – undo
33 32
  **/
34 33
 class OperationFactory
35 34
 {
36
-	protected static $cache = array();
35
+    protected static $cache = array();
37 36
 	
38
-	public static function get($operationName)
39
-	{
40
-		$lcname = strtolower($operationName);
37
+    public static function get($operationName)
38
+    {
39
+        $lcname = strtolower($operationName);
41 40
 		
42
-		if (!isset(self::$cache[$lcname])) {
43
-			$opClassName = "\\WideImage\\Operation\\" . ucfirst($operationName);
41
+        if (!isset(self::$cache[$lcname])) {
42
+            $opClassName = "\\WideImage\\Operation\\" . ucfirst($operationName);
44 43
 			
45
-			// why not use autoloading?			
46
-			// if (!class_exists($opClassName, false)) {
47
-			if (!class_exists($opClassName)) {
48
-				throw new UnknownImageOperationException("Can't load '{$operationName}' operation.");
49
-			}
44
+            // why not use autoloading?			
45
+            // if (!class_exists($opClassName, false)) {
46
+            if (!class_exists($opClassName)) {
47
+                throw new UnknownImageOperationException("Can't load '{$operationName}' operation.");
48
+            }
50 49
 			
51
-			self::$cache[$lcname] = new $opClassName();
52
-		}
50
+            self::$cache[$lcname] = new $opClassName();
51
+        }
53 52
 		
54
-		return self::$cache[$lcname];
55
-	}
53
+        return self::$cache[$lcname];
54
+    }
56 55
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 		$lcname = strtolower($operationName);
41 41
 		
42 42
 		if (!isset(self::$cache[$lcname])) {
43
-			$opClassName = "\\WideImage\\Operation\\" . ucfirst($operationName);
43
+			$opClassName = "\\WideImage\\Operation\\".ucfirst($operationName);
44 44
 			
45 45
 			// why not use autoloading?			
46 46
 			// if (!class_exists($opClassName, false)) {
Please login to merge, or discard this patch.
htdocs/class/libraries/vendor/smottt/wideimage/lib/WideImage/Canvas.php 2 patches
Indentation   +116 added lines, -117 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	/**
2
+    /**
3 3
 ##DOC-SIGNATURE##
4 4
 
5 5
     This file is part of WideImage.
@@ -17,9 +17,8 @@  discard block
 block discarded – undo
17 17
     You should have received a copy of the GNU Lesser General Public License
18 18
     along with WideImage; if not, write to the Free Software
19 19
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
-    
21
-    * @package WideImage
22
-  **/
20
+     * @package WideImage
21
+     **/
23 22
 
24 23
 namespace WideImage;
25 24
 
@@ -33,129 +32,129 @@  discard block
 block discarded – undo
33 32
  */
34 33
 class Canvas
35 34
 {
36
-	protected $handle = 0;
37
-	protected $image  = null;
38
-	protected $font   = null;
35
+    protected $handle = 0;
36
+    protected $image  = null;
37
+    protected $font   = null;
39 38
 	
40
-	/**
41
-	 * Creates a canvas object that writes to the image passed as a parameter
42
-	 *
43
-	 * Shouldn't be used directly, use \WideImage\Image::getCanvas() instead.
44
-	 *
45
-	 * @param \WideImage\Image $img Image object
46
-	 */
47
-	public function __construct($img)
48
-	{
49
-		$this->handle = $img->getHandle();
50
-		$this->image  = $img;
51
-	}
39
+    /**
40
+     * Creates a canvas object that writes to the image passed as a parameter
41
+     *
42
+     * Shouldn't be used directly, use \WideImage\Image::getCanvas() instead.
43
+     *
44
+     * @param \WideImage\Image $img Image object
45
+     */
46
+    public function __construct($img)
47
+    {
48
+        $this->handle = $img->getHandle();
49
+        $this->image  = $img;
50
+    }
52 51
 	
53
-	/**
54
-	 * Sets the active font. Can be an instance of 
55
-	 * \WideImage\Font\TTF, \WideImage\Font\PS, or \WideImage\Font\GDF.
56
-	 * 
57
-	 * @param object $font Font object to set for writeText()
58
-	 */
59
-	public function setFont($font)
60
-	{
61
-		$this->font = $font;
62
-	}
52
+    /**
53
+     * Sets the active font. Can be an instance of 
54
+     * \WideImage\Font\TTF, \WideImage\Font\PS, or \WideImage\Font\GDF.
55
+     * 
56
+     * @param object $font Font object to set for writeText()
57
+     */
58
+    public function setFont($font)
59
+    {
60
+        $this->font = $font;
61
+    }
63 62
 	
64
-	/**
65
-	 * Creates and sets the current font
66
-	 * 
67
-	 * The supported font types are: TTF/OTF, PS, and GDF.
68
-	 * Font type is detected from the extension. If the $file parameter doesn't have an extension, TTF font is presumed.
69
-	 * 
70
-	 * Note: not all parameters are supported by all fonts.
71
-	 * 
72
-	 * @param string $file Font file name (string)
73
-	 * @param int $size Font size (supported for TTF/OTF and PS fonts, ignored for GDF)
74
-	 * @param int $color Text color
75
-	 * @param int $bgcolor Background color (supported only for PS font, ignored for TTF and PS)
76
-	 * @return mixed One of the \WideImage\Font\* objects
77
-	 */
78
-	public function useFont($file, $size = 12, $color = 0, $bgcolor = null)
79
-	{
80
-		$p = strrpos($file, '.');
63
+    /**
64
+     * Creates and sets the current font
65
+     * 
66
+     * The supported font types are: TTF/OTF, PS, and GDF.
67
+     * Font type is detected from the extension. If the $file parameter doesn't have an extension, TTF font is presumed.
68
+     * 
69
+     * Note: not all parameters are supported by all fonts.
70
+     * 
71
+     * @param string $file Font file name (string)
72
+     * @param int $size Font size (supported for TTF/OTF and PS fonts, ignored for GDF)
73
+     * @param int $color Text color
74
+     * @param int $bgcolor Background color (supported only for PS font, ignored for TTF and PS)
75
+     * @return mixed One of the \WideImage\Font\* objects
76
+     */
77
+    public function useFont($file, $size = 12, $color = 0, $bgcolor = null)
78
+    {
79
+        $p = strrpos($file, '.');
81 80
 		
82
-		if ($p === false || $p < strlen($file) - 4) {
83
-			$ext = 'ttf';
84
-		} else {
85
-			$ext = strtolower(substr($file, $p + 1));
86
-		}
81
+        if ($p === false || $p < strlen($file) - 4) {
82
+            $ext = 'ttf';
83
+        } else {
84
+            $ext = strtolower(substr($file, $p + 1));
85
+        }
87 86
 		
88
-		if ($ext == 'ttf' || $ext == 'otf') {
89
-			$font = new Font\TTF($file, $size, $color);
90
-		} elseif ($ext == 'ps') {
91
-			$font = new Font\PS($file, $size, $color, $bgcolor);
92
-		} elseif ($ext == 'gdf') {
93
-			$font = new Font\GDF($file, $color);
94
-		} else {
95
-			throw new InvalidFontFileException("'$file' appears to be an invalid font file.");
96
-		}
87
+        if ($ext == 'ttf' || $ext == 'otf') {
88
+            $font = new Font\TTF($file, $size, $color);
89
+        } elseif ($ext == 'ps') {
90
+            $font = new Font\PS($file, $size, $color, $bgcolor);
91
+        } elseif ($ext == 'gdf') {
92
+            $font = new Font\GDF($file, $color);
93
+        } else {
94
+            throw new InvalidFontFileException("'$file' appears to be an invalid font file.");
95
+        }
97 96
 		
98
-		$this->setFont($font);
99
-		return $font;
100
-	}
97
+        $this->setFont($font);
98
+        return $font;
99
+    }
101 100
 	
102
-	/**
103
-	 * Write text on the image at specified position
104
-	 * 
105
-	 * You must set a font with a call to \WideImage\Canvas::setFont() prior to writing text to the image.
106
-	 * 
107
-	 * Smart coordinates are supported for $x and $y arguments, but currently only for TTF/OTF fonts.
108
-	 * 
109
-	 * Example:
110
-	 * <code>
111
-	 * $img = WideImage::load('pic.jpg');
112
-	 * $canvas = $img->getCanvas();
113
-	 * $canvas->useFont('Verdana.ttf', 16, $img->allocateColor(255, 0, 0));
114
-	 * $canvas->writeText('right', 'bottom', 'www.website.com');
115
-	 * </code>
116
-	 * 
117
-	 * @param int $x Left
118
-	 * @param int $y Top
119
-	 * @param string $text Text to write
120
-	 * @param int $angle The angle, defaults to 0
121
-	 */
122
-	public function writeText($x, $y, $text, $angle = 0)
123
-	{
124
-		if ($this->font === null) {
125
-			throw new NoFontException("Can't write text without a font.");
126
-		}
101
+    /**
102
+     * Write text on the image at specified position
103
+     * 
104
+     * You must set a font with a call to \WideImage\Canvas::setFont() prior to writing text to the image.
105
+     * 
106
+     * Smart coordinates are supported for $x and $y arguments, but currently only for TTF/OTF fonts.
107
+     * 
108
+     * Example:
109
+     * <code>
110
+     * $img = WideImage::load('pic.jpg');
111
+     * $canvas = $img->getCanvas();
112
+     * $canvas->useFont('Verdana.ttf', 16, $img->allocateColor(255, 0, 0));
113
+     * $canvas->writeText('right', 'bottom', 'www.website.com');
114
+     * </code>
115
+     * 
116
+     * @param int $x Left
117
+     * @param int $y Top
118
+     * @param string $text Text to write
119
+     * @param int $angle The angle, defaults to 0
120
+     */
121
+    public function writeText($x, $y, $text, $angle = 0)
122
+    {
123
+        if ($this->font === null) {
124
+            throw new NoFontException("Can't write text without a font.");
125
+        }
127 126
 		
128
-		$angle = - floatval($angle);
127
+        $angle = - floatval($angle);
129 128
 		
130
-		if ($angle < 0) {
131
-			$angle = 360 + $angle;
132
-		}
129
+        if ($angle < 0) {
130
+            $angle = 360 + $angle;
131
+        }
133 132
 		
134
-		$angle = $angle % 360;
133
+        $angle = $angle % 360;
135 134
 		
136
-		$this->font->writeText($this->image, $x, $y, $text, $angle);
137
-	}
135
+        $this->font->writeText($this->image, $x, $y, $text, $angle);
136
+    }
138 137
 	
139
-	/**
140
-	 * A magic method that allows you to call any PHP function that starts with "image".
141
-	 * 
142
-	 * This is a shortcut to call custom functions on the image handle.
143
-	 * 
144
-	 * Example:
145
-	 * <code>
146
-	 * $img = WideImage::load('pic.jpg');
147
-	 * $canvas = $img->getCanvas();
148
-	 * $canvas->filledRect(10, 10, 20, 30, $img->allocateColor(0, 0, 0));
149
-	 * $canvas->line(60, 80, 30, 100, $img->allocateColor(255, 0, 0));
150
-	 * </code>
151
-	 */
152
-	function __call($method, $params)
153
-	{
154
-		if (function_exists('image' . $method)) {
155
-			array_unshift($params, $this->handle);
156
-			call_user_func_array('image' . $method, $params);
157
-		} else {
158
-			throw new InvalidCanvasMethodException("Function doesn't exist: image{$method}.");
159
-		}
160
-	}
138
+    /**
139
+     * A magic method that allows you to call any PHP function that starts with "image".
140
+     * 
141
+     * This is a shortcut to call custom functions on the image handle.
142
+     * 
143
+     * Example:
144
+     * <code>
145
+     * $img = WideImage::load('pic.jpg');
146
+     * $canvas = $img->getCanvas();
147
+     * $canvas->filledRect(10, 10, 20, 30, $img->allocateColor(0, 0, 0));
148
+     * $canvas->line(60, 80, 30, 100, $img->allocateColor(255, 0, 0));
149
+     * </code>
150
+     */
151
+    function __call($method, $params)
152
+    {
153
+        if (function_exists('image' . $method)) {
154
+            array_unshift($params, $this->handle);
155
+            call_user_func_array('image' . $method, $params);
156
+        } else {
157
+            throw new InvalidCanvasMethodException("Function doesn't exist: image{$method}.");
158
+        }
159
+    }
161 160
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -151,9 +151,9 @@
 block discarded – undo
151 151
 	 */
152 152
 	function __call($method, $params)
153 153
 	{
154
-		if (function_exists('image' . $method)) {
154
+		if (function_exists('image'.$method)) {
155 155
 			array_unshift($params, $this->handle);
156
-			call_user_func_array('image' . $method, $params);
156
+			call_user_func_array('image'.$method, $params);
157 157
 		} else {
158 158
 			throw new InvalidCanvasMethodException("Function doesn't exist: image{$method}.");
159 159
 		}
Please login to merge, or discard this patch.
htdocs/class/libraries/vendor/smottt/wideimage/lib/WideImage/Mapper/GD2.php 1 patch
Indentation   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	/**
2
+    /**
3 3
 ##DOC-SIGNATURE##
4 4
 
5 5
     This file is part of WideImage.
@@ -17,9 +17,8 @@  discard block
 block discarded – undo
17 17
     You should have received a copy of the GNU Lesser General Public License
18 18
     along with WideImage; if not, write to the Free Software
19 19
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
-
21
-    * @package Internal/Mappers
22
-  **/
20
+     * @package Internal/Mappers
21
+     **/
23 22
 
24 23
 namespace WideImage\Mapper;
25 24
 
@@ -30,13 +29,13 @@  discard block
 block discarded – undo
30 29
  */
31 30
 class GD2
32 31
 {
33
-	public function load($uri)
34
-	{
35
-		return @imagecreatefromgd2($uri);
36
-	}
32
+    public function load($uri)
33
+    {
34
+        return @imagecreatefromgd2($uri);
35
+    }
37 36
 	
38
-	public function save($handle, $uri = null, $chunk_size = null, $type = null)
39
-	{
40
-		return imagegd2($handle, $uri, $chunk_size, $type);
41
-	}
37
+    public function save($handle, $uri = null, $chunk_size = null, $type = null)
38
+    {
39
+        return imagegd2($handle, $uri, $chunk_size, $type);
40
+    }
42 41
 }
Please login to merge, or discard this patch.
htdocs/class/libraries/vendor/smottt/wideimage/lib/WideImage/Mapper/GD.php 1 patch
Indentation   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	/**
2
+    /**
3 3
 ##DOC-SIGNATURE##
4 4
 
5 5
     This file is part of WideImage.
@@ -17,9 +17,8 @@  discard block
 block discarded – undo
17 17
     You should have received a copy of the GNU Lesser General Public License
18 18
     along with WideImage; if not, write to the Free Software
19 19
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
-
21
-    * @package Internal/Mappers
22
-  **/
20
+     * @package Internal/Mappers
21
+     **/
23 22
 
24 23
 namespace WideImage\Mapper;
25 24
 
@@ -30,17 +29,17 @@  discard block
 block discarded – undo
30 29
  */
31 30
 class GD
32 31
 {
33
-	public function load($uri)
34
-	{
35
-		return @imagecreatefromgd($uri);
36
-	}
32
+    public function load($uri)
33
+    {
34
+        return @imagecreatefromgd($uri);
35
+    }
37 36
 	
38
-	public function save($handle, $uri = null)
39
-	{
40
-		if ($uri == null) {
41
-			return imagegd($handle);
42
-		}
37
+    public function save($handle, $uri = null)
38
+    {
39
+        if ($uri == null) {
40
+            return imagegd($handle);
41
+        }
43 42
 		
44
-		return imagegd($handle, $uri);
45
-	}
43
+        return imagegd($handle, $uri);
44
+    }
46 45
 }
Please login to merge, or discard this patch.