2

The imagesetthickness() on the PHP will change the thickness of all lines on the image. Is there any way to select what line to be associated with this function? For Example in following image I would like to ONLY change the thickness of GREEN lines to 5.

<?php
 $image = ImageCreate(130, 170);
 $white = ImageColorAllocate($image, 255, 255, 255);
 $black = ImageColorAllocate($image, 0, 0, 0);
 $green = ImageColorAllocate($image, 82, 128, 8);

 ImageFill($image, 0, 0, $white);

 ImageSetThickness ($image , 5);

 ImageLine($image,60,40,60,100,$black);
 ImageLine($image,25,25,100,25,$green);

 ImagePng($image, "flag.png");
 ImageDestroy($image);
 ?>
4

1 回答 1

0

您只需在调用之前将厚度设置为所需的值imageline

<?php
 $image = ImageCreate(130, 170);
 $white = ImageColorAllocate($image, 255, 255, 255);
 $black = ImageColorAllocate($image, 0, 0, 0);
 $green = ImageColorAllocate($image, 82, 128, 8);

 ImageFill($image, 0, 0, $white);

 // set to 3 for the next call 
 ImageSetThickness ($image , 3);
 ImageLine($image,60,40,60,100,$black);

 // set to 5 for the next call
 ImageSetThickness ($image , 5);
 ImageLine($image,25,25,100,25,$green);

 // Set back to 3 for any future calls calls
 ImageSetThickness ($image , 3);

 ImagePng($image, "flag.png");
 ImageDestroy($image);
于 2013-04-25T20:53:01.817 回答