📄 function.imagecolormatch.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Makes the colors of the palette version of an image more closely match the true color version</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagecolorexactalpha.html">imagecolorexactalpha</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagecolorresolve.html">imagecolorresolve</a></div> <div class="up"><a href="ref.image.html">GD Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.imagecolormatch" class="refentry"> <div class="refnamediv"> <h1 class="refname">imagecolormatch</h1> <p class="verinfo">(PHP 4 >= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">imagecolormatch</span> — <span class="dc-title">Makes the colors of the palette version of an image more closely match the true color version</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>imagecolormatch</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$image1</tt></span> , <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$image2</tt></span> )</div> <p class="para rdfs-comment"> Makes the colors of the palette version of an image more closely match the true color version. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">image1</tt></i></span> <dd> <p class="para"> A truecolor image link resource. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">image2</tt></i></span> <dd> <p class="para"> A palette image link resource pointing to an image that has the same size as <i><tt class="parameter">image1</tt></i>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <div class="example"> <p><b>Example #1 <b>imagecolormatch()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Setup the true color and palette images<br /></span><span style="color: #0000BB">$im1 </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatefrompng</span><span style="color: #007700">(</span><span style="color: #DD0000">'./gdlogo.png'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$im2 </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreate</span><span style="color: #007700">(</span><span style="color: #0000BB">imagesx</span><span style="color: #007700">(</span><span style="color: #0000BB">$im1</span><span style="color: #007700">), </span><span style="color: #0000BB">imagesy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im1</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Add some colors to $im2<br /></span><span style="color: #0000BB">$colors </span><span style="color: #007700">= Array();<br /></span><span style="color: #0000BB">$colors</span><span style="color: #007700">[] = </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">36</span><span style="color: #007700">, </span><span style="color: #0000BB">74</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$colors</span><span style="color: #007700">[] = </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">, </span><span style="color: #0000BB">40</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">240</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$colors</span><span style="color: #007700">[] = </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">, </span><span style="color: #0000BB">82</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$colors</span><span style="color: #007700">[] = </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">, </span><span style="color: #0000BB">84</span><span style="color: #007700">, </span><span style="color: #0000BB">63</span><span style="color: #007700">, </span><span style="color: #0000BB">44</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Match these colors with the true color image<br /></span><span style="color: #0000BB">imagecolormatch</span><span style="color: #007700">(</span><span style="color: #0000BB">$im1</span><span style="color: #007700">, </span><span style="color: #0000BB">$im2</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Free from memory<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <blockquote><p><b class="note">Note</b>: <span class="simpara">This function is only available ifPHP is compiled with the bundled version of the GD library.</span></p></blockquote> <blockquote><p><b class="note">Note</b>: <span class="simpara">This function requires GD 2.0.1 or later (2.0.28 or later is recommended).</span></p></blockquote> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.imagecreatetruecolor.html" class="function" rel="rdfs-seeAlso">imagecreatetruecolor()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagecolorexactalpha.html">imagecolorexactalpha</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagecolorresolve.html">imagecolorresolve</a></div> <div class="up"><a href="ref.image.html">GD Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -