php imagecreatetruecolor建立高清圖片函數
imagecreatetruecolor()返回一個映像標識符代表指定大小的黑色形象。
根據你的PHP和GD版本中函數定義與否。對於PHP 4.0.6通過4.1.x這個函數總是存在的
,如果廣東模組載入,但它要求GD2的情況下被安裝了PHP將發出一個致命錯誤並退出。
用PHP 4.2.x版這種行為是不同的人發出警告,而不是一個錯誤。其他版本只定義此功
能,
看看執行個體
<?php
header ('Content-type: image/png');
$im = @imagecreatetruecolor(120, 20)
or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
imagepng($im);
imagedestroy($im);
?>
我提出這方面合作 - 結合一些例子,然後動態產生的文本。但是,與此設定,我能得
到透明背景的工作也。
<?php
// Set the content-type
header('Content-type: image/png');
// Create the image
$im = imagecreatetruecolor(175, 15);
imagesavealpha($im, true);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 25, $black);
$trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $trans_colour);
// The text to draw
$text = $_GET['text'];
// Replace path by your own font path
$font = 'catriel regular.ttf';
// Add some shadow to the text
imagettftext($im, 9, 0, 13, 16, $black, $font, $text);
// Add the text
imagettftext($im, 9, 0, 12, 15, $white, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>