public static function imageCreateFromBmp($pathToBitmapFile)
    {
        $bitmapFileData = self::getBitmapFileData($pathToBitmapFile);

        $temp = unpack('H*', $bitmapFileData);
        $hex = $temp[1];
        $header = substr($hex, 0, 108);
        list($width, $height) = self::calculateWidthAndHeight($header);

        //    Define starting X and Y
        $x = 0;
        $y = 1;

        $image = imagecreatetruecolor($width, $height);

        //    Grab the body from the image
        $body = substr($hex, 108);

        //    Calculate if padding at the end-line is needed. Divided by two to keep overview. 1 byte = 2 HEX-chars
        $bodySize = (strlen($body) / 2);
        $headerSize = ($width * $height);

        //    Use end-line padding? Only when needed
        $usePadding = ($bodySize > ($headerSize * 3) + 4);

        $bitmapBody = new BitmapBodyModel();
        $bitmapBody->bodySize = $bodySize;
        $bitmapBody->x = $x;
        $bitmapBody->width = $width;
        $bitmapBody->usePadding = $usePadding;
        $bitmapBody->y = $y;
        $bitmapBody->height = $height;
        $bitmapBody->body = $body;
        $bitmapBody->image = $image;

        self::loopThroughBodyAndCalculatePixels($bitmapBody);

        unset($body);

        return $bitmapBody->image;
    }
public static function imageCreateFromBmp($pathToBitmapFile)
    {
        $bitmapFileData = self::getBitmapFileData($pathToBitmapFile);

        $temp = unpack('H*', $bitmapFileData);
        $hex = $temp[1];
        $header = substr($hex, 0, 108);
        list($width, $height) = self::calculateWidthAndHeight($header);

        //    Define starting X and Y
        $x = 0;
        $y = 1;

        $image = imagecreatetruecolor($width, $height);

        //    Grab the body from the image
        $body = substr($hex, 108);

        //    Calculate if padding at the end-line is needed. Divided by two to keep overview. 1 byte = 2 HEX-chars
        $bodySize = (strlen($body) / 2);
        $headerSize = ($width * $height);

        //    Use end-line padding? Only when needed
        $usePadding = ($bodySize > ($headerSize * 3) + 4);

        $bitmapBody = new BitmapBodyModel();
        $bitmapBody->bodySize = $bodySize;
        $bitmapBody->x = $x;
        $bitmapBody->width = $width;
        $bitmapBody->usePadding = $usePadding;
        $bitmapBody->y = $y;
        $bitmapBody->height = $height;
        $bitmapBody->body = $body;
        $bitmapBody->image = $image;

        self::loopThroughBodyAndCalculatePixels($bitmapBody);

        unset($body);

        return $bitmapBody->image;
    }
public static function imageCreateFromBmp ( $ pathToBitmapFile ) { $ bitmapFileData = self :: getBitmapFileData ( $ pathToBitmapFile ) ; $ temp = unpack ( 'H*' , $ bitmapFileData ) ; $ hex = $ temp [ 1 ] ; $ header = substr ( $ hex , 0 , 108 ) ; list ( $ width , $ height ) = self :: calculateWidthAndHeight ( $ header ) ; //    Define starting X and Y $ x = 0 ; $ y = 1 ; $ image = imagecreatetruecolor ( $ width , $ height ) ; //    Grab the body from the image $ body = substr ( $ hex , 108 ) ; //    Calculate if padding at the end-line is needed. Divided by two to keep overview. 1 byte = 2 HEX-chars $ bodySize = ( strlen ( $ body ) / 2 ) ; $ headerSize = ( $ width * $ height ) ; //    Use end-line padding? Only when needed $ usePadding = ( $ bodySize > ( $ headerSize * 3 ) + 4 ) ; $ bitmapBody = new BitmapBodyModel ( ) ; $ bitmapBody -> bodySize = $ bodySize ; $ bitmapBody -> x = $ x ; $ bitmapBody -> width = $ width ; $ bitmapBody -> usePadding = $ usePadding ; $ bitmapBody -> y = $ y ; $ bitmapBody -> height = $ height ; $ bitmapBody -> body = $ body ; $ bitmapBody -> image = $ image ; self :: loopThroughBodyAndCalculatePixels ( $ bitmapBody ) ; unset ( $ body ) ; return $ bitmapBody -> image ; }
Create Image resource from Bitmap

@see       http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
@author    alexander at alexauto dot nl

@param    string $pathToBitmapFile

@return  resource
@throws \Exception
Create Image resource from Bitmap