說明 resource imagecreatetruecolor ( int $x_size , int $y_size ) imagecreatetruecolor() 返回一個圖像標識符,代表了一幅大小為 x_size " /> 国产精品一区二区三区免费视频 ,国产91精品高跟丝袜在线,亚洲精品高清国产一久久

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

php imagecreatetruecolor 創建高清和透明圖片代碼小結

(php 4 >= 4.0.6, php 5)
imagecreatetruecolor ― 新建一個真彩色圖像

說明
resource imagecreatetruecolor ( int $x_size , int $y_size )
imagecreatetruecolor() 返回一個圖像標識符,代表了一幅大小為 x_size 和 y_size 的黑色圖像。

是否定義了本函數取決于 php 和 GD 的版本。從 php 4.0.6 到 4.1.x 只要加載了 GD 模塊本函數一直存在,但是在沒有安裝 GD2 的時候調用,php 將發出致命錯誤并退出。在 php 4.2.x 中此行為改為發出警告而不是錯誤。其它版本只在安裝了正確的 GD 版本時定義了本函數。

新建一個新的 GD 圖像流并輸出圖像
復制代碼 代碼如下:
<?php
header("Content-type: image/png");
$im = @imagecreatetruecolor(50, 100)
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);
?>

Note: 本函數需要 GD 2.0.1 或更高版本(推薦 2.0.28 及更高版本)。

php imagecolorallocatealpha 創建透明圖片實例
imagecolorallocatealpha(resource $image , int $red , int $green , int $blue, int $alpha )
imagecolorallocatealpha()的行為相同imagecolorallocate()同阿爾法增加透明度參數。


$image
圖像資源,通過創造的圖像功能,如,一返回imagecreatetruecolor()。

$red
紅色分量的價值。

$green
價值的綠色成分。

$blue
藍色成分的價值。

$alpha
一個介于0和127的價值。 0表示完全不透明,而127表示完全透明。
來看個imagecolorallocatealpha實例教程
復制代碼 代碼如下:
<?php
$size = 300;
$image=imagecreatetruecolor($size, $size);

// something to get a white background with black border
$back = imagecolorallocate($image, 255, 255, 255);
$border = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back);
imagerectangle($image, 0, 0, $size - 1, $size - 1, $border);

$yellow_x = 100;
$yellow_y = 75;
$red_x = 120;
$red_y = 165;
$blue_x = 187;
$blue_y = 125;
$radius = 150;

// allocate colors with alpha values
$yellow = imagecolorallocatealpha($image, 255, 255, 0, 75);
$red = imagecolorallocatealpha($image, 255, 0, 0, 75);
$blue = imagecolorallocatealpha($image, 0, 0, 255, 75);

// drawing 3 overlapped circle
imagefilledellipse($image, $yellow_x, $yellow_y, $radius, $radius, $yellow);
imagefilledellipse($image, $red_x, $red_y, $radius, $radius, $red);
imagefilledellipse($image, $blue_x, $blue_y, $radius, $radius, $blue);

// don't forget to output a correct header!
header('Content-type: image/png');

// and finally, output the result
imagepng($image);
imagedestroy($image);
?>


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);
?>

ph利用imagecreatetruecolor動態生成高清圖片代碼
復制代碼 代碼如下:
//實例用我們用imagecreatetruecolor
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);

//我把這個一起 - 結合較好的例子,然后動態生成的文本。但是,與此成立,我能得到透明背景以及工作。
//實例二imagecreatetruecolor
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);

/*
實例三創建透明圖片

如果你想創建一個PNG圖像*透明*,其中的背景是完全透明的,所有行動發生在借鑒,除此之外,然后執行下列操作:
*/
$png = imagecreatetruecolor(800, 600);
imagesavealpha($png, true);

$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
imagefill($png, 0, 0, $trans_colour);

$red = imagecolorallocate($png, 255, 0, 0);
imagefilledellips教程e($png, 400, 300, 400, 300, $red);

header("Content-type: image/png");
imagepng($png);

你要做的就是創建一個真正的彩色圖像,確保阿爾法保存狀態是,然后填寫一個顏色,也經歷了阿爾法級別設置為完全透明(127)的圖像。

從上面的代碼產生的巴新將有一個完全透明的背景(一紅色圓圈拖到Photoshop中的圖像,以了解自己)
The resulting PNG from the code above will have a red circle on a fully transparent background (drag the image into Photoshop to see for yourself)

php技術php imagecreatetruecolor 創建高清和透明圖片代碼小結,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产成人短视频 | 国产一二三在线观看 | 国产免费播放一区二区 | 中文字幕一区二区三 | 国语对白免费观看网址 | 亚洲国产一区二区在线 | 色噜噜狠狠先锋影音久久 | 色综合视频在线 | 日韩色爱| 思99re久久这里只有精品首页 | 福利视频免费看 | 日本高清视频在线www色 | 婷婷六月天激情 | 5月婷婷6月丁香 | 香港三级欧美国产精品 | 免费一区 | 欧美另类特大 | 黄色小视频在线免费看 | 看全色黄大色黄大片大学生 | 狠狠穞老司机的福67194 | 亚洲94vvv男人的天堂五月 | 91精品免费视频 | 最新精品亚洲成a人在线观看 | 久久精品国产亚洲a不卡 | 久久国产精品-久久精品 | 日本精品一区二区三区在线 | 日韩视频免费 | 在线二区| 天天色色网| 91精品91| 五色婷婷| 不卡一区二区三区四区 | 国产精品网页 | 大色虫成人午夜在线观看 | 韩国女主播一区二区视频 | 精品在线观看一区 | 亚洲香蕉久久一区二区 | 美女一级一级毛片 | 伊人网综合在线观看 | 四虎影视永久免费观看网址 | 亚洲精品中文字幕午夜 |