protected function encode(): string
    {
        $bitmap = null;
        $lastRow = null;

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

            for ($x = 0; $x < $this->width; $x++) {
                $bits .= $this->decoder->getBitAt($x, $y);
            }

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

            $row = null;

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

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

        return $bitmap;
    }
protected function encode(): string
    {
        $bitmap = null;
        $lastRow = null;

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

            for ($x = 0; $x < $this->width; $x++) {
                $bits .= $this->decoder->getBitAt($x, $y);
            }

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

            $row = null;

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

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

        return $bitmap;
    }
protected function encode ( ) : string { $ bitmap = null ; $ lastRow = null ; for ( $ y = 0 ; $ y < $ this -> height ; $ y ++ ) { $ bits = null ; for ( $ x = 0 ; $ x < $ this -> width ; $ x ++ ) { $ bits .= $ this -> decoder -> getBitAt ( $ x , $ y ) ; } $ bytes = str_split ( $ bits , 8 ) ; $ bytes [ ] = str_pad ( array_pop ( $ bytes ) , 8 , '0' ) ; $ row = null ; foreach ( $ bytes as $ byte ) { $ row .= sprintf ( '%02X' , bindec ( $ byte ) ) ; } $ bitmap .= $ this -> compress ( $ row , $ lastRow ) ; $ lastRow = $ row ; } return $ bitmap ; }
Encode the image in ASCII hexadecimal by looping over every pixel.

@return string
Encode the image in ASCII hexadecimal by looping over every pixel .