PHP create without losing true HD picture implementation Code _php tutorial

Source: Internet
Author: User
Tags dashed line
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, ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.