note 101675 added to function.imagexbm
| From: | DonJones at osu1 dot php dot net | Date: | Tue, 04 Jan 2011 03:47:29 +0000 |
| Subject: | note 101675 added to function.imagexbm | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175436@lists.php.net to get a copy of this message | ||
There are 2 errors on this page in the examples. No one points out that the width MUST be evenly
divisible by 8 or you get a mess. The example is 120 wide which just accidentally is evenly
divisible by 8, which will happen only 1 in 8 times, randomly. This issue is dealt with in the code
below. Also, since xbm is not color but black and white, the example should not be showing color
anything, but it does. The code below is for black and white, and it works great.
I love your site!!!
<?php
header("Content-type: image/xbm");
$mytext = $_GET['mytext'];
$fontsize = 5;
$wide = imagefontwidth($fontsize) * strlen($mytext) + 20;
$temp1=$wide/8;
$temp2=round($wide/8);
if ($temp1<>$temp2){$wide=($temp2 * 8) + 8;}
$high = imagefontheight($fontsize) + 20;
$picture = imagecreatetruecolor($wide,$high);
$white = imagecolorallocate($picture,255,255,255);
imagefill($picture,0,0,$white);
$black=imagecolorallocate($picture, 0, 0, 0);
imageline($picture, 0, 0, 0, $high, $black);
imageline($picture, 0, 0, $wide, 0, $black);
imageline($picture, $wide-1, 0, $wide-1, $high-1, $black);
imageline($picture, 0, $high-1, $wide-1, $high-1, $black);
imagestring($picture,$fontsize,10,10,$mytext,$black);
imagexbm($picture);
imagexbm($picture,"mytextpic.xbm");
imagedestroy($picture);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 76.115.172.245
----
Manual Page -- http://www.php.net/manual/en/function.imagexbm.php
Edit -- https://master.php.net/note/edit/101675
Del: integrated -- https://master.php.net/note/delete/101675/integrated
Del: useless -- https://master.php.net/note/delete/101675/useless
Del: bad code -- https://master.php.net/note/delete/101675/bad+code
Del: spam -- https://master.php.net/note/delete/101675/spam
Del: non-english -- https://master.php.net/note/delete/101675/non-english
Del: in docs -- https://master.php.net/note/delete/101675/in+docs
Del: other reasons-- https://master.php.net/note/delete/101675
Reject -- https://master.php.net/note/reject/101675
Search -- https://master.php.net/manage/user-notes.php