@@ -89,8 +89,7 @@ |
||
| 89 | 89 | $red = ($pixel & 0xF800) >> 8; |
| 90 | 90 | $green = ($pixel & 0x07E0) >> 3; |
| 91 | 91 | $blue = ($pixel & 0x001F) << 3; |
| 92 | - } |
|
| 93 | - else if ($this->encoding == "555") |
|
| 92 | + } else if ($this->encoding == "555") |
|
| 94 | 93 | { |
| 95 | 94 | $red = ($pixel & 0x7C00) >> 7; |
| 96 | 95 | $green = ($pixel & 0x03E0) >> 2; |
@@ -75,10 +75,11 @@ discard block |
||
| 75 | 75 | for ($x = 0; $x < $this->GetWidth();) |
| 76 | 76 | { |
| 77 | 77 | $run = $this->reader->ReadInt(2); |
| 78 | - if (($run & 0x0001) > 0) |
|
| 79 | - $run_type = "colour"; |
|
| 80 | - else |
|
| 81 | - $run_type = "black"; |
|
| 78 | + if (($run & 0x0001) > 0) { |
|
| 79 | + $run_type = "colour"; |
|
| 80 | + } else { |
|
| 81 | + $run_type = "black"; |
|
| 82 | + } |
|
| 82 | 83 | $run_length = ($run & 0x7FFF) >> 1; |
| 83 | 84 | if ($run_type == "black") |
| 84 | 85 | { |
@@ -98,8 +99,7 @@ discard block |
||
| 98 | 99 | $red = ($pixel & 0xF800) >> 8; |
| 99 | 100 | $green = ($pixel & 0x07E0) >> 3; |
| 100 | 101 | $blue = ($pixel & 0x001F) << 3; |
| 101 | - } |
|
| 102 | - else if ($this->encoding == "555") |
|
| 102 | + } else if ($this->encoding == "555") |
|
| 103 | 103 | { |
| 104 | 104 | $red = ($pixel & 0x7C00) >> 7; |
| 105 | 105 | $green = ($pixel & 0x03E0) >> 2; |
@@ -109,8 +109,9 @@ discard block |
||
| 109 | 109 | imagesetpixel($image, $x, $y, $colour); |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | - if ($x == $this->GetWidth()) |
|
| 113 | - $this->reader->Skip(2); |
|
| 112 | + if ($x == $this->GetWidth()) { |
|
| 113 | + $this->reader->Skip(2); |
|
| 114 | + } |
|
| 114 | 115 | } |
| 115 | 116 | } |
| 116 | 117 | $this->gdImage = $image; |
@@ -34,8 +34,9 @@ |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $buffer = $reader->ReadInt(2); |
| 37 | - if ($buffer < 1) |
|
| 38 | - throw new Exception('Sprite file appears to contain less than 1 frame.'); |
|
| 37 | + if ($buffer < 1) { |
|
| 38 | + throw new Exception('Sprite file appears to contain less than 1 frame.'); |
|
| 39 | + } |
|
| 39 | 40 | $frameCount = $buffer; |
| 40 | 41 | for ($x = 0; $x < $frameCount; $x++) |
| 41 | 42 | { |
@@ -105,8 +105,9 @@ |
||
| 105 | 105 | * if it does't already. |
| 106 | 106 | */ |
| 107 | 107 | protected function EnsureDecoded() { |
| 108 | - if (!$this->decoded) |
|
| 109 | - $this->Decode(); |
|
| 108 | + if (!$this->decoded) { |
|
| 109 | + $this->Decode(); |
|
| 110 | + } |
|
| 110 | 111 | |
| 111 | 112 | $this->decoded = true; |
| 112 | 113 | } |
@@ -21,12 +21,15 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function FileReader($filename) |
| 23 | 23 | { |
| 24 | - if (!file_exists($filename)) |
|
| 25 | - throw new Exception("File does not exist: ".$filename); |
|
| 26 | - if (!is_file($filename)) |
|
| 27 | - throw new Exception("Target is not a file."); |
|
| 28 | - if (!is_readable($filename)) |
|
| 29 | - throw new Exception("File exists, but is not readable."); |
|
| 24 | + if (!file_exists($filename)) { |
|
| 25 | + throw new Exception("File does not exist: ".$filename); |
|
| 26 | + } |
|
| 27 | + if (!is_file($filename)) { |
|
| 28 | + throw new Exception("Target is not a file."); |
|
| 29 | + } |
|
| 30 | + if (!is_readable($filename)) { |
|
| 31 | + throw new Exception("File exists, but is not readable."); |
|
| 32 | + } |
|
| 30 | 33 | |
| 31 | 34 | $this->fp = fopen($filename, 'rb'); |
| 32 | 35 | } |
@@ -51,8 +54,9 @@ discard block |
||
| 51 | 54 | for ($x = 0; $x < $count; $x++) |
| 52 | 55 | { |
| 53 | 56 | $buffer = (ord(fgetc($this->fp)) << ($x*8)); |
| 54 | - if ($buffer === false) |
|
| 55 | - throw new Exception("Read failure"); |
|
| 57 | + if ($buffer === false) { |
|
| 58 | + throw new Exception("Read failure"); |
|
| 59 | + } |
|
| 56 | 60 | $int += $buffer; |
| 57 | 61 | } |
| 58 | 62 | return $int; |