PHP 中的 imagecolorexact() 函数
imagecolorexact() 函数获取指定颜色的索引。
语法
imagecolorexact ( $img, $red, $green, $blue )
参数
img: 使用 imagecreatetruecolor() 创建的图像资源。
red: 红色颜色组件
green: 绿色颜色组件
blue: 蓝色颜色组件
返回
imagecolorexact() 函数返回调色板中指定颜色的索引,如果颜色不存在,则返回 -1。
示例
以下是一个示例
<?php
$img = imagecreatefrompng('https://tutorialspoint.com/assets/videos/courses/67/images/course_67_image.png');
$colors = Array();
$colors[] = imagecolorexact($img, 30, 90, 50);
$colors[] = imagecolorexact($img, 80, 120, 100);
$colors[] = imagecolorexact($img, 25, 80, 50);
print_r($colors);
imagedestroy($img);
?>输出
以下为输出
Array ( [0] => 1989170 [1] => 5273700 [2] => 1658930 )
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP