検索
ホームページphp教程php手册GDライブラリを使わずに現時点のPNG形式画像を生成するPHPプログラム ページ1/2

GDライブラリを使わずに現時点のPNG形式画像を生成するPHPプログラム ページ1/2

Jun 13, 2016 pm 12:26 PM
functionphppngset図書館時間フォーマット生成するプログラム


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);
}
// 数字図形を生成する関数
functiondraw2digits($x, $y, $number)
{
draw_digit($x, $y, (int) ($数値 / 10));
draw_digit($x 11, $y, $number % 10);
}

functiondraw_digit($x, $y, $digit)
{
global $sx, $sy, $pixels, $digits, $lines;

$digit = $digits[$digit];
$m = 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)
{
グローバル $result、$data、$chunk、$crc_table;

// チャンク : 為层
// 長さ: 4 字节: 用来计算チャンク
// チャンクタイプ: 4 字节
// チャンクデータ: 長さバイト
// CRC: 4 字节: 循環冗余网验

// データをコピーし、CRC チェックサムを作成します
$len = strlen($data);
$chunk = Pack("c*", ($len >> 24) & 255,
($len >> 16) & 255,
($len >>> 8) & 255、
$len & 255);
$chunk .= $type;
$chunk .= $data;

// バイトチャンク[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);
}
}

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

WebStorm Mac版

WebStorm Mac版

便利なJavaScript開発ツール

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

SublimeText3 Linux 新バージョン

SublimeText3 Linux 新バージョン

SublimeText3 Linux 最新バージョン

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター