您的位置:首页 > 编程语言 > PHP开发

php之实现打印的正方形

2009-02-06 10:54 381 查看
浏览html文件将看到一个红色的正方形

//php图片

<?php
$img = ImageCreate(200, 200);
$clrWhite = ImageColorAllocate($img, 0xff, 0xff, 0xff);
$clrRed = ImageColorAllocate($img, 0xff, 0x00, 0x00);
$clrBlue = ImageColorAllocate($img, 0x00, 0x00, 0xff);
$clrGreen = ImageColorAllocate($img, 0x00, 0xff, 0x00);
ImageFilledRectangle($img, 50, 50, 150, 150, $clrRed);
ImageRectangle($img, 0, 0, 200 - 1, 200 - 1, $clrBlue);
ImageString($img, 5, 50, 160, "A red Squar", $clrGreen);

$tpImg = ImageTypes();
if ($tpImg & IMG_PNG)
{
header('Context-type: image/png');
ImagePNG($img);
}
else if ($tyImg & IMG_JPG)
{
header("Content-Type: image/jpeg");
ImageJPEG($img);
}
else if ($tyImg & IMG_GIF)
{
header('Content-type: image/gif');
ImageGIF($img);
}
?>


//html文件

<html>
<head>
<title> read squr </title>
</head>
<body>
<img src = "squr.php">
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: