zoukankan      html  css  js  c++  java
  • 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);
  • 相关阅读:
    Net Core -- 配置Kestrel端口
    NET Core迁移
    NET Core 2.0 微服务跨平台实践
    NET Core 与 Vue.js 服务端渲染
    Varnish 实战
    Hitchhiker 是一款开源的 Restful Api 测试工具
    ABP框架用Dapper实现通过SQL访问数据库
    开源框架总体介绍
    Net Core API网关Ocelot
    Jquery autocomplete插件
  • 原文地址:https://www.cnblogs.com/xiaozong/p/5758329.html
Copyright © 2011-2022 走看看