In PHP in order to generate high-definition images must be done with the Imagecreatetruecolor function, the following see its usage imagecreatetruecolor (int x,int y) is a black image of size and Y, Instead of adding a background color to the generated pixels, it uses the Imagecolorallocate () to create a drawing color directly.
In the PHP tutorial in order to generate HD pictures must be done with the Imagecreatetruecolor function, the following see its usage
Imagecreatetruecolor (int x,int y) is a black image of size and y, and its example does not add a background color to the generated pixels, but instead creates a drawing color directly with the Imagecolorallocate ().
*/
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);
/*
Executing the code will generate a graphic with a red background.
*/
Code two
Create a true Color image
$img =imagecreatetruecolor (400,400);
Performing operations by looping
for ($i =10; $i <=350; $i = $i +20)
{
Define 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);
Destroying images
Imagedestroy ($IMG);
/*
The code is executed as shown in result 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);
Drawing on an 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);
Destroying images
Imagedestroy ($IMG);
/*
The execution results of this code are shown in 22.6:
*/
Example Four
Send header File
Header ("Content-type:image/png");
Create an image if the output fails
$im =imagecreatetruecolor (500,500); Create an image
Define background color
$black =imagecolorallocate ($im, 0,0,0);
Define Line Colors
$color =imagecolorallocate ($im, 0,255,255);
Draw a dashed line on the image
Imageline ($im, 1,1,450,450, $color);
Output image File
Imagepng ($im);
Destroying images
Imagedestroy ($im);
http://www.bkjia.com/PHPjc/632995.html www.bkjia.com true http://www.bkjia.com/PHPjc/632995.html techarticle in PHP in order to generate high-definition images must be done with the Imagecreatetruecolor function, the following see its usage imagecreatetruecolor (int x,int y) is a black image of the size and Y, ...