png格式 php不用GD函式庫產生目前時間的PNG格式圖象的程式第1/2頁

WBOY
發布: 2016-07-29 08:38:57
原創
1080 人瀏覽過

函數set_4pixel($r, $g, $b, $x, $y)
{
全域$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) ($數量/10));
draw_digit($x + 11, $y, $ number % 10);
}
函數draw_digit($x, $y, $digit)
{
全域$sx, $sy, $pixels, $digits, $lines;
$digit = $digits[$digit];
百萬美元= 8;
for ($b = 1, $i = 0; $i 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 $pixels[$ofs] = chr(0);
$pixels[$ofs + 1] = chr(0);
$pixels[$ofs + 2] = chr(0);
}
} else {
$ofs = 3 * ($sx * $y0 + $x0) ;
for ($w = $x0; $w $pixels[$ofs++] = chr(0);
$pixels[$ofs++] = chr( 0);
$pixels[$ofs++] = chr(0);
}
}
}
}
}
//將文字加入表格
function add_chunk($type)
{
global $結果,$數據,$塊,$crc_table;
// chunk :為層
// length: 4 位元組: 用於計算chunk
// chunk type: 4 位元組
// chunk data: length bytes
// CRC: 4 位元組: 循環冗餘碼校驗
// 複製資料並建立CRC校驗與
$len = strlen($data);
$chunk = pack("c*", ($len >> 24) & 255,
($len >> 16) & 255 ,
($len >> 16) & 255,
($len >> 8) & 255,
$len & 255);
$chunk .= $type;
$ chunk .= $data;
// 使用位元組chunk[4..len-1] 計算CRC 校驗和
$z = 16777215;
$z |= 255 $c = $z;
for ($n = 4; $n $c8 = ($c >> 8) & 0xffffff;
$ c = $crc_table[($c ^ ord($chunk][$n])) & 0xff] ^ $c8;
}
$crc = $c ^ $z;
$chunk .= chr(($crc >> 24) & 255);
$chunk .= chr(($crc >> 16) & 255);
$chunk .= chr(($crc >> 8) & 255);
$chunk .= chr($crc & 255);
// 將結果加到$result中
$result .= $chunk;
}
//主程式
$sx = 80;
$sy = 21;
$pixels = "";
//填充
for ($h = 0; $h for ($w = 0; $w $r = 100 / $sx * $w + 155;
$g = 100 / $sy * $ h + 155;
$b = 255 - (100 / ($sx + $sy) * ($w + $h));
$pixels .= chr($r);
$pixels .= chr($g);
$pixels .= chr($b);
}
}

目前1/2頁 12下一頁

以上就介紹了png格式php不用GD函式庫產生目前時間的PNG格式圖片的程式第1/2頁,包含了png格式方面的內容,希望對PHP教學有興趣的朋友有幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!