宗小宗-PHP程序猿

欢迎各位朋友前来,如果我的文章中有不对的地方,还望指正;如需转载,请注明原处

PHP图形处理函数试题

一.问答题

1.取得当前安装的 GD 库的信息的函数是?

2.取得图像大小的函数是?

3.为一幅图像分配颜色 + alpha的函数是?

4.新建一个基于调色板的图像的函数是?

5.新建一个黑色图像的函数是?

6.用给定角度旋转图像的函数是?

7.水平地画一行字符串的函数是?

8.载入一新字体的函数是?

9.取得某像素的颜色索引值的函数是?

 

二.编程题

请画出下列图片

 

 


 

答案:

一.问答题

1.array gd_info ( void )

2.array getimagesize ( string $filename [, array &$imageinfo ] )

3.int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha )

  第一次对 imagecolorallocatealpha() 的调用会给基于调色板的图像填充背景色,即用 imagecreate() 建立的图像

4.resource imagecreate ( int $x_size , int $y_size )

5.resource imagecreatetruecolor ( int $width , int $height )

6.resource imagerotate ( resource $image , float $angle , int $bgd_color [, int$ignore_transparent = 0 ] )

7.bool imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col )

   如果 font 是 1,2,3,4 或 5,则使用内置字体

8.int imageloadfont ( string $file )

9.int imagecolorat ( resource $image , int $x , int $y )

二.编程题

图一

<?php
$image = imagecreatetruecolor(200, 200);

// 分配一些颜色
$white    = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$gray     = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
$darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90);
$navy     = imagecolorallocate($image, 0x00, 0x00, 0x80);
$darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50);
$red      = imagecolorallocate($image, 0xFF, 0x00, 0x00);
$darkred  = imagecolorallocate($image, 0x90, 0x00, 0x00);

// 创建 3D 效果
for ($i = 110; $i > 100; $i--) {
   imagefilledarc($image, 100, $i, 100, 50, 0, 45, $darknavy, IMG_ARC_PIE);
   imagefilledarc($image, 100, $i, 100, 50, 45, 75 , $darkgray, IMG_ARC_PIE);
   imagefilledarc($image, 100, $i, 100, 50, 75, 360 , $darkred, IMG_ARC_PIE);
}

imagefilledarc($image, 100, 100, 100, 50, 0, 45, $navy, IMG_ARC_PIE);
imagefilledarc($image, 100, 100, 100, 50, 45, 75 , $gray, IMG_ARC_PIE);
imagefilledarc($image, 100, 100, 100, 50, 75, 360 , $red, IMG_ARC_PIE);


// 输出图像
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);

 

posted @ 2016-08-10 20:33  宗小宗  阅读(396)  评论(0编辑  收藏  举报