导航首页 » 技术教程 » PHP:imagesetthickness()的用法_GD库图像处理函数
PHP:imagesetthickness()的用法_GD库图像处理函数 143 2023-12-15   

imagesetthickness

(PHP 4 >= 4.0.6, PHP 5)

imagesetthickness — 设定画线的宽度

说明

bool imagesetthickness ( resource $image , int $thickness )

imagesetthickness() 把画矩形,多边形,椭圆等等时所用的线宽设为 thickness 个像素。成功时返回 TRUE, 或者在失败时返回 FALSE

Note: 此函数需要 GD 2.0.1 或更高版本(推荐 2.0.28 及更高版本)。

参数

image

由图象创建函数(例如imagecreatetruecolor())返回的图象资源。

thickness

Thickness, in pixels.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

Example #1 imagesetthickness() example

<?php
// Create a 200x100 image
$im = imagecreatetruecolor(200, 100);
$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);

// Set the background to be white
imagefilledrectangle($im, 0, 0, 299, 99, $white);

// Set the line thickness to 5
imagesetthickness($im, 5);

// Draw the rectangle
imagerectangle($im, 14, 14, 185, 85, $black);

// Output image to the browser
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
?>

以上例程的输出类似于:

注释

Note: 此函数需要 GD 2.0.1 或更高版本(推荐 2.0.28 及更高版本)。


!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103