不用GD库生成当前时间的PNG格式图象的程序

2016-01-29 14:58 31 1 收藏

不用GD库生成当前时间的PNG格式图象的程序,不用GD库生成当前时间的PNG格式图象的程序

【 tulaoshi.com - PHP 】

 

该程序是不用GD库可以生成当前时间的PNG格式图象,给人大开眼界,很有参考价值. teaman整理

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/php/)

<?php
       
    function set_4pixel($r, $g, $b, $x, $y)
    {
    global $sx, $sy, $pixels;

    $ofs = 3 * ($sx * $y + $x);
    $pixels[$ofs] = chr($r);
    $pixels[$ofs + 1] = chr($g);
    $pixels[$ofs + 2] = chr($b);
    $pixels[$ofs + 3] = chr($r);
    $pixels[$ofs + 4] = chr($g);
    $pixels[$ofs + 5] = chr($b);
    $ofs += 3 * $sx;
    $pixels[$ofs] = chr($r);
    $pixels[$ofs + 1] = chr($g);
    $pixels[$ofs + 2] = chr($b);
    $pixels[$ofs + 3] = chr($r);
    $pixels[$ofs + 4] = chr($g);
    $pixels[$ofs + 5] = chr($b);
    }
    //生成数字图象的函数    
    function draw2digits($x, $y, $number)
    {
    draw_digit($x, $y, (int) ($number / 10));
    draw_digit($x + 11, $y, $number % 10);
    }
        
    function draw_digit($x, $y, $digit)
    {
    global $sx, $sy, $pixels, $digits, $lines;
            
    $digit = $digits[$digit];
    $m = 8;
    for ($b = 1, $i = 0; $i < 7; $i++, $b *= 2) {
        if (($b & $digit) == $b) {
        $j = $i * 4;
        $x0 = $lines[$j] * $m + $x;
        $y0 = $lines[$j + 1] * $m + $y;
        $x1 = $lines[$j + 2] * $m + $x;
        $y1 = $lines[$j + 3] * $m + $y;
        if ($x0 == $x1) {
            $ofs = 3 * ($sx * $y0 + $x0);
            for ($h = $y0; $h <= $y1; $h++, $ofs += 3 * $sx) {
            $pixels[$ofs] = chr(0);
            $pixels[$ofs + 1] = chr(0);
            $pixels[$ofs + 2] = chr(0);
            }
        } else {
            $ofs = 3 * ($sx * $y0 + $x0);
            for ($w = $x0; $w <= $x1; $w++) {
            $pixels[$ofs++] = chr(0);
            $pixels[$ofs++] = chr(0);
            $pixels[$ofs++] = chr(0);
            }
        }
        }
    }
    }
        
    //将文字加入到图象中 
    function add_chunk($type)
    {
    global $result, $data, $chunk, $crc_table;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/php/)

    // chunk :为层
    // length: 4 字节: 用来计算 chunk 
    // chunk type: 4 字节
    // chunk data: length bytes

来源:https://www.tulaoshi.com/n/20160129/1494878.html

延伸阅读
一、静态库的生成 a) 用VC向导生成一个win32 Static Library工程 b) 添加头文件,声明函数接口。 c) 添加实现文件,包含头文件并实现其中的函数。 d) 编译工程后,生成Mylib.lib。 二、静态库的应用 a) 用MFC AppWizard生成VC++工程。 b) 将前面生成的Mylib.lib 和 mylib.h拷贝到当前工程目录下...
网上好象这个例子还没有样,如果你用VC做一个人事部管理系统,不可能没有人员照片吧!能找到的例子中都是用BMP,不敢用! 这个例子用到了VC6.0和access2002(officeXP),涉及到ADO的用法,文件对话框的使用,一个CPicture类和一个buffer缓冲区。 一、我的ADO用法整理 1. stdafx.h头文件中加入: #import "c:program filescommon...
C程序在 Linux系统 编辑器: mcedit;vi;emacs 编译: cc;gcc;g++ 运行: ./a.out (编译输出的默认文件) 一般是编辑Makefile文件,用make编译工程文件 Makefile 规则通用形式: target :dependency dependency [....] command command [....] #一个简单的Makefile...
标签: PHP
  用php生成excel文件   <? header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=test.xls"); echo "test1\t"; echo "test2\t\n"; echo "test1\t"; echo "test2\t\n"; echo "test1\t"; echo "test2\t\n&q...
在澳门10周年纪念版中,加强了对粘贴选项的支持。我们从“工具”→“选项”菜单中调出“选项”设置面板,切换到“编辑”选项卡,可以看到,在其下方多出了“剪切和粘贴选项”,在WPS文档中粘贴新内容后,在粘贴内容的后面会出现一个粘贴选项下拉按钮图标 。点击下拉按钮右侧的小三角,...

经验教程

581

收藏

74
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部