reference/image/functions/imagecolorallocatealpha.xml
593ea510e853ff034e03f78a4be0daa41661c9d4
...
...
@@ -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>
...
...
@@ -67,36 +67,29 @@
67
67
</para>
68
68
&return.falseproblem;
69
69
</refsect1>
70
+

70
71
<refsect1 role="changelog">
71
72
&reftitle.changelog;
72
-
<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
-
<row>
83
-
<entry>5.1.3</entry>
84
-
<entry>
85
-
Returns &false; if the allocation failed. Previously
86
-
<literal>-1</literal> was returned.
87
-
</entry>
88
-
</row>
89
-
</tbody>
90
-
</tgroup>
91
-
</informaltable>
92
-
</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>
93
86
</refsect1>
87
+

94
88
<refsect1 role="examples">
95
89
&reftitle.examples;
96
-
<para>
97
-
<example>
98
-
<title>Example of using <function>imagecolorallocatealpha</function></title>
99
-
<programlisting role="php">
90
+
<example>
91
+
<title>Example of using <function>imagecolorallocatealpha</function></title>
92
+
<programlisting role="php">
100
93
<![CDATA[
101
94
<?php
102
95
$size = 300;
...
...
@@ -134,29 +127,51 @@ imagepng($image);
134
127
imagedestroy($image);
135
128
?>
136
129
]]>
137
-
</programlisting>
138
-
&example.outputs.similar;
139
-
<mediaobject>
140
-
<alt>Output of example : Example of using imagecolorallocatealpha()</alt>
141
-
<imageobject>
142
-
<imagedata fileref="en/reference/image/figures/imagecolorallocatealpha.png"/>
143
-
</imageobject>
144
-
</mediaobject>
145
-
</example>
146
-
</para>
130
+
</programlisting>
131
+
&example.outputs.similar;
132
+
<mediaobject>
133
+
<alt>Output of example : Example of using imagecolorallocatealpha()</alt>
134
+
<imageobject>
135
+
<imagedata fileref="en/reference/image/figures/imagecolorallocatealpha.png"/>
136
+
</imageobject>
137
+
</mediaobject>
138
+
</example>
139
+
<example xml:id="imagecolorallocatealpha.example.convert">
140
+
<title>Convert typical alpha values for use with <function>imagecolorallocatealpha</function></title>
141
+
<para>
142
+
Usually alpha values of <literal>0</literal> designate fully transparent pixels,
143
+
and the alpha channel has 8 bits. To convert such alpha values to be compatible
144
+
with <function>imagecolorallocatealpha</function>, some simple arithmetic is
145
+
sufficient:
146
+
</para>
147
+
<programlisting role="php">
148
+
<![CDATA[
149
+
<?php
150
+
$alpha8 = 0; // fully transparent
151
+
var_dump(127 - ($alpha8 >> 1));
152
+
$alpha8 = 255; // fully opaque
153
+
var_dump(127 - ($alpha8 >> 1));
154
+
?>
155
+
]]>
156
+
</programlisting>
157
+
&example.outputs;
158
+
<screen>
159
+
<![CDATA[
160
+
int(127)
161
+
int(0)
162
+
]]>
163
+
</screen>
164
+
</example>
147
165
</refsect1>
148
166

149
167
<refsect1 role="seealso">
150
168
&reftitle.seealso;
151
-
<para>
152
-
<simplelist>
153
-
<member><function>imagecolorallocate</function></member>
154
-
<member><function>imagecolordeallocate</function></member>
155
-
</simplelist>
156
-
</para>
169
+
<simplelist>
170
+
<member><function>imagecolorallocate</function></member>
171
+
<member><function>imagecolordeallocate</function></member>
172
+
</simplelist>
157
173
</refsect1>
158
174
</refentry>
159
-

160
175
<!-- Keep this comment at the end of the file
161
176
Local variables:
162
177
mode: sgml
163
178