[ 永遠的UNIX::UNIX技術資料的寶庫 ]   GB | BIG5

首頁 > 編程技術 > Php > 正文
PHP4手冊:函數庫及函數(十九) 圖形處理函式庫
http://netleader.126.com 星空浪子 (2001-04-18 14:13:23)
-------------------------------------------------------------------------------- 
 圖形處理函式庫  
-------------------------------------------------------------------------------- 
  


本函式庫共有 44 個函式 
使用本功能需要在編譯 PHP 前先安裝 GD library,可到 http://www.boutell.com/gd 下載。在 1.6.2 版以前的 GD library 有支援 GIF 格式的功能,但因為 GIF 格式使用的 LZW 演算法牽涉到 Unisys 的專利權,因此在 GD library 1.6.2 版之不支援 GIF 的格式。在安裝 1.6.2 版時系統必須要有 libpng 及 zlib 二個動態連結函式庫。前者可在 http://www.cdrom.com/pub/png 下載;者可在 http://www.cdrom.com/pub/infozip/zlib 下載。而 GD library 也支援 TrueType 字型,請先到 http://www.freetype.org 下載動態連結程式庫。  
PHP 在 3.0.13 版之,終支援了 PNG 的圖型格式,使用 PNG 就不怕會有版權的問題了,而且在 PHP 這個版本以,安裝編譯時會檢查 GD library 支援的是舊的 GIF 格式還是新的 PNG 格式來決定是否使用 GIF 或 PNG 的專用函式。 

若真的需要使用 GD Library 中有關 GIF 的部份,不妨找較舊的 FreeBSD 或者 Linux 版本,裡面可能會有這些函式,但可能會因為侵犯到 Unisys 的專利權,而引發法律問題。同時請注意舊版的 TTF 字型相關函式可能不能用。 

以下是簡單的例子 
  

Header("Content-type: image/gif"); 
$im = imagecreate(400,30); 
$black = ImageColorAllocate($im, 0,0,0); 
$white = ImageColorAllocate($im, 255,255,255); 
imageline($im, 1, 1, 350, 25, $black); 
imagearc($im, 200, 15, 20, 20, 35, 190, $white); 
imagestring($im, 5, 4, 10, "Graph TEST!!", $white); 
ImageGif($im); 
ImageDestroy($im); 
?> 

  


GetImageSize: 取得圖片的長寬。  
ImageArc: 畫弧線。  
ImageChar: 寫出橫向字元。  
ImageCharUp: 寫出直式字元。  
ImageColorAllocate: 匹配顏色。  
ImageColorTransparent: 指定透明背景色。  
ImageCopyResized: 復制新圖並調整大小。  
ImageCreate: 建立新圖。  
ImageDashedLine: 繪虛線。  
ImageDestroy: 結束圖形。  
ImageFill: 圖形著色。  
ImageFilledPolygon: 多邊形區域著色。  
ImageFilledRectangle: 矩形區域著色。  
ImageFillToBorder: 指定顏色區域內著色。  
ImageFontHeight: 取得字型的高度。  
ImageFontWidth: 取得字型的寬度。  
ImageInterlace: 使用交錯式顯示與否。  
ImageLine: 繪實線。  
ImageLoadFont: 載入點陣字型。  
ImagePolygon: 繪多邊形。  
ImageRectangle: 繪矩形。  
ImageSetPixel: 繪點。  
ImageString: 繪橫式字串。  
ImageStringUp: 繪直式字串。  
ImageSX: 取得圖片的寬度。  
ImageSY: 取得圖片的高度。  
ImageTTFBBox: 計算 TTF 文字所佔區域。  
ImageTTFText: 寫 TTF 文字到圖中。  
ImageColorAt: 取得圖中指定點顏色的索引值。  
ImageColorClosest: 計算色表中與指定顏色最接近者。  
ImageColorExact: 計算色表上指定顏色索引值。  
ImageColorResolve: 計算色表上指定或最接近顏色的索引值。  
ImageColorSet: 設定色表上指定索引的顏色。  
ImageColorsForIndex: 取得色表上指定索引的顏色。  
ImageColorsTotal: 計算圖的顏色數。  
ImagePSLoadFont: 載入 PostScript 字型。  
ImagePSFreeFont: 卸下 PostScript 字型。  
ImagePSEncodeFont: PostScript 字型轉成向量字。  
ImagePSText: 寫 PostScript 文字到圖中。  
ImagePSBBox: 計算 PostScript 文字所佔區域。  
ImageCreateFromPNG: 取出 PNG 圖型。  
ImagePNG: 建立 PNG 圖型。  
ImageCreateFromGIF: 取出 GIF 圖型。  
ImageGIF: 建立 GIF 圖型。  


-------------------------------------------------------------------------------- 
 函式:GetImageSize()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


GetImageSize 
取得圖片的長寬。 

語法: array getimagesize(string filename, array [imageinfo]); 

傳回值: 陣列 

函式種類: 圖形處理 


  
  
內容說明  


本函式可用來取得 GIF、JPEG 及 PNG 三種 WWW 上圖片的高與寬,不需要安裝 GD library 就可以使用本函式。傳回的陣列有四個元素。傳回陣列的第一個元素 (索引值 0) 是圖片的高度,單位是像素 (pixel)。第二個元素 (索引值 1) 是圖片的寬度。第三個元素 (索引值 2) 是圖片的檔案格式,其值 1 為 GIF 格式、 2 為 JPEG/JPG 格式、3 為 PNG 格式。第四個元素 (索引值 3) 為圖片的高與寬字串,height=xxx width=yyy。可省略的參數 imageinfo 用來取得一些圖片的相關訊息,例如 IPTC (http://www.xe.net/iptc) 的 APP13 標記,就可以加在圖片中,可利用 iptcparse() 來解析。 


  
  
使用范例  


function MyImg($imgfile) { 
  $size = GetImageSize($imgfile); 
  echo ""; 
} 
MyImg("img/img1.gif"); 
MyImg("img/img2.png"); 
?>  


-------------------------------------------------------------------------------- 
 函式:ImageArc()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageArc 
畫弧線。 

語法: int imagearc(int im, int cx, int cy, int w, int h, int s, int e, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來畫弧線。原點坐標 (0,0) 為圖片的左上角,參數 cx、cy 為橢圓心坐標,參數 w 為水平軸長,參數 h 為垂直軸長,參數 s 及 e 分別為起始角與結束角,參數 col 為弧線的顏色。參數 im 表示圖形的 handle。 
  

-------------------------------------------------------------------------------- 
 函式:ImageChar()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageChar 
寫出橫向字元。 

語法: int imagechar(int im, int font, int x, int y, string c, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來書寫橫向的字元。原點坐標 (0,0) 為圖片的左上角,參數 font 表示字體的大小,從最小的 1 起,參數 x、y 是寫入字元的坐標值,參數 c 為欲寫出的字元,參數 col 為字的顏色。參數 im 表示圖形的 handle。 


  
  
參考  


ImageLoadFont()   
  

-------------------------------------------------------------------------------- 
 函式:ImageCharUp()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageCharUp 
寫出直式字元。 

語法: int imagecharup(int im, int font, int x, int y, string c, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來書寫直式的字元。原點坐標 (0,0) 為圖片的左上角,參數 font 表示字體的大小,從最小的 1 起,參數 x、y 是寫入字元的坐標值,參數 c 為欲寫出的字元,參數 col 為字的顏色。參數 im 表示圖形的 handle。 


  
  
參考  


ImageLoadFont()   
  

-------------------------------------------------------------------------------- 
 函式:ImageColorAllocate()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageColorAllocate 
匹配顏色。 

語法: int imagecolorallocate(int im, int red, int green, int blue); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來匹配圖形的顏色,供其它繪圖函式使用。參數 im 表示圖形的 handle。參數 red、green、blue 是色彩三原色,其值從 0 至 255。 


  
  
使用范例  


$white = ImageColorAllocate($im, 255,255,255); 
$black = ImageColorAllocate($im, 0,0,0); 
?>  
  

-------------------------------------------------------------------------------- 
 函式:ImageColorTransparent()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageColorTransparent 
指定透明背景色。 

語法: int imagecolortransparent(int im, int [col]); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來指定某色為透明背景。參數 im 為使用 imagecreate() 打開圖形的 handle。參數 col 為 ImageColorAllocate() 所匹配的顏色。傳回值為新的透明背景色 
  

-------------------------------------------------------------------------------- 
 函式:ImageCopyResized()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageCopyResized 
復制新圖並調整大小。 

語法: int imagecopyresized(int dst_im, int src_im, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式可復制新圖,並重新調整圖片的大小尺寸。參數都是目的在前,來源在。參數 dst_im 及 src_im 為圖片的 handle。參數 dstX、dstY、srcX、srcY 分別為目的及來源的坐標。參數 dstW、dstH、srcW、srcH 分別為來源及目的的寬及高,若欲調整新圖的尺寸就在這兒設定。 

  

-------------------------------------------------------------------------------- 
 函式:ImageCreate()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageCreate 
建立新圖。 

語法: int imagecreate(int x_size, int y_size); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來建立一張全空的圖形。參數 x_size、y_size 為圖形的尺寸,單位為像素 (pixel)。 

  

-------------------------------------------------------------------------------- 
 函式:ImageDashedLine()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageDashedLine 
繪虛線。 

語法: int imagedashedline(int im, int x1, int y1, int x2, int y2, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式將在圖形上畫出一條虛線。從 x1、y1 連接到 x2、y2,原點 (0,0) 為圖形的左上角。參數 col 為虛線的顏色。 


  
  
參考  


ImageLine()   

  

-------------------------------------------------------------------------------- 
 函式:ImageDestroy()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageDestroy 
結束圖形。 

語法: int imagedestroy(int im); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式將圖片 handle 解構,釋記憶體空間。參數 im 為 ImageCreate() 所建立的圖片 handle。 

  

-------------------------------------------------------------------------------- 
 函式:ImageFill()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageFill 
圖形著色。 

語法: int imagefill(int im, int x, int y, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式將圖片坐標 (x,y) 所在的區域著色。參數 col 表示欲塗上的顏色。 

  

-------------------------------------------------------------------------------- 
 函式:ImageFilledPolygon()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageFilledPolygon 
多邊形區域著色。 

語法: int imagefilledpolygon(int im, array points, int num_points, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式將圖片的封閉多邊形區域著色。參數 points 為陣列,代表多邊形區域,陣列的偶數元素為 X 坐標,奇數元素為 Y 坐標,例如 points[0] = x0、points[1] = y0、points[2] = x1、points[3] = y1。參數 num_points 為多邊形的轉折點數目。參數 col 表示欲塗上的顏色。 
  

-------------------------------------------------------------------------------- 
 函式:ImageFilledRectangle()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageFilledRectangle 
矩形區域著色。 

語法: int imagefilledrectangle(int im, int x1, int y1, int x2, int y2, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式將圖片的封閉長方形區域著色。參數 x1、y1 及 x2、y2 分別為矩形對角線的坐標。參數 col 表示欲塗上的顏色。 
  

-------------------------------------------------------------------------------- 
 函式:ImageFillToBorder()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageFillToBorder 
指定顏色區域內著色。 

語法: int imagefilltoborder(int im, int x, int y, int border, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式將圖片中指定的顏色做為邊界,著色在其中的封閉區域之中。參數 x、y 為著色區內的坐標,原點 (0,0) 為圖形的左上角。參數 border 為顏色值,表填入顏色的邊界范圍。參數 col 表示欲塗上的顏色。 

  

-------------------------------------------------------------------------------- 
 函式:ImageFontHeight()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageFontHeight 
取得字型的高度。 

語法: int imagefontheight(int font); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來取得指定字型的高度,單位為像素 (pixel)。 


  
  
參考  


ImageFontWidth()  ImageLoadFont()   

  

-------------------------------------------------------------------------------- 
 函式:ImageFontWidth()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageFontWidth 
取得字型的寬度。 

語法: int imagefontwidth(int font); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來取得指定字型的寬度,單位為像素 (pixel)。 


  
  
參考  


ImageFontHeight()  ImageLoadFont()   

  

-------------------------------------------------------------------------------- 
 函式:ImageInterlace()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageInterlace 
使用交錯式顯示與否。 

語法: int imageinterlace(int im, int [interlace]); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來決定圖片是否使用交錯式顯示 (interlace)。欲使用交錯式顯示,則將參數 interlace 值設為 1。不想使用交錯式顯示圖形則將之設為 0。傳回值 1 表示已設定成交錯式、0 表示已設成非交錯式。 

  

-------------------------------------------------------------------------------- 
 函式:ImageLine()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageLine 
繪實線。 

語法: int imageline(int im, int x1, int y1, int x2, int y2, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式將在圖形上畫出一條實線。從 x1、y1 連接到 x2、y2,原點 (0,0) 為圖形的左上角。參數 col 為實線的顏色。 


  
  
參考  


ImageDashedLine()   
  

-------------------------------------------------------------------------------- 
 函式:ImageLoadFont()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageLoadFont 
載入點陣字型。 

語法: int imageloadfont(string file); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來載入使用者自訂的點陣字型。傳回值為字型的代號,此值為大 5 的整數。字型檔的格式如表 

byte偏移 型態 說明  
0-3 int 檔案中字元的數目  
4-7 int 字型的啟始 ASCII 字元,例如從 ASCII 32 的空白開始  
8-11 int 字元的寬度  
12-15 int 字元的高度  
16以 char 字元的位元值,也就是點陣的內容  



  
  
參考  


ImageFontHeight()  ImageFontWidth()   


-------------------------------------------------------------------------------- 
 函式:ImagePolygon()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImagePolygon 
繪多邊形。 

語法: int imagepolygon(int im, array points, int num_points, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式可在圖片上繪出多邊形。參數 points 為陣列,代表多邊形區域,陣列的偶數元素為 X 坐標,奇數元素為 Y 坐標,例如 points[0] = x0、points[1] = y0、points[2] = x1、points[3] = y1。參數 num_points 為多邊形的轉折點數目。參數 col 表示多邊形線的顏色。 

  

-------------------------------------------------------------------------------- 
 函式:ImageRectangle()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageRectangle 
繪矩形。 

語法: int imagerectangle(int im, int x1, int y1, int x2, int y2, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式可在圖片上繪出長方形。參數 x1、y1 及 x2、y2 分別為矩形對角線的坐標。參數 col 表示矩形邊框的顏色。 

  

-------------------------------------------------------------------------------- 
 函式:ImageSetPixel()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageSetPixel 
繪點。 

語法: int imagesetpixel(int im, int x, int y, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式可在圖片上繪出一點。參數 x、y 為欲繪點的坐標,參數 col 表示該點的顏色。 

  

-------------------------------------------------------------------------------- 
 函式:ImageString()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageString 
繪橫式字串。 

語法: int imagestring(int im, int font, int x, int y, string s, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式在圖片上繪出水平的橫式字串。參數 font 為字形,設為 1 到 5 表示使用內定字形。參數 x、y 為字串起點坐標。字串的內容放在參數 s 上。參數 col 表示字串的顏色。 


  
  
參考  


ImageLoadFont()   

  

-------------------------------------------------------------------------------- 
 函式:ImageStringUp()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageStringUp 
繪直式字串。 

語法: int imagestringup(int im, int font, int x, int y, string s, int col); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式在圖片上繪出鉛直的直式字串。參數 font 為字形,設為 1 到 5 表示使用內定字形。參數 x、y 為字串起點坐標。字串的內容放在參數 s 上。參數 col 表示字串的顏色。 


  
  
參考  


ImageLoadFont()   

  

-------------------------------------------------------------------------------- 
 函式:ImageSX()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageSX 
取得圖片的寬度。 

語法: int imagesx(int im); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來取得圖片的寬度數值。 

  

-------------------------------------------------------------------------------- 
 函式:ImageSY()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageSY 
取得圖片的高度。 

語法: int imagesy(int im); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來取得圖片的高度數值。 
  

-------------------------------------------------------------------------------- 
 函式:ImageTTFBBox()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageTTFBBox 
計算 TTF 文字所佔區域。 

語法: array ImageTTFBBox(int size, int angle, string fontfile, string text); 

傳回值: 陣列 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來計算並傳回 TTF 文字區域框 (bounding box) 大小。參數 size 為字形的尺寸;angle 為字型的角度;fontfile 為字型檔名稱,亦可是遠端的檔案;text 當然就是字串內容了。傳回值為陣列,包括了八個元素,頭二個分別為左下的 x、y 坐標,第三、四個為右下角的 x、y 坐標,第五、六及七、八二組分別為右上及左上的 x、y 坐標。值得注意的是欲使用本函式,系統要裝妥 GD 及 Freetype 二個函式館。 
  

-------------------------------------------------------------------------------- 
 函式:ImageTTFText()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageTTFText 
寫 TTF 文字到圖中。 

語法: array ImageTTFText(int im, int size, int angle, int x, int y, int col, string fontfile, string text); 

傳回值: 陣列 

函式種類: 圖形處理 


  
  
內容說明  


本函式將 TTF (TrueType Fonts) 字型文字寫入圖片。參數 size 為字形的尺寸;angle 為字型的角度,順時針計算,0 度為水平,也就是三點鐘的方向 (由左到右),90 度則為由下到上的文字;x,y 二參數為文字的坐標值 (原點為左上角);參數 col 為字的顏色;fontfile 為字型檔名稱,亦可是遠端的檔案;text 當然就是字串內容了。傳回值為陣列,包括了八個元素,頭二個分別為左下的 x、y 坐標,第三、四個為右下角的 x、y 坐標,第五、六及七、八二組分別為右上及左上的 x、y 坐標。值得注意的是欲使用本函式,系統要裝妥 GD 及 Freetype 二個函式館。 


  
  
使用范例  


本例建立一個 400x30 pixel 大小的黑底圖,並用 Arial 向量字體寫出 I am NUMBER ONE !! 的白字。 

Header("Content-type: image/gif"); 
$im = imagecreate(400,30); 
$black = ImageColorAllocate($im, 0,0,0); 
$white = ImageColorAllocate($im, 255,255,255); 
ImageTTFText($im, 20, 0, 10, 20, $white, "/somewhere/arial.ttf", "I am NUMBER ONE !!"); 
ImageGif($im); 
ImageDestroy($im); 
?>  

  
  
參考  


ImageTTFBBox()   


-------------------------------------------------------------------------------- 
 函式:ImageColorAt()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageColorAt 
取得圖中指定點顏色的索引值。 

語法: int imagecolorat(int im, int x, int y); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式可取得圖形中某指定點的顏色索引值 (index)。 


  
  
參考  


ImageColorSet()  ImageColorsForIndex()   



-------------------------------------------------------------------------------- 
  

-------------------------------------------------------------------------------- 
 函式:ImageColorClosest()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageColorClosest 
計算色表中與指定顏色最接近者。 

語法: int imagecolorclosest(int im, int red, int green, int blue); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來計算調色盤中與指定 RGB 顏色最接近的顏色。參數 red、green、blue 分別為紅、綠、藍三原色,也就是所謂的 RGB 值。 


  
  
參考  


ImageColorExact()   


-------------------------------------------------------------------------------- 
 函式:ImageColorExact()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageColorExact 
計算色表上指定顏色索引值。 

語法: int imagecolorexact(int im, int red, int green, int blue); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來計算調色盤中指定 RGB 顏色的色素索引值。參數 red、green、blue 分別為紅、綠、藍三原色,也就是所謂的 RGB 值。若調色盤中沒有指定的顏色,則傳回 -1。 


  
  
參考  


ImageColorClosest()   
  

-------------------------------------------------------------------------------- 
 函式:ImageColorResolve()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageColorResolve 
計算色表上指定或最接近顏色的索引值。 

語法: int imagecolorresolve(int im, int red, int green, int blue); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來計算調色盤中指定 RGB 顏色的色素索引值。參數 red、green、blue 分別為紅、綠、藍三原色,也就是所謂的 RGB 值。若無指定顏色則取得最接近的顏色。無論如何本函式都會有索引值傳回。 


  
  
參考  


ImageColorClosest()  ImageColorExact()   
  

-------------------------------------------------------------------------------- 
 函式:ImageColorSet()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageColorSet 
設定色表上指定索引的顏色。 

語法: boolean imagecolorset(int im, int index, int red, int green, int blue); 

傳回值: 布林值 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來設定調色盤上指定索引的顏色值。參數 index 為索引值。參數 red、green、blue 分別為紅、綠、藍三原色,也就是所謂的 RGB 值。此函式適合將圖片上某顏色改掉,即利用索引的顏色更改圖片顏色。 


  
  
參考  


ImageColorAt()   
  

-------------------------------------------------------------------------------- 
 函式:ImageColorsForIndex()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageColorsForIndex 
取得色表上指定索引的顏色。 

語法: array imagecolorsforindex(int im, int index); 

傳回值: 陣列 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來取得調色盤上指定索引的顏色值。參數 index 為索引值。陣列傳回值分別為紅、綠、藍三原色的值。 


  
  
參考  


ImageColorAt()  ImageColorSet()   

  

-------------------------------------------------------------------------------- 
 函式:ImageColorsTotal()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImageColorsTotal 
計算圖的顏色數。 

語法: int imagecolorstotal(int im); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來計算圖片的調色盤有幾種不同的顏色。 


  
  
參考  


ImageColorAt()  ImageColorsForIndex()   

  

-------------------------------------------------------------------------------- 
 函式:ImagePSLoadFont()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImagePSLoadFont 
載入 PostScript 字型。 

語法: int imagepsloadfont(string filename); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來載入 PostScript Type1 字型。參數 filename 為 PostScript Type1 字型的名稱。 


  
  
參考  


ImagePSFreeFont()   
  

-------------------------------------------------------------------------------- 
 函式:ImagePSFreeFont()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImagePSFreeFont 
卸下 PostScript 字型。 

語法: void imagepsfreefont(int fontindex); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式將已載入 PostScript Type1 字型卸下。參數 fontindex 為載入 PostScript Type1 字型的 handle。 


  
  
參考  


ImagePSLoadFont()   

  

-------------------------------------------------------------------------------- 
 函式:ImagePSEncodeFont()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImagePSEncodeFont 
PostScript 字型轉成向量字。 

語法: int imagepsencodefont(string encodingfile); 

傳回值: 整數 

函式種類: 圖形處理 


  
  
內容說明  


本函式將 PostScript Type1 字型轉換成向量字。若需要西方語系的特殊文字則要 T1lib 函式庫。目前 T1lib 提供 IsoLatin1.enc 和 IsoLatin2.enc 二套字。若常要使用向量字,可以在 php3.ini/php.ini 中設定 ps.default_encoding,PHP 系統會自動載入轉換。 


  
  
參考  


ImagePSLoadFont()   
  

-------------------------------------------------------------------------------- 
 函式:ImagePSText()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImagePSText 
寫 PostScript 文字到圖中。 

語法: array imagepstext(int image, string text, int font, int size, int foreground, int background, int x, int y, int space, int tightness, float angle, int antialias_steps); 

傳回值: 陣列 

函式種類: 圖形處理 


  
  
內容說明  


本函式將 PostScript Type1 字型文字寫入圖片。參數 image 為圖形。text 參數為要寫入的字串。參數 font 則為指定的字型。參數 size 為字的大小,單位為像素 (pixel)。參數 foreground 及 background 分別為前景及背景色,程式會依這二色來修正文字邊緣的鋸齒。參數 x,y 為文字的坐標,以左下角開始計算。space 參數為文字間的空隔大小。參數 tightness 為單字間的緊密度。angle 為角度。最一個參數 antialias_steps 為邊緣鋸齒狀修正的等級,范圍為 4 至 16。傳回陣列有四個元素,第一、二個分別為左下角的 x,y 值,第三、四個元素為右上角的 x,y 值。 


  
  
參考  


ImagePSBBox()   
  

-------------------------------------------------------------------------------- 
 函式:ImagePSBBox()  
-------------------------------------------------------------------------------- 
  


圖形處理函式庫 


ImagePSBBox 
計算 PostScript 文字所佔區域。 

語法: array imagepsbbox(string text, int font, int size, int space, int width, float angle); 

傳回值: 陣列 

函式種類: 圖形處理 


  
  
內容說明  


本函式用來計算並傳回 PostScript 文字區域框 (bounding box) 大小。參數 text 為要寫入的字串。參數 font 則為指定的字型。參數 size 為字的大小,單位為像素 (pixel)。參數 width 為的寬度。angle 為角度。傳回陣列有四個元素,第一、二個分別為左下角的 x,y 值,第三、四個元素為右上角的 x,y 值。 


  
  
參考  


ImagePSText()     (http://www.fanqiang.com)
    進入【UNIX論壇

相關文章
PHP4手冊:函數庫及函數(四十六) SNMP 網管函式庫 (2001-04-18 16:56:55)
PHP4手冊:函數庫及函數(四十五) Solid 資料庫連結函式庫 (2001-04-18 16:54:16)
PHP4手冊:函數庫及函數(四十四) 信號與共享記憶體函式庫 (2001-04-18 16:49:09)
PHP4手冊:函數庫及函數(四十三) 常規表示法函式庫 (2001-04-18 16:40:33)
PHP4手冊:函數庫及函數(四十二) URL 處理函式庫 (2001-04-18 16:37:13)
PHP4手冊:函數庫及函數(四十一) PostgreSQL 資料庫函式庫 (2001-04-18 15:58:12)
PHP4手冊:函數庫及函數(四十) PDF 格式檔案函式庫 - 2 (2001-04-18 15:53:53)
PHP4手冊:函數庫及函數(四十) PDF 格式檔案函式庫 - 1 (2001-04-18 15:53:35)
PHP4手冊:函數庫及函數(三十九) Perl 相容語法函式庫 (2001-04-18 15:45:08)
PHP4手冊:函數庫及函數(三十八) Oracle 資料庫函式庫 (2001-04-18 15:43:09)

===更多相關===
 

★  樊強制作 歡迎分享  ★