public function getEnclosingRectangle() : ?array
    {
        $left = $this->width;
        $top = $this->height;
        $right = -1;
        $bottom = -1;

        for ($y = 0; $y < $this->height; ++$y) {
            for ($x32 = 0; $x32 < $this->rowSize; ++$x32) {
                $bits = $this->bits[$y * $this->rowSize + $x32];

                if (0 !== $bits) {
                    if ($y < $top) {
                        $top = $y;
                    }

                    if ($y > $bottom) {
                        $bottom = $y;
                    }

                    if ($x32 * 32 < $left) {
                        $bit = 0;

                        while (($bits << (31 - $bit)) === 0) {
                            $bit++;
                        }

                        if (($x32 * 32 + $bit) < $left) {
                            $left = $x32 * 32 + $bit;
                        }
                    }
                }

                if ($x32 * 32 + 31 > $right) {
                    $bit = 31;

                    while (0 === BitUtils::unsignedRightShift($bits, $bit)) {
                        --$bit;
                    }

                    if (($x32 * 32 + $bit) > $right) {
                        $right = $x32 * 32 + $bit;
                    }
                }
            }
        }

        $width = $right - $left;
        $height = $bottom - $top;

        if ($width < 0 || $height < 0) {
            return null;
        }

        return [$left, $top, $width, $height];
    }
public function getEnclosingRectangle() : ?array
    {
        $left = $this->width;
        $top = $this->height;
        $right = -1;
        $bottom = -1;

        for ($y = 0; $y < $this->height; ++$y) {
            for ($x32 = 0; $x32 < $this->rowSize; ++$x32) {
                $bits = $this->bits[$y * $this->rowSize + $x32];

                if (0 !== $bits) {
                    if ($y < $top) {
                        $top = $y;
                    }

                    if ($y > $bottom) {
                        $bottom = $y;
                    }

                    if ($x32 * 32 < $left) {
                        $bit = 0;

                        while (($bits << (31 - $bit)) === 0) {
                            $bit++;
                        }

                        if (($x32 * 32 + $bit) < $left) {
                            $left = $x32 * 32 + $bit;
                        }
                    }
                }

                if ($x32 * 32 + 31 > $right) {
                    $bit = 31;

                    while (0 === BitUtils::unsignedRightShift($bits, $bit)) {
                        --$bit;
                    }

                    if (($x32 * 32 + $bit) > $right) {
                        $right = $x32 * 32 + $bit;
                    }
                }
            }
        }

        $width = $right - $left;
        $height = $bottom - $top;

        if ($width < 0 || $height < 0) {
            return null;
        }

        return [$left, $top, $width, $height];
    }
public function getEnclosingRectangle ( ) : ? array { $ left = $ this -> width ; $ top = $ this -> height ; $ right = - 1 ; $ bottom = - 1 ; for ( $ y = 0 ; $ y < $ this -> height ; ++ $ y ) { for ( $ x32 = 0 ; $ x32 < $ this -> rowSize ; ++ $ x32 ) { $ bits = $ this -> bits [ $ y * $ this -> rowSize + $ x32 ] ; if ( 0 !== $ bits ) { if ( $ y < $ top ) { $ top = $ y ; } if ( $ y > $ bottom ) { $ bottom = $ y ; } if ( $ x32 * 32 < $ left ) { $ bit = 0 ; while ( ( $ bits << ( 31 - $ bit ) ) === 0 ) { $ bit ++ ; } if ( ( $ x32 * 32 + $ bit ) < $ left ) { $ left = $ x32 * 32 + $ bit ; } } } if ( $ x32 * 32 + 31 > $ right ) { $ bit = 31 ; while ( 0 === BitUtils :: unsignedRightShift ( $ bits , $ bit ) ) { -- $ bit ; } if ( ( $ x32 * 32 + $ bit ) > $ right ) { $ right = $ x32 * 32 + $ bit ; } } } } $ width = $ right - $ left ; $ height = $ bottom - $ top ; if ( $ width < 0 || $ height < 0 ) { return null ; } return [ $ left , $ top , $ width , $ height ] ; }
This is useful in detecting the enclosing rectangle of a 'pure' barcode.

@return int[]|null
This is useful in detecting the enclosing rectangle of a pure barcode .