svn: /phpdoc/ja/trunk/reference/image/functions/ imagecolorallocatealpha.xml
| From: | Yoshinari Takaoka | Date: | Mon, 23 Dec 2019 10:26:41 +0000 |
| Subject: | svn: /phpdoc/ja/trunk/reference/image/functions/ imagecolorallocatealpha.xml | ||
| Groups: | php.doc.ja | ||
| Request: | Send a blank email to doc-ja+get-5236@lists.php.net to get a copy of this message | ||
mumumu Mon, 23 Dec 2019 10:26:41 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=348670
Log:
Add example for conversion of typical alpha values
This integrates user note 103146, 106642 and 124527.
Changed paths:
U phpdoc/ja/trunk/reference/image/functions/imagecolorallocatealpha.xml
Modified: phpdoc/ja/trunk/reference/image/functions/imagecolorallocatealpha.xml
===================================================================
--- phpdoc/ja/trunk/reference/image/functions/imagecolorallocatealpha.xml 2019-12-23 08:09:43 UTC
(rev 348669)
+++ phpdoc/ja/trunk/reference/image/functions/imagecolorallocatealpha.xml 2019-12-23 10:26:41 UTC
(rev 348670)
@@ -97,10 +97,9 @@
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
- <para>
- <example>
- <title><function>imagecolorallocatealpha</function>
の使用例</title>
- <programlisting role="php">
+ <example>
+ <title><function>imagecolorallocatealpha</function> の使用例</title>
+ <programlisting role="php">
<![CDATA[
<?php
$size = 300;
@@ -138,16 +137,41 @@
imagedestroy($image);
?>
]]>
- </programlisting>
- &example.outputs.similar;
- <mediaobject>
- <alt>出力例 : imagecolorallocatealpha()</alt>
- <imageobject>
- <imagedata fileref="en/reference/image/figures/imagecolorallocatealpha.png"/>
- </imageobject>
- </mediaobject>
- </example>
- </para>
+ </programlisting>
+ &example.outputs.similar;
+ <mediaobject>
+ <alt>出力例 : imagecolorallocatealpha 関数の使用例</alt>
+ <imageobject>
+ <imagedata fileref="en/reference/image/figures/imagecolorallocatealpha.png"/>
+ </imageobject>
+ </mediaobject>
+ </example>
+ <example xml:id="imagecolorallocatealpha.example.convert">
+ <title><function>imagecolorallocatealpha</function>
関数を使い、典型的なアルファ値を変換する</title>
+ <para>
+ アルファの値を <literal>0</literal>
にすると、通常は完全に透過なピクセルが指定されますし、
+ アルファチャネルは 8bit です。このようなアルファ値を
+ <function>imagecolorallocatealpha</function>
関数と互換性がある値に変換するには、
+ いくつか簡単な計算をすれば十分です:
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$alpha8 = 0; // 完全に透過
+var_dump(127 - ($alpha8 >> 1));
+$alpha8 = 255; // 完全に不透明
+var_dump(127 - ($alpha8 >> 1));
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+int(127)
+int(0)
+]]>
+ </screen>
+ </example>
</refsect1>
<refsect1 role="seealso">