이미지 처리 및 GD imagecolorset
(PHP 4, PHP 5, PHP 7, PHP 8)
imagecolorset — 지정된 팔레트 인덱스의 색상 설정
설명
imagecolorset( GdImage $image, int $color, int $red, int $green, int $blue, int $alpha = 0 ): ?bool
이렇게 하면 팔레트의 지정된 인덱스가 지정된 색상으로 설정됩니다. 이것은 실제 홍수 채우기를 수행하는 오버헤드 없이 팔레트 이미지에서 홍수 채우기와 같은 효과를 만드는 데 유용합니다.
매개변수
image
- imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
red
- 빨간색 구성 요소의 값입니다.
green
- 녹색 구성 요소의 가치.
blue
- 파란색 구성 요소의 값입니다.
alpha
- 알파 구성 요소의 값입니다.
반환 값
함수는 성공하면 null
을 반환하고 실패하면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.0.0 | image 는 이제 GdImage 인스턴스를 예상합니다. 이전에는 리소스가 필요했습니다. |
Examples
예제 #1 imagecolorset() 예제
<?php
// Create a 300x100 image
$im = imagecreate(300, 100);
// Set the background to be red
imagecolorallocate($im, 255, 0, 0);
// Get the color index for the background
$bg = imagecolorat($im, 0, 0);
// Set the backgrund to be blue
imagecolorset($im, $bg, 0, 0, 255);
// Output the image to the browser
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>
기타
- imagecolorat() - 픽셀의 색상 인덱스 가져오기