GD PHP

Drawing on a Palette-Based Image

This PHP program demonstrates how to draw on a color-palette-based image with the Graphics Draw, GD, library.

DrawingInAPaletteBasedImage.php

<?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);
?>
 

Output

 
 

© 2007–2024 XoaX.net LLC. All rights reserved.