<HTML ><HEAD ><TITLE >imagecolorallocate</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Image functions" HREF="ref.image.html"><LINK REL="PREVIOUS" TITLE="imagecharup" HREF="function.imagecharup.html"><LINK REL="NEXT" TITLE="imagecolorallocatealpha" HREF="function.imagecolorallocatealpha.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.imagecharup.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.imagecolorallocatealpha.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.imagecolorallocate" ></A >imagecolorallocate</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN34450" ></A ><P > (PHP 3, PHP 4 )</P >imagecolorallocate -- Allocate a color for an image</DIV ><DIV CLASS="refsect1" ><A NAME="AEN34453" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >imagecolorallocate</B > ( resource image, int red, int green, int blue)<BR ></BR ><P > <B CLASS="function" >imagecolorallocate()</B > returns a color identifier representing the color composed of the given <SPAN CLASS="acronym" >RGB</SPAN > components. The <TT CLASS="parameter" ><I >im</I ></TT > argument is the return from the <A HREF="function.imagecreate.html" ><B CLASS="function" >imagecreate()</B ></A > function. <TT CLASS="parameter" ><I >red</I ></TT >, <TT CLASS="parameter" ><I >green</I ></TT > and <TT CLASS="parameter" ><I >blue</I ></TT > are the values of the red, green and blue component of the requested color respectively. These parameters are integers between 0 and 255. <B CLASS="function" >imagecolorallocate()</B > must be called to create each color that is to be used in the image represented by <TT CLASS="parameter" ><I >image</I ></TT >. <DIV CLASS="informalexample" ><A NAME="AEN34480" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" >$white = imagecolorallocate ($im, 255, 255, 255); $black = imagecolorallocate ($im, 0, 0, 0);</PRE ></TD ></TR ></TABLE ><P ></P ></DIV > </P ><P > Returns -1 if the allocation failed. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.imagecharup.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.imagecolorallocatealpha.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >imagecharup</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.image.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >imagecolorallocatealpha</TD ></TR ></TABLE ></DIV ></BODY ></HTML >