|
imagecolorallocatealpha
Allocate a color for an image
(PHP 4 >= 4.3.2, PHP 5)
Example 990. Example of using imagecolorallocatealpha()<?php The above example will output something similar to: Code Examples / Notes » imagecolorallocatealphaeric
If you only wish to extract the alpha value for a color, you can simply extract it like so: <?php $color = imagecolorat($im, 50, 50); $alpha = $color >> 24; ?> It actually shifts off the first 24 bits (where 8x3 are used for each color), and returns the remaining 7 allocated bits (commonly used for alpha) fchristl
Check out this Source, it's a little funny feature showing you, for what imagecolorallocatealpha() is used: <?php $im=imagecreatetruecolor(300,300); $white=imagecolorallocate($im,255,255,255); imagefilledrectangle($im,0,0,imagesx($im),imagesy($im),$white); for($i=0;$i<256;$i=$i+10) { $col=imagecolorallocatealpha($im,$i,$i,$i,ceil(rand(0,127))); imagefilledellipse($im,$i,$i,$i,$i,$col); } header("content-type: image/png"); imagepng($im); ?> |
Change Languagegd_info getimagesize image_type_to_extension image_type_to_mime_type image2wbmp imagealphablending imageantialias imagearc imagechar imagecharup imagecolorallocate imagecolorallocatealpha imagecolorat imagecolorclosest imagecolorclosestalpha imagecolorclosesthwb imagecolordeallocate imagecolorexact imagecolorexactalpha imagecolormatch imagecolorresolve imagecolorresolvealpha imagecolorset imagecolorsforindex imagecolorstotal imagecolortransparent imageconvolution imagecopy imagecopymerge imagecopymergegray imagecopyresampled imagecopyresized imagecreate imagecreatefromgd2 imagecreatefromgd2part imagecreatefromgd imagecreatefromgif imagecreatefromjpeg imagecreatefrompng imagecreatefromstring imagecreatefromwbmp imagecreatefromxbm imagecreatefromxpm imagecreatetruecolor imagedashedline imagedestroy imageellipse imagefill imagefilledarc imagefilledellipse imagefilledpolygon imagefilledrectangle imagefilltoborder imagefilter imagefontheight imagefontwidth imageftbbox imagefttext imagegammacorrect imagegd2 imagegd imagegif imagegrabscreen imagegrabwindow imageinterlace imageistruecolor imagejpeg imagelayereffect imageline imageloadfont imagepalettecopy imagepng imagepolygon imagepsbbox imagepsencodefont imagepsextendfont imagepsfreefont imagepsloadfont imagepsslantfont imagepstext imagerectangle imagerotate imagesavealpha imagesetbrush imagesetpixel imagesetstyle imagesetthickness imagesettile imagestring imagestringup imagesx imagesy imagetruecolortopalette imagettfbbox imagettftext imagetypes imagewbmp imagexbm iptcembed iptcparse jpeg2wbmp png2wbmp |