reference/image/functions/imagecolorallocatealpha.xml
9960a09a5705102bf4dd0ce63e03d9ec716d0015
9960a09a5705102bf4dd0ce63e03d9ec716d0015
...
...
@@ -8,8 +8,8 @@
8
8
<refsect1 role="description">
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
-
<type>int</type><methodname>imagecolorallocatealpha</methodname>
12
-
<methodparam><type>resource</type><parameter>image</parameter></methodparam>
11
+
<type class="union"><type>int</type><type>false</type></type><methodname>imagecolorallocatealpha</methodname>
12
+
<methodparam><type>GdImage</type><parameter>image</parameter></methodparam>
13
13
<methodparam><type>int</type><parameter>red</parameter></methodparam>
14
14
<methodparam><type>int</type><parameter>green</parameter></methodparam>
15
15
<methodparam><type>int</type><parameter>blue</parameter></methodparam>
...
...
@@ -55,8 +55,9 @@
55
55
</listitem>
56
56
</varlistentry>
57
57
</variablelist>
58
-
The colors parameters are integers between 0 and 255 or hexadecimals
59
-
between 0x00 and 0xFF.
58
+
The <parameter>red</parameter>, <parameter>green</parameter>
59
+
and <parameter>blue</parameter> parameters are integers
60
+
between 0 and 255 or hexadecimals between 0x00 and 0xFF.
60
61
</para>
61
62
</refsect1>
62
63
<refsect1 role="returnvalues">
...
...
@@ -66,35 +67,29 @@
66
67
</para>
67
68
&return.falseproblem;
68
69
</refsect1>
70
+
69
71
<refsect1 role="changelog">
70
72
&reftitle.changelog;
71
-
<para>
72
-
<informaltable>
73
-
<tgroup cols="2">
74
-
<thead>
75
-
<row>
76
-
<entry>&Version;</entry>
77
-
<entry>&Description;</entry>
78
-
</row>
79
-
</thead>
80
-
<tbody>
81
-
<row>
82
-
<entry>Prior to 5.1.3</entry>
83
-
<entry>
84
-
Returns -1 if the allocation failed.
85
-
</entry>
86
-
</row>
87
-
</tbody>
88
-
</tgroup>
89
-
</informaltable>
90
-
</para>
73
+
<informaltable>
74
+
<tgroup cols="2">
75
+
<thead>
76
+
<row>
77
+
<entry>&Version;</entry>
78
+
<entry>&Description;</entry>
79
+
</row>
80
+
</thead>
81
+
<tbody>
82
+
&gd.changelog.image-param;
83
+
</tbody>
84
+
</tgroup>
85
+
</informaltable>
91
86
</refsect1>
87
+
92
88
<refsect1 role="examples">
93
89
&reftitle.examples;
94
-
<para>
95
-
<example>
96
-
<title>Example of using <function>imagecolorallocatealpha</function></title>
97
-
<programlisting role="php">
90
+
<example>
91
+
<title>Example of using <function>imagecolorallocatealpha</function></title>
92
+
<programlisting role="php">
98
93
<![CDATA[
99
94
<?php
100
95
$size = 300;
...
...
@@ -129,35 +124,53 @@ header('Content-Type: image/png');
129
124
130
125
// and finally, output the result
131
126
imagepng($image);
132
-
imagedestroy($image);
133
127
?>
134
128
]]>
135
-
</programlisting>
136
-
&example.outputs.similar;
137
-
<mediaobject>
138
-
<alt>Output of example : Example of using imagecolorallocatealpha()</alt>
139
-
<imageobject>
140
-
<imagedata fileref="en/reference/image/figures/imagecolorallocatealpha.png"/>
141
-
</imageobject>
142
-
</mediaobject>
143
-
</example>
144
-
</para>
145
-
</refsect1>
146
-
<refsect1 role="notes">
147
-
&reftitle.notes;
148
-
¬e.gd.2;
129
+
</programlisting>
130
+
&example.outputs.similar;
131
+
<mediaobject>
132
+
<alt>Output of example : Example of using imagecolorallocatealpha()</alt>
133
+
<imageobject>
134
+
<imagedata fileref="en/reference/image/figures/imagecolorallocatealpha.png"/>
135
+
</imageobject>
136
+
</mediaobject>
137
+
</example>
138
+
<example xml:id="imagecolorallocatealpha.example.convert">
139
+
<title>Convert typical alpha values for use with <function>imagecolorallocatealpha</function></title>
140
+
<para>
141
+
Usually alpha values of <literal>0</literal> designate fully transparent pixels,
142
+
and the alpha channel has 8 bits. To convert such alpha values to be compatible
143
+
with <function>imagecolorallocatealpha</function>, some simple arithmetic is
144
+
sufficient:
145
+
</para>
146
+
<programlisting role="php">
147
+
<![CDATA[
148
+
<?php
149
+
$alpha8 = 0; // fully transparent
150
+
var_dump(127 - ($alpha8 >> 1));
151
+
$alpha8 = 255; // fully opaque
152
+
var_dump(127 - ($alpha8 >> 1));
153
+
?>
154
+
]]>
155
+
</programlisting>
156
+
&example.outputs;
157
+
<screen>
158
+
<![CDATA[
159
+
int(127)
160
+
int(0)
161
+
]]>
162
+
</screen>
163
+
</example>
149
164
</refsect1>
165
+
150
166
<refsect1 role="seealso">
151
167
&reftitle.seealso;
152
-
<para>
153
-
<simplelist>
154
-
<member><function>imagecolorallocate</function></member>
155
-
<member><function>imagecolordeallocate</function></member>
156
-
</simplelist>
157
-
</para>
168
+
<simplelist>
169
+
<member><function>imagecolorallocate</function></member>
170
+
<member><function>imagecolordeallocate</function></member>
171
+
</simplelist>
158
172
</refsect1>
159
173
</refentry>
160
-
161
174
<!-- Keep this comment at the end of the file
162
175
Local variables:
163
176
mode: sgml
164
177