English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
imagecolorallocatealpha — 이미지에 색상과 투명도를 할당합니다.
int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha )
imagecolorallocatealpha()의 동작은 imagecolorallocate()와 동일하지만 추가적인 투명도 매개변수 alpha를 가집니다. 이 값은 0에서 127。0은 완전 불투명을 의미합니다,127 는 완전 투명을 의미합니다.
할당이 실패하면 FALSE를 반환합니다.
주의:이 함수는 GD가 필요합니다 2.0.1 또는 이상 버전(추천 2.0.28 및 이상 버전).
<?php $size = 300; $image=imagecreatetruecolor($size, $size); // 백색 배경과 검은 테두리로 사각형을 그립니다 $back = imagecolorallocate($image, 255, 255, 255); $border = imagecolorallocate($image, 0, 0, 0); imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back); imagerectangle($image, 0, 0, $size - 1, $size - 1, $border); $yellow_x = ; 100; $yellow_y = ; 75; $red_x = ; 120; $red_y = ; 165; $blue_x = ; 187; $blue_y = ; 125; $radius = ; 150; // alpha 값으로 색상을 할당합니다 $yellow = imagecolorallocatealpha($image, 255, 255, 0, 75); $red = imagecolorallocatealpha($image, 255, 0, 0, 75); $blue = imagecolorallocatealpha($image, 0, 0, 255, 75); // 세 개의 교차하는 원을 그립니다 imagefilledellipse($image, $yellow_x, $yellow_y, $radius, $radius, $yellow); imagefilledellipse($image, $red_x, $red_y, $radius, $radius, $red); imagefilledellipse($image, $blue_x, $blue_y, $radius, $radius, $blue); // 올바른 header를 출력하지 마세요! header('Content-type: image/png'); // 마지막 출력 결과 imagepng($image); imagedestroy($image); ?>
위 예제의 출력 결과 이미지는 다음과 같습니다:
imagecolorallocate() 이미지에 색상을 할당하세요。
imagecolordeallocate() 이미지의 색상 할당을 취소하세요。