用php的GD库画不出水平的虚线解决方法

WBOY
發布: 2016-06-13 13:31:41
原創
765 人瀏覽過

用php的GD库画不出水平的虚线
运行一下以下代码

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->$img = imagecreatetruecolor(600, 600);
$white = imagecolorallocate($img, 255, 255, 255);
imagedashedline($img, 20, 20, 500, 20, $white);
imagedashedline($img, 20, 20, 20, 500, $white);
header("content-type:image/jpeg");
imagejpeg($img);
imagedestroy($img);
登入後複製

你会发现垂直的虚线没问题,但水平虚线就不显示。有谁知道为什么?


------解决方案--------------------
PHP code
$img = imagecreatetruecolor(600, 600);
$white = imagecolorallocate($img, 255, 255, 255);
$red = imagecolorallocate($img, 255, 0, 0);

$style = array($red, $red, $red, $red, $red, $white, $white, $white, $white, $white);
imagesetstyle($img, $style);
imageline($img, 20, 20, 500, 20, IMG_COLOR_STYLED);

header("content-type:image/jpeg");
imagejpeg($img);
imagedestroy($img);
<br><font color="#e78608">------解决方案--------------------</font><br>The bug reported by 'michi at marel dot at' also exists in PHP version 5.1.1. This functions just works with vertical lines! 5.1.1版本发现的BUG,反对使用本函数。应该用 imagesetstyle() 和 imageline() 的组合替代之
<br><font color="#e78608">------解决方案--------------------</font><br>This functions just works with vertical lines!该函数只能画垂直线!
<br><font color="#e78608">------解决方案--------------------</font><br>确实,GD库只能画竖直的虚线! <div class="clear">
                 
              
              
        
            </div>
登入後複製
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!