標籤:des color 使用 ar for 檔案 sp c on
1. imagecreatetruecolor() 建立一個真彩色映像
resource imagecreatetruecolor ( int x_size, int y_size )
imagecreatetruecolor() 返回一個映像標識符,代表了一幅大小為 x_size 和 y_size 的黑色映像。
2. imagecolorallocate() 為一幅映像分配顏色
int imagecolorallocate ( resource image, int red, int green, int blue )
imagecolorallocate() 返回一個標識符,代表了由給定的 RGB 成分組成的顏色。red,green 和 blue 分別是所需要的顏色的紅,綠,藍成分。
3. imagefill() 地區填充
bool imagefill ( resource image, int x, int y, int color )
imagefill() 在 image 映像的座標 x,y(映像左上方為 0, 0)處用 color 顏色執列區域填充(即與 x, y 點顏色相同且相鄰的點都會被填充)。
4. imagestring() 水平地畫一行字串
bool imagestring ( resource image, int font, int x, int y, string s, int col )
imagestring() 用 col 顏色將字串 s 畫到 image 所代表的映像的 x,y 座標處(這是字串左上方座標,整幅映像的左上方為 0,0)。如果 font 是 1,2,3,4 或 5,則使用內建字型。
5. imageline() 畫一條線段
bool imageline ( resource image, int x1, int y1, int x2, int y2, int color )
imageline() 用 color 顏色在映像 image 中從座標 x1,y1 到 x2,y2(映像左上方為 0, 0)畫一條線段。
6. imagesetpixel() 畫一個單一像素
bool imagesetpixel ( resource image, int x, int y, int color )
imagesetpixel() 在 image 映像中用 color 顏色在 x,y 座標(映像左上方為 0,0)上畫一個點。
7. imagettftext() 用 TrueType 字型向映像寫入文本
array imagettftext ( resource image, float size, float angle, int x, int y, int color, string fontfile, string text )
image 映像資源
size 字型大小
angle 角度製表示的角度,0 度為從左向右讀的文本。更高數值表示逆時針旋轉
x 由 x,y 所表示的座標定義了第一個字元的基本點(大概是字元的左下角)
y Y 座標。它設定了字型基準的位置,不是字元的最底端
color 色彩索引。使用負的色彩索引值具有關閉防鋸齒的效果
fontfile 是想要使用的 TrueType 字型的路徑。
text 要寫入的文本字串
8. imagecreatefrompng() 從 PNG 檔案或 URL 建立一映像
resource imagecreatefrompng ( string filename )
imagecreatefrompng() 返回一映像標識符,代表了從給定的檔案名稱取得的映像。
9. imagecopyresampled() 重採樣拷貝部分映像並調整大小
bool imagecopyresampled ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h )
imagecopyresampled() 將一幅映像中的一塊正方形地區拷貝到另一個映像中,平滑地插入像素值,因此,尤其是,減小了映像的大小而仍然保持了極大的清晰度。如果成功則返回 TRUE,失敗則返回 FALSE。
10. PHP產生簡單的郵件表徵圖代碼
header(‘Content-Type:image/png‘);$img=imagecreatetruecolor(400,200);$blue=imagecolorallocate($img,0,102,255);$white=imagecolorallocate($img,255,255,255);imagefill($img,0,0,$blue);imagestring($img,2,130,50,‘Emailto:[email protected]‘,$white);imageline($img,0,0,400,200,$white);imageline($img,0,200,400,0,$white);for($i=0;$i<200;$i++){ imagesetpixel($img,rand(0,400),rand(0,200),$white);}$font=‘C:\WINDOWS\Fonts\SIMKAI.TTF‘;$text=iconv(‘utf-8‘,‘utf-8‘,‘收件者:管理員‘);imagettftext($img,20,0,108,40,$white,$font,$text); imagepng($img);imagedestroy($img);
常用的PHP圖形處理函數