> per column: posts [top row, pixels] */ public array $posts = []; public function __construct( public int $width = 0, public int $height = 0, public int $leftOffset = 0, public int $topOffset = 0, ) { } public static function decode(string $data): self { if (strlen($data) < 8) { return new self(); } $h = unpack('vwidth/vheight/sleft/stop', $data); $p = new self($h['width'], $h['height'], $h['left'], $h['top']); $len = strlen($data); for ($x = 0; $x < $p->width; $x++) { $pos = unpack('V', $data, 8 + $x * 4)[1]; $col = []; $top = -1; while ($pos < $len) { $delta = ord($data[$pos]); if ($delta === 0xFF) { break; } // tall patches (DeePsea): a delta not above the previous one is relative to it $top = $delta <= $top ? $top + $delta : $delta; $n = ord($data[$pos + 1]); $col[] = [$top, substr($data, $pos + 3, $n)]; $pos += $n + 4; } $p->posts[] = $col; } return $p; } }