|
@@ 624-627 (lines=4) @@
|
| 621 |
|
* @return bool|resource an image resource identifier on success, <b>FALSE</b> on errors. |
| 622 |
|
*/ |
| 623 |
|
private function imagecreatefrombmp($fileName) { |
| 624 |
|
if (!($fh = fopen($fileName, 'rb'))) { |
| 625 |
|
$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName, array('app' => 'core')); |
| 626 |
|
return false; |
| 627 |
|
} |
| 628 |
|
// read file header |
| 629 |
|
$meta = unpack('vtype/Vfilesize/Vreserved/Voffset', fread($fh, 14)); |
| 630 |
|
// check for bitmap |
|
@@ 631-635 (lines=5) @@
|
| 628 |
|
// read file header |
| 629 |
|
$meta = unpack('vtype/Vfilesize/Vreserved/Voffset', fread($fh, 14)); |
| 630 |
|
// check for bitmap |
| 631 |
|
if ($meta['type'] != 19778) { |
| 632 |
|
fclose($fh); |
| 633 |
|
$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName . ' is not a bitmap!', array('app' => 'core')); |
| 634 |
|
return false; |
| 635 |
|
} |
| 636 |
|
// read image header |
| 637 |
|
$meta += unpack('Vheadersize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vcolors/Vimportant', fread($fh, 40)); |
| 638 |
|
// read additional 16bit header |
|
@@ 655-659 (lines=5) @@
|
| 652 |
|
// in rare cases filesize is equal to offset so we need to read physical size |
| 653 |
|
if ($meta['imagesize'] < 1) { |
| 654 |
|
$meta['imagesize'] = @filesize($fileName) - $meta['offset']; |
| 655 |
|
if ($meta['imagesize'] < 1) { |
| 656 |
|
fclose($fh); |
| 657 |
|
$this->logger->warning('imagecreatefrombmp: Can not obtain file size of ' . $fileName . ' is not a bitmap!', array('app' => 'core')); |
| 658 |
|
return false; |
| 659 |
|
} |
| 660 |
|
} |
| 661 |
|
} |
| 662 |
|
// calculate colors |