Skip to content

Commit

Permalink
Another minor refactor for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
robgridley committed Feb 18, 2016
1 parent 9840f91 commit b562ef3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Zpl/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,23 @@ protected function encode()
{
$bitmap = null;

for ($row = 0; $row < $this->height; $row++) {
for ($y = 0; $y < $this->height; $y++) {
$bits = null;

for ($column = 0; $column < $this->width; $column++) {
$bits .= (imagecolorat($this->image, $column, $row) & 0xFF) < 127 ? '1' : '0';
for ($x = 0; $x < $this->width; $x++) {
$bits .= (imagecolorat($this->image, $x, $y) & 0xFF) < 127 ? '1' : '0';
}

$bytes = str_split($bits, 8);
$bytes[] = str_pad(array_pop($bytes), 8, '0');

$ascii = null;
$row = null;

foreach ($bytes as $byte) {
$ascii .= sprintf('%02X', bindec($byte));
$row .= sprintf('%02X', bindec($byte));
}

$bitmap .= $this->compress($ascii);
$bitmap .= $this->compress($row);
}

return $bitmap;
Expand Down

0 comments on commit b562ef3

Please sign in to comment.