In the php tutorial to generate high-definition images must use imagecreatetruecolor function to do, see below its usage
imagecreatetruecolor (int x, int y) creates a black image of size y and y. Instead of adding a background color to the resulting pixel, the imagecreatetruecolor directly establishes the color of a drawing using imagecolorallocate ()
* /
// Create the image
$ im = imagecreatetruecolor (100,100);
// Set the background to red
$ red = imagecolorallocate ($ im, 255,0,0);
imagefill ($ im, 0,0, $ red);
// output image
header ('content-type: image / png');
imagepng ($ im);
imagedestroy ($ im);
/ *
Executing this code will generate a graph with a red background.
* /
// code two
// Create a true color image
$ img = imagecreatetruecolor (400,400);
// Perform the operation by looping
for ($ i = 10; $ i <= 350; $ i = $ i + 20)
{
// define the color
$ color = imagecolorallocate ($ img, 200,50, $ i);
// Draw an ellipse
imageellips tutorial e ($ img, 200,200,350, $ i, $ color);
}
// output image
header ("content-type: image / png");
imagepng ($ img);
// Destroy the image
imagedestroy ($ img);
/ *
The code execution results as shown in Figure 22.7:
* /
// code three
// Create a true color image
$ img = imagecreatetruecolor (200,200);
$ white = imagecolorallocate ($ img, 255,255,255);
$ red = imagecolorallocate ($ img, 255,0,0);
$ blue = imagecolorallocate ($ img, 0,0,255);
// Draw on the image
imagearc ($ img, 100,100,50,150,360,0, $ red);
imagearc ($ img, 100,100,150,50,0,360, $ blue);
// output image
header ("content-type: image / png");
imagepng ($ img);
// Destroy the image
imagedestroy ($ img);
/ *
The result of this code is shown in Figure 22.6:
* /
// Example four
// send the header file
header ("content-type: image / png");
// Create image, if it fails to output content
$ im = imagecreatetruecolor (500,500); // Create the image
// define the background color
$ black = imagecolorallocate ($ im, 0,0,0);
// define the line color
$ color = imagecolorallocate ($ im, 0,255,255);
// Draw a dotted line on the image
imageline ($ im, 1,1,450,450, $ color);
// output image file
imagepng ($ im);
// Destroy the image