zoukankan      html  css  js  c++  java
  • PHP图像处理

    1.创建画布:

      $img=imagescreatetruecolor(200,200);

      创建颜色并填充

      $red=imagecolorallocate($img,255,0,0);  //创建颜色

      $imagefill($img,0,10,$red);  //填充颜色

    2.画图形

      矩形:

        

        imagedrectangle($img,90,10,190,80,$green); 不填充的矩形
        imagefilledrectangle($img,90,10,190,80,$green); 填充的矩形

      线段:

        imageline($img,0,0,200,200,$blue);

      点:

        imagesetpixel ($img,50,50,$red);

      圆:

        imageellipse ($img,100,100,100,100,$green);

          image

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

          cx

          中间的 X 坐标。

          cy

          中间的 Y 坐标。

          width

          椭圆的宽度。

          height

          椭圆的高度。

          color

          椭圆的颜色。颜色标识符由 imagecolorallocate() 创建。

      圆形:

        imagefilledarc($img,50,50,-160,40,$green);

        

      圆弧:

        imagefilledarc($img,50,50,100,50-160,40,$green,IMG_ARC_RIE);

          bool imagefilledarc ( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )
           imagefilledarc() 在 image 所代表的图像中以 cxcy(图像左上角为 0, 0)画一椭圆弧。如果成功则返回 TRUE,失败则返回 FALSEw 和 h 分别指定了椭圆的宽和高,s 和 e 参数以角度指定了起始和结束点。style 可以是下列值按位或(OR)后的值:

      写字符到图像:

        水平画:imagechar($img,5,100,100,"ABCDEFG",$red);

        垂直画:imagecharup($img,5,100,100,"ABCDEFGHIJK",$red);

    3.输出资源

        header("Content-type:image/gif");

        imagegif($img);

    4.释放资源

        imagedestry($img);

  • 相关阅读:
    VIJOS-P1340 拯救ice-cream(广搜+优先级队列)
    uva 11754 Code Feat
    uva11426 GCD Extreme(II)
    uvalive 4119 Always an Interger
    POJ 1442 Black Box 优先队列
    2014上海网络赛 HDU 5053 the Sum of Cube
    uvalive 4795 Paperweight
    uvalive 4589 Asteroids
    uvalive 4973 Ardenia
    DP——数字游戏
  • 原文地址:https://www.cnblogs.com/subtract/p/3870767.html
Copyright © 2011-2022 走看看