imagebmp 


gd apg

CREATE a particular BMP image to be shown in a browser or stored in a file.





This function creates a BMP file in $file from the $image which is created by imagecreate or imagecreatetruecolor, for example.


PALETTE IMAGE

is the designation term for images with a small number of colors.

For this type of image, a maximum of 256 colors are accepted.


TRUECOLOR IMAGE

is the designation term for images with a great number of colors.

For this type of image, a maximum of 16,777,216 colors are accepted.





This function returns TRUE on success or FALSE on failure.

However, if libgd fails to output the image, this function returns TRUE.





BMP file format

also known as bitmap image file, device independent bitmap (DIB) file format and bitmap, is a raster graphics image file format used to store bitmap digital images, independently of the display device (such as a graphics adapter), especially on Microsoft Windows and OS/2 operating systems.

The BMP file format is capable of storing two-dimensional digital images both monochrome and color, in various color depths, and optionally with data compression, alpha channels, and color profiles.

The Windows Metafile (WMF) specification covers the BMP file format.
. . . . . . . . .
The bitmap image file consists of fixed-size structures (headers) as well as variable-sized structures appearing in a predetermined sequence.

Many different versions of some of these structures can appear in the file, due to the long evolution of this file format.
. . . . . . . . .

From Wikipedia, the free encyclopedia.



<?php

bool imagebmp
GdImage $image
          
resource|string|null $file null
                                 
bool $compressed true )


where,

$image The image identifier 

$file 
The path or stream resource 
          
SEE the below TABLE 
          
$compressed To control if RLE will be used

?>
 

  $image   


The image identifier.



  $file   


The path or stream resource.

If $file was not set or NULL, the raw image stream will be outputted directly.

$file can reference a local file or, (configuration permitting), a remote file using one of the supported stream wrappers:

STREAM WRAPPERS MEANING
file:// LOCAL File System
http:// URL HTTP
ftp:// URL FTP
php:// I/O streams
zlib:// Data Compression stream
data:// DATA (RFC-2397)
glob:// Find Filenames
phar:// PHP Archive
ssh2:// Secure Shell 2
rar:// RAR
ogg:// Audio
expect:// Interaction of stream processes
ed48


If not set or null, the raw image stream will be output directly.

$file = $null is invalid if the $compressed is not used.



  $compressed   


To control if the BMP should compressed with run-length encoding (RLE), or not.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$var getcwd();

define('PBWP''file://' $var '/bmp/');

echo 
PBWP '<br><br>';
// STREAM WRAPPER MODE

$im01 imagecreatetruecolor (200100);
$yellow imagecolorallocate($im012552550);
$green imagecolorallocate($im0101270);

$img01 PBWP 'BMP 001 01.bmp';

$font01 6;

$cormpressed01 FALSE;

$bool01 imagebmp($im01$img01$cormpressed01);

if (
$bool01 == TRUE)
{
$mess01 'The image was created!';
echo 
'$bool01 = ';
var_dump($bool01);
echo 
'<br><br>' $mess01 '<br><br>';

$img01a 'bmp/BMP 001 01.bmp';
// NORMAL MODE

echo '<img src="' $img01a 
  
'" alt="' $img01a '" title="' $img01a '">'
  
imagedestroy($im01);
}
else
{
$mess01 'The image COULD NOT BE CREATED!';
echo 
$mess01;
}

?> 

 RESULT   

BMP 001 01.bmp

$bool01 = bool(true)


The image has been created!

BMP 001 01.bmp apr

  2 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$im02 imagecreate (200100);
$blue imagecolorallocate($im0200255);
$white imagecolorallocate($im02255255255);

$img02 'bmp/BMP 002 02.bmp';

$cormpressed02 TRUE;

$bool02 imagebmp($im02$img02$cormpressed02);

if (
$bool02 == TRUE)
{
$mess02 'The image was created!<br>';
echo 
'$bool02 = ';
var_dump($bool02);
echo 
'<br><br>' $mess02 '<br><br>';

echo 
'<img src="' $img02 
    
'" alt="' $img02'" title="' $img02 '">';  
imagedestroy($im02);
}
else
{
$mess02 'The image COULD NOT BE CREATED!';
echo 
$mess02;
}

?> 

 RESULT   

BMP 002 02.bmp

$bool02 = bool(true)


The image was created!

BMP 002 02.bmp apr