This PHP program demonstrates how to draw on a color-palette-based image with the Graphics Draw, GD, library.
<?php
// Create a color palette-based image
$qPaletteImage = imagecreate(500, 400);
// The first color allocated in a palette-based image automatically paints the background.
$qBackgroundColor = imagecolorallocate( $qPaletteImage, 200, 200, 200);
$qDrawColor = imagecolorallocate( $qPaletteImage, 255, 255, 220);
imageline( $qPaletteImage, 50, 100, 450, 300, $qDrawColor);
imagerectangle($qPaletteImage, 50, 100, 450, 300, $qDrawColor);
imageellipse($qPaletteImage, 250, 200, 400, 200, $qDrawColor);
header("Content-type: image/png");
imagepng($qPaletteImage);
imagedestroy($qPaletteImage);
?>
© 20072025 XoaX.net LLC. All rights reserved.