Php creates non-distorted HD image implementation code. In php, the imagecreatetruecolor function must be used to generate high-definition images. The following describes how to use imagecreatetruecolor (intx, inty) to create a black image with a size of y, in php, the imagecreatetruecolor function must be used to generate high-definition images. The following describes how to use imagecreatetruecolor (int x, int y) to create a black image with a size of y, in this example, the background color is not added to the generated pixel. Instead, the image colorallocate () is directly used to create a painting color.
In the php Tutorial, you must use the imagecreatetruecolor function to generate a high-definition image. The following describes its usage.
Imagecreatetruecolor (int x, int y) creates a black image of the same size as y. In this example, the background color is not added to the generated pixel, instead, it uses imagecolorallocate () to create the color of a drawing.
*/
// Create an 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 );
/*
Run this code to generate a red image.
*/
// Code 2
// Create a true color image
$ Img = imagecreatetruecolor (0, 400,400 );
// Execute the operation cyclically
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 result 22.7 is as follows:
*/
// Code 3
// Create a true color image
$ Img = imagecreatetruecolor (0, 200,200 );
$ White = imagecolorallocate ($ img, 255,255,255 );
$ Red = imagecolorallocate ($ img, 255, 0, 0 );
$ Blue = imagecolorallocate ($ img, 255 );
// Draw images
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 code execution result 22.6 is as follows:
*/
// Instance 4
// Send the header file
Header ("content-type: image/png ");
// Create an image. if the output fails
$ Im = imagecreatetruecolor (500,500); // create an image
// Define the background color
$ Black = imagecolorallocate ($ im, 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
Imagedestroy ($ im );
The imagecreatetruecolor function is used. the usage of imagecreatetruecolor (int x, int y) is used to create a black image with the size of y ,...