用PHP实现图片像素级别的操作:imagesetpixel 函数详解
最编程
2024-07-28 13:47:23
...
imagesetpixel()在指定的坐标处绘制像素。
语法
PHP imagesetpixel()函数具有以下语法。
bool imagesetpixel ( resource $image , int $x , int $y , int $color )
参数
PHP imagesetpixel()函数具有以下参数。
- image - 由图像创建函数(如imagecreatetruecolor())返回的图像资源。
- x-x坐标。
- y-y坐标。
- color - 使用imagecolorallocate()创建的颜色标识符。
返回值
成功时返回TRUE,失败时返回FALSE。
实例
<?php
/*
http://www.manongjc.com/article/1758.html
作者:码农教程
*/
$myImage = imagecreatetruecolor( 200, 100 );
$myGray = imagecolorallocate( $myImage, 204, 204, 204 );
$myBlack = imagecolorallocate( $myImage, 0, 0, 0 );
imagesetpixel( $myImage, 120, 60, $myBlack );
header( "Content-type: image/png" );
imagepng( $myImage );
imagedestroy( $myImage );
?>
上一篇: 轻松学习MATLAB:从头开始,用plot函数画出函数图示
下一篇: 在Qt中绘制函数图形的方法