PHP imagesetpixel() function

Description

imagesetpixel() draws a pixel at the specified coordinate.

Syntax

PHP imagesetpixel() function has the following syntax.

bool imagesetpixel ( resource $image , int $x , int $y , int $color )

Parameter

PHP imagesetpixel() function has the following parameters.

  • image - An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().
  • x - x-coordinate.
  • y - y-coordinate.
  • color - A color identifier created with imagecolorallocate().

Return

Returns TRUE on success or FALSE on failure.

Example


<?php //from  ww w  . j  a  v a2s  .co m
        $myImage = imagecreatetruecolor( 200, 100 ); 
        $myGray = imagecolorallocate( $myImage, 204, 204, 204 ); 
        $myBlack = imagecolorallocate( $myImage, 0, 0, 0 ); 
        imagesetpixel( $myImage, 120, 60, $myBlack );   
        header( "Content-type: image/png" ); 
        imagepng( $myImage ); 
        imagedestroy( $myImage ); 
?> 




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions