English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
imagecolorsforindex — 특정 인덱스의 색상을 얻습니다.
array imagecolorsforindex ( resource $image , int $index )
이 함수는 red, green, blue, alpha의 키를 가진 연관 배열을 반환하며, 지정된 색상 인덱스의相应的 값을 포함합니다.
<?php // 이미지를 엽니다 $im = imagecreatefrompng('w3codebox-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 )
imagecolorat() 특정 픽셀의 색상 인덱스 값을 얻습니다.
imagecolorexact() 지정된 색상의 인덱스 값을 얻습니다.