note 35765 added to function.imagecolorallocate

From: Date: Sat, 13 Sep 2003 21:44:56 +0000
Subject: note 35765 added to function.imagecolorallocate
Groups: php.notes 
Request: Send a blank email to php-notes+get-56456@lists.php.net to get a copy of this message
<?php /* An example combining the use of ImageColorAllocate, Imagesetpixel, Imagecopyresized and some basic Trig */ Header("Content-type: image/png"); $height = 128; $width = 128; $imA = ImageCreate($width, $height); $imB = ImageCreate($width*4, $height*4); $bckA = ImageColorAllocate($imA, 0,0,0); $bckB = ImageColorAllocate($imB, 0,0,0); //GENERATE GRAY SCALE PALLETE for($c=0;$c<256;$c++){ ImageColorAllocate($imA, $c, $c, $c); } //PRODUCE DATA $m=rand(0,10); for($c=0;$c<128;$c++){ $s= (sin( deg2rad($c*360*$m/128) )+1)*127; $col_arr[$c]=$s; } for($y=0;$y<$height;$y++){ for($x=0;$x<$width;$x++){ $imgA[$x][$y]=$col_arr[$x]; } } for($y=0;$y<$height;$y++){ for($x=0;$x<$width;$x++){ $imgB[$x][$y]=$col_arr[$y]; } } //SET PIXELS for($y=0;$y<$height;$y++){ for($x=0;$x<$width;$x++){ $imgC[$x][$y]=$imgA[$x][$y]+$imgB[$x][$y]; $s=$imgC[$x][$y]/2; Imagesetpixel($imA,$x,$y,$s); } } //RESIZE IMAGE FOR DISPLAY Imagecopyresized ($imB, $imA, 0, 0, 0, 0, $width*4, $height*4, $width, $width); ImagePNG($imB); ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35765 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35765&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35765&report=yes

« previous php.notes (#56456) next »