PHP 繪圖

PHP 繪圖

以下範例是用來產生出一張A4紙 畫出 3mm x 3mm格子
<?php

// example2.php

// set the HTTP header type to PNG
header("Content-type: image/png");

// set the width and height of the new image in pixels
$mm = 35;
$width = 2480;
$height = 3508;
// create a pointer to a new true colour image
$im = ImageCreateTrueColor($width, $height);

// switch on image antialising if it is available
ImageAntiAlias($im, true);

// sets background to white
$white = ImageColorAllocate($im, 255, 255, 255);
ImageFillToBorder($im, 0, 0, $white, $white);

// define a black colour
$red = ImageColorAllocate($im, 255, 0, 0);
$black = ImageColorAllocate($im, 0, 0, 0);
// make a new line and add it to the image

while(true){
        if($i * $mm > $height) { break;}
         ImageLine($im, 0, $i * $mm, $width, $i*$mm, $black);
         $i++;
}
$i = 0;
while(true){
        if($i * $mm > $width) { break;}
         ImageLine($im, $i * $mm, 0, $i*$mm, $height, $black);
         $i++;
}

// send the new PNG image to the browser
ImagePNG($im);

$im = ImageCreateFromPng("test.png");
ImagePng($im);

// destroy the reference pointer to the image in memory to free up resources
ImageDestroy($im);

?>

留言

這個網誌中的熱門文章

delivery note和delivery order的區別和翻譯

Eclipse 3.6.1 Helios 中文化方法

牙技專業英文--技工篇