Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> PHP

PHP में imagecolorallocate() फंक्शन

imagecolorallocate() फंक्शन इमेज के लिए रंग आवंटित करता है।

सिंटैक्स

int imagecolorallocate ( $img, $red, $green, $blue )

पैरामीटर्स

  • img: imagecreatetruecolor() के साथ बनाया गया इमेज रिसोर्स।

  • red: लाल रंग घटक

  • green: हरा रंग घटक

  • blue: नीला रंग घटक

रिटर्न

imagecolorallocate() फंक्शन RGB फॉर्मेट में रंग लौटाता है।

उदाहरण

निम्नलिखित एक उदाहरण है:

<?php 
    $img = imagecreatetruecolor(600, 220); 
    $bgcolor = imagecolorallocate($img, 20, 50, 120); 
    imagefill($img, 0, 0, $bgcolor); 
    header("Content-type: image/png"); 
    imagepng($img); 
    imagedestroy($img); 
?>

आउटपुट

निम्नलिखित आउटपुट है:

PHP में imagecolorallocate() फंक्शन

  1. PHP में imagefill() फंक्शन PHP में imagefill() फंक्शन

    PHP में imagefill() फंक्शन छवि में निर्दिष्ट प्रारंभिक बिंदु से फ्लड फिल (flood fill) ऑपरेशन करता है - अर्थात्, यह मिलते-जुलते रंग वाले सभी जुड़े हुए क्षेत्र को निर्दिष्ट रंग से भर देता है। सिंटैक्स (Syntax) imagefill(GdImage $image, int $x, int $y, int $color): bool पैरामीटर्स (Parameters) $ima

  1. PHP में imagefilledrectangle() फंक्शन PHP में imagefilledrectangle() फंक्शन

    PHP में imagefilledrectangle() फंक्शन छवि पर एक भरा हुआ आयत (filled rectangle) खींचता है। यह निर्दिष्ट दो कोनों के बीच के पूरे आयताकार क्षेत्र को रंग से भर देता है। सिंटैक्स (Syntax) imagefilledrectangle(GdImage $image, int $x1, int $y1, int $x2, int $y2, int $color): bool पैरामीटर्स (Parameters)

  1. PHP में imagefilledellipse() फंक्शन PHP में imagefilledellipse() फंक्शन

    PHP में imagefilledellipse() फंक्शन छवि पर एक भरा हुआ अंडाकार (filled ellipse) खींचता है। केंद्र निर्देशांक, चौड़ाई और ऊंचाई निर्दिष्ट करके अंडाकार बनाया जाता है। सिंटैक्स (Syntax) imagefilledellipse(GdImage $image, int $cx, int $cy, int $width, int $height, int $color): bool पैरामीटर्स (Paramete