* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: gd.php,v 1.2 2005/02/21 20:49:58 nosey Exp $ * @link http://pear.php.net/package/Image_Graph */ // create a true color image (requires GD2) $image = ImageCreateTrueColor(400, 300); ImageAlphaBlending($image, true); // allocate some colors $black = ImageColorAllocate($image, 0, 0, 0); $red = ImageColorAllocate($image, 0xff, 0, 0); $green = ImageColorAllocate($image, 0, 0xff, 0); $blue = ImageColorAllocate($image, 0, 0, 0xff); $white = ImageColorAllocate($image, 0xff, 0xff, 0xff); // create a frame ImageFilledRectangle($image, 0, 0, 399, 299, $white); ImageRectangle($image, 0, 0, 399, 299, $black); // draw some lines ImageLine($image, 200, 50, 350, 150, $red); ImageLine($image, 200, 60, 350, 160, $green); ImageLine($image, 200, 70, 350, 170, $blue); // draw some overlapping alpha blended boxes $redAlpha = ImageColorAllocateAlpha($image, 0xff, 0, 0, 75); $blueAlpha = ImageColorAllocateAlpha($image, 0, 0xff, 0, 75); $greenAlpha = ImageColorAllocateAlpha($image, 0, 0, 0xff, 75); ImageFilledRectangle($image, 50, 50, 90, 90, $redAlpha); ImageFilledRectangle($image, 60, 80, 100, 120, $greenAlpha); ImageFilledRectangle($image, 80, 60, 120, 100, $blueAlpha); // write some _default_ text for ($font = 1; $font <= 5; $font++) { ImageString($image, $font, 50, 150 + $font * 20, 'Testing GD output', $black); } ImageString($image, 3, 51, 21, 'Congratulations! The GD2 installation works', $black); ImageString($image, 3, 50, 20, 'Congratulations! The GD2 installation works', $red); // output the test image header('Content-Type: image/png'); ImagePNG($image); ?>