设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 数据 手机
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP图像处理怎样获得索引的颜色?

发布时间:2022-11-28 08:53 所属栏目:121 来源:互联网
导读:这篇文章主要讲解了PHP图像处理怎样获取索引的颜色?,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习PHP图像处理怎样获取索引的颜色?吧! PHP 图像处理 imagecolorsforindex 取得某索引的颜色。 语法 array
  这篇文章主要讲解了“PHP图像处理怎样获取索引的颜色?”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“PHP图像处理怎样获取索引的颜色?”吧!
 
  PHP 图像处理
 
  imagecolorsforindex — 取得某索引的颜色。
 
  语法
 
  array imagecolorsforindex ( resource $image , int $index )
 
  本函数返回一个具有 red,green,blue 和 alpha 的键名的关联数组,包含了指定颜色索引的相应的值。
 
  实例
 
  <?php
 
  // 打开一幅图像
 
  $im = imagecreatefrompng('youj-logo.png');
 
  // 取得一点的颜色
 
  $start_x = 40;
 
  $start_y = 20;
 
  $color_index = imagecolorat($im, $start_x, $start_y);
 
  // 使其可读
 
  $color_tran = imagecolorsforindex($im, $color_index);
 
  // 显示该颜色的值
 
  print_r($color_tran);
 
  ?>
 
  以上实例的输出类似于:
 
  Array
 
  (
 
      [red] => 195
 
      [green] => 223
 
      [blue] => 165
 
      [alpha] => 64
 
  )
 

(编辑:ASP站长网)

    网友评论
    推荐文章
      热点阅读