<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >imagecolorallocate</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual PHP" 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-2"></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" >Manual PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.imagecharup.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.imagecolorallocatealpha.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.imagecolorallocate" ></A >imagecolorallocate</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN38674" ></A ><P > (PHP 3, PHP 4 , PHP 5)</P >imagecolorallocate -- Allocate a color for an image</DIV ><DIV CLASS="refsect1" ><A NAME="AEN38677" ></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 <ACRONYM CLASS="acronym" >RGB</ACRONYM > components. The <VAR CLASS="parameter" >image</VAR > argument is the return from the <A HREF="function.imagecreate.html" ><B CLASS="function" >imagecreate()</B ></A > function. <VAR CLASS="parameter" >red</VAR >, <VAR CLASS="parameter" >green</VAR > and <VAR CLASS="parameter" >blue</VAR > are the values of the red, green and blue component of the requested color respectively. These parameters are integers between 0 and 255 or hexadecimals between 0x00 and 0xFF. <B CLASS="function" >imagecolorallocate()</B > must be called to create each color that is to be used in the image represented by <VAR CLASS="parameter" >image</VAR >. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Notã: </B > The first call to <B CLASS="function" >imagecolorallocate()</B > fills the background color. </P ></BLOCKQUOTE ></DIV ><P > <DIV CLASS="informalexample" ><P ></P ><A NAME="AEN38708" ></A ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br /></font><font color="#FF8000">// sets background to red<br /></font><font color="#0000BB">$background </font><font color="#007700">= </font><font color="#0000BB">imagecolorallocate</font><font color="#007700">(</font><font color="#0000BB">$im</font><font color="#007700">, </font><font color="#0000BB">255</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// sets some colors<br /></font><font color="#0000BB">$white </font><font color="#007700">= </font><font color="#0000BB">imagecolorallocate</font><font color="#007700">(</font><font color="#0000BB">$im</font><font color="#007700">, </font><font color="#0000BB">255</font><font color="#007700">, </font><font color="#0000BB">255</font><font color="#007700">, </font><font color="#0000BB">255</font><font color="#007700">);<br /></font><font color="#0000BB">$black </font><font color="#007700">= </font><font color="#0000BB">imagecolorallocate</font><font color="#007700">(</font><font color="#0000BB">$im</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#0000BB">0</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// hexadecimal way<br /></font><font color="#0000BB">$white </font><font color="#007700">= </font><font color="#0000BB">imagecolorallocate</font><font color="#007700">(</font><font color="#0000BB">$im</font><font color="#007700">, </font><font color="#0000BB">0xFF</font><font color="#007700">, </font><font color="#0000BB">0xFF</font><font color="#007700">, </font><font color="#0000BB">0xFF</font><font color="#007700">);<br /></font><font color="#0000BB">$black </font><font color="#007700">= </font><font color="#0000BB">imagecolorallocate</font><font color="#007700">(</font><font color="#0000BB">$im</font><font color="#007700">, </font><font color="#0000BB">0x00</font><font color="#007700">, </font><font color="#0000BB">0x00</font><font color="#007700">, </font><font color="#0000BB">0x00</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P ></P ></DIV > </P ><P > Returns -1 if the allocation failed. </P ><P > See also <A HREF="function.imagecolorallocatealpha.html" ><B CLASS="function" >imagecolorallocatealpha()</B ></A > and <A HREF="function.imagecolordeallocate.html" ><B CLASS="function" >imagecolordeallocate()</B ></A >. </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" >Înapoi</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Acasã</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.imagecolorallocatealpha.html" ACCESSKEY="N" >Înainte</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" >Sus</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >imagecolorallocatealpha</TD ></TR ></TABLE ></DIV ></BODY ></HTML >