Use PHP's GD library to draw a horizontal dashed line solution

Source: Internet
Author: User
Tags dashed line imagejpeg
Use PHP's GD library to draw horizontal dashed lines
Run the following code
PHP Code
  
   $img = imagecreatetruecolor, $white = Imagecolorallocate ($img, 255, 255, 255); Imagedashedline ($img, 20, 20, 500, ($white), Imagedashedline ($img, (a), $white), header ("Content-type:image/jpeg"), imagejpeg ($IMG); Imagedestroy ($IMG);

You will find that the vertical dashed line is fine, but the horizontal dashed line is not displayed. Who knows why?


------Solution--------------------
PHP code
 $img = Imagecreatetruecolor (+); $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 ("Content-type:image/jpeg"); imagejpeg ($img); Imagedestroy ($img); 
------Solution--------------------
The bug reported by ' Michi @ Marel dot at ' also exists in PHP version 5.1.1. This functions just works with vertical lines! 5.1.1 version found the bug, against the use of this function. The
------solution should be replaced with the combination of Imagesetstyle () and Imageline ()--------------------
This functions just works with vertical Lines! This function can only draw a vertical line!
------Solution--------------------
Indeed, the GD library can only draw vertical dashed lines!
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.