您的位置:首页 > 其它

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

2006-10-09 00:00 459 查看

    $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;

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐