php create distortionless HD image implementation code

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags code content create created examples function high high-definition

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

Related Article

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.