이미지 처리 및 GD imagefilltoborder

(PHP 4, PHP 5, PHP 7, PHP 8)

imagefilltoborder — 특정 색상으로 채우기


설명

imagefilltoborder(
    GdImage $image,
    int $x,
    int $y,
    int $border_color,
    int $color
): bool
                

imagefilltoborder()는 테두리 색상이 border_color로 정의된 홍수 채우기를 수행합니다. 채우기의 시작점은 x, y(왼쪽 상단은 0, 0)이고 영역은 색상 color으로 채워집니다.


매개변수

image
imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
x
시작의 x 좌표.
y
시작의 y 좌표.
border_color
테두리 색상입니다. imagecolorallocate()로 생성된 색상 식별자입니다.
color
채우기 색상입니다. imagecolorallocate()로 생성된 색상 식별자입니다.

반환 값

성공하면 true를, 실패하면 false를 반환합니다.


변경 로그

버전 설명
8.0.0 image는 이제 GdImage 인스턴스를 예상합니다. 이전에는 리소스가 필요했습니다.

Examples

예제 #1 타원에 색 채우기

                  
<?php
// Create the image handle, set the background to white
$im = imagecreatetruecolor(100, 100);
imagefilledrectangle($im, 0, 0, 100, 100, imagecolorallocate($im, 255, 255, 255));

// Draw an ellipse to fill with a black border
imageellipse($im, 50, 50, 50, 50, imagecolorallocate($im, 0, 0, 0));

// Set the border and fill colors
$border = imagecolorallocate($im, 0, 0, 0);
$fill = imagecolorallocate($im, 255, 0, 0);

// Fill the selection
imagefilltoborder($im, 50, 50, $border, $fill);

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

function imagefilltoborder


메모

알고리즘은 이미 설정된 픽셀을 명시적으로 기억하지 않고 오히려 픽셀의 색상에서 이를 유추하므로 새로 설정된 픽셀과 이미 있는 픽셀을 구별할 수 없습니다. 즉, 이미 이미지에 사용된 채우기 색상을 선택하면 원하지 않는 결과가 발생할 수 있습니다.