国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 語(yǔ)言 > PHP > 正文

php利用imagecreatetruecolor動(dòng)態(tài)生成高清圖片代碼

2024-09-04 11:44:34
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

實(shí)例一,用我們用imagecreatetruecolor,代碼如下:

  1. header ('Content-type: image/png'); 
  2. $im = @imagecreatetruecolor(120, 20) 
  3.       or die('Cannot Initialize new GD image stream'); 
  4. $text_color = imagecolorallocate($im, 233, 14, 91); 
  5. imagestring($im, 1, 5, 5,  'A Simple Text String'$text_color); 
  6. imagepng($im); 
  7. imagedestroy($im); 

我把這個(gè)一起 - 結(jié)合較好的例子,然后動(dòng)態(tài)生成的文本,但是,與此成立,我能得到透明背景以及工作.

實(shí)例二,imagecreatetruecolor,代碼如下:

  1. header('Content-type: image/png'); 
  2.  
  3. // Create the image 
  4. $im = imagecreatetruecolor(175, 15); 
  5. imagesavealpha($im, true); 
  6.  
  7. // Create some colors 
  8. $white = imagecolorallocate($im, 255, 255, 255); 
  9. $grey = imagecolorallocate($im, 128, 128, 128); 
  10. $black = imagecolorallocate($im, 0, 0, 0); 
  11. imagefilledrectangle($im, 0, 0, 150, 25, $black); 
  12. $trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127); 
  13. imagefill($im, 0, 0, $trans_colour); 
  14.  
  15. // The text to draw 
  16. $text = $_GET['text']; 
  17. // Replace path by your own font path 
  18. $font = 'catriel regular.ttf'
  19.  
  20. // Add some shadow to the text 
  21. imagettftext($im, 9, 0, 13, 16, $black$font$text); 
  22.  
  23. // Add the text 
  24. imagettftext($im, 9, 0, 12, 15, $white$font$text); 
  25. //開(kāi)源代碼Vevb.com 
  26. // Using imagepng() results in clearer text compared with imagejpeg() 
  27. imagepng($im); 
  28. imagedestroy($im); 

實(shí)例三:創(chuàng)建透明圖片

如果你想創(chuàng)建一個(gè)PNG圖像*透明*,其中的背景是完全透明的,所有行動(dòng)發(fā)生在借鑒,除此之外,然后執(zhí)行下列操作,代碼如下:

  1. $png = imagecreatetruecolor(800, 600); 
  2.  imagesavealpha($png, true); 
  3.  
  4.  $trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127); 
  5.  imagefill($png, 0, 0, $trans_colour); 
  6.  //開(kāi)源代碼Vevb.com 
  7.  $red = imagecolorallocate($png, 255, 0, 0); 
  8.  imagefilledellipse($png, 400, 300, 400, 300, $red); 
  9.   
  10.  header("Content-type: image/png"); 
  11.  imagepng($png); 

你要做的就是創(chuàng)建一個(gè)真正的彩色圖像,確保阿爾法保存狀態(tài)是,然后填寫(xiě)一個(gè)顏色,也經(jīng)歷了阿爾法級(jí)別設(shè)置為完全透明(127)的圖像.

從上面的代碼產(chǎn)生的將有一個(gè)完全透明的背景,一紅色圓圈拖到Photoshop中的圖像,以了解自己.

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 遵化市| 浙江省| 新绛县| 临沂市| 永修县| 永胜县| 长春市| 大冶市| 曲阳县| 石阡县| 吉隆县| 城步| 甘孜县| 深水埗区| 凉城县| 萨迦县| 阿克苏市| 衢州市| 余姚市| 望谟县| 灵石县| 六盘水市| 兴城市| 邛崃市| 大悟县| 祁连县| 浦江县| 漯河市| 年辖:市辖区| 尚义县| 沙雅县| 紫阳县| 广汉市| 郎溪县| 淳安县| 田阳县| 泗洪县| 垫江县| 会宁县| 彰化市| 彰化市|