位置: 编程技术 - 正文
推荐整理分享PHP:imagecolorclosestalpha()的用法_GD库图像处理函数,希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!
(PHP 4 >= 4.0.6, PHP 5)
imagecolorclosestalpha — 取得与指定的颜色加透明度最接近的颜色
说明 int imagecolorclosestalpha ( resource $image , int $red , int $green , int $blue , int $alpha )返回图像调色板中与指定的 RGB 值以及 alpha 深度最“接近”的颜色。
参数image
由图象创建函数(例如imagecreatetruecolor())返回的图象资源。
red红色成分的值。
green绿色成分的值。
blue蓝色成分的值。
alphaA value between 0 and . 0 indicates completely opaque while indicates completely transparent.
The colors parameters are integers between 0 and or hexadecimals between 0x and 0xFF. 返回值Returns the index of the closest color in the palette.
范例
Example #1 Search for a set of colors in an image
<?php//Startwithanimageandconvertittoapalette-basedimage$im=imagecreatefrompng('figures/imagecolorclosest.png');imagetruecolortopalette($im,false,);//Searchcolors(RGB)$colors=array(array(,,,),array(,,,),array(,,,0),array(,,,));//Loopthrougheachsearchandfindtheclosestcolorinthepalette.//Returnthesearchnumber,thesearchRGBandtheconvertedRGBmatchforeach($colorsas$id=>$rgb){$result=imagecolorclosestalpha($im,$rgb[0],$rgb[1],$rgb[2],$rgb[3]);$result=imagecolorsforindex($im,$result);$result="({$result['red']},{$result['green']},{$result['blue']},{$result['alpha']})";echo"#$id:Search($rgb[0],$rgb[1],$rgb[2],$rgb[3]);Closestmatch:$result.n";}imagedestroy($im);?>以上例程的输出类似于:
注释Note: 此函数需要 GD 2.0.1 或更高版本(推荐 2.0. 及更高版本)。
参见imagecolorexactalpha() - 取得指定的颜色加透明度的索引值 imagecolorclosest() - 取得与指定的颜色最接近的颜色的索引值 imagecolorclosesthwb() - 取得与给定颜色最接近的色度的黑白色的索引
PHP:imagecolorallocate()的用法_GD库图像处理函数 imagecolorallocate(PHP4,PHP5)imagecolorallocate为一幅图像分配颜色说明intimagecolorallocate(resource$image,int$red,int$green,int$blue)imagecolorallocate()返回一个标识符,代表了由
PHP:imagechar()的用法_GD库图像处理函数 imagechar(PHP4,PHP5)imagechar水平地画一个字符说明boolimagechar(resource$image,int$font,int$x,int$y,string$c,int$color)imagechar()将字符串c的第一个字符画在image指定的图像中
PHP:imagearc()的用法_GD库图像处理函数 imagearc(PHP4,PHP5)imagearc画椭圆弧说明boolimagearc(resource$image,int$cx,int$cy,int$w,int$h,int$s,int$e,int$color)imagearc()以cx,cy(图像左上角为0,0)为中心在image所代表的图
标签: PHP:imagecolorclosestalpha()的用法_GD库图像处理函数
本文链接地址:https://www.jiuchutong.com/biancheng/288386.html 转载请保留说明!上一篇:PHP:imagecolorclosest()的用法_GD库图像处理函数
下一篇:PHP:imagechar()的用法_GD库图像处理函数(php中imagecreatefromjpeg)
友情链接: 武汉网站建设