<refentry id="gdk-pixbuf-xlib-rendering" revision="27 Aug 2000">
<refmeta>
<refentrytitle>Xlib Rendering</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GDK-PIXBUF Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Xlib Rendering</refname><refpurpose>Rendering a pixbuf to an X drawable.</refpurpose>
</refnamediv>

<refsynopsisdiv><title>Synopsis</title>
<synopsis>

#include &lt;gdk-pixbuf/gdk-pixbuf.h&gt;


void        <link linkend="gdk-pixbuf-xlib-render-threshold-alpha">gdk_pixbuf_xlib_render_threshold_alpha</link>
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                             <link linkend="Pixmap">Pixmap</link> bitmap,
                                             int src_x,
                                             int src_y,
                                             int dest_x,
                                             int dest_y,
                                             int width,
                                             int height,
                                             int alpha_threshold);
void        <link linkend="gdk-pixbuf-xlib-render-to-drawable">gdk_pixbuf_xlib_render_to_drawable</link>
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                             <link linkend="Drawable">Drawable</link> drawable,
                                             <link linkend="GC">GC</link> gc,
                                             int src_x,
                                             int src_y,
                                             int dest_x,
                                             int dest_y,
                                             int width,
                                             int height,
                                             <link linkend="XlibRgbDither">XlibRgbDither</link> dither,
                                             int x_dither,
                                             int y_dither);
void        <link linkend="gdk-pixbuf-xlib-render-to-drawable-alpha">gdk_pixbuf_xlib_render_to_drawable_alpha</link>
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                             <link linkend="Drawable">Drawable</link> drawable,
                                             int src_x,
                                             int src_y,
                                             int dest_x,
                                             int dest_y,
                                             int width,
                                             int height,
                                             <link linkend="GdkPixbufAlphaMode">GdkPixbufAlphaMode</link> alpha_mode,
                                             int alpha_threshold,
                                             <link linkend="XlibRgbDither">XlibRgbDither</link> dither,
                                             int x_dither,
                                             int y_dither);
void        <link linkend="gdk-pixbuf-xlib-render-pixmap-and-mask">gdk_pixbuf_xlib_render_pixmap_and_mask</link>
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                             <link linkend="Pixmap">Pixmap</link> *pixmap_return,
                                             <link linkend="Pixmap">Pixmap</link> *mask_return,
                                             int alpha_threshold);
</synopsis>
</refsynopsisdiv>





<refsect1>
<title>Description</title>
  <para>
    The &gdk-pixbuf; Xlib library provides several convenience
    functions to render pixbufs to X drawables.  It uses XlibRGB to
    render the image data.
  </para>

  <para>
    These functions are analogous to those for the Gdk version of
    &gdk-pixbuf;.
  </para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="gdk-pixbuf-xlib-render-threshold-alpha">gdk_pixbuf_xlib_render_threshold_alpha ()</title>
<programlisting>void        gdk_pixbuf_xlib_render_threshold_alpha
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                             <link linkend="Pixmap">Pixmap</link> bitmap,
                                             int src_x,
                                             int src_y,
                                             int dest_x,
                                             int dest_y,
                                             int width,
                                             int height,
                                             int alpha_threshold);</programlisting>
<para>
Takes the opacity values in a rectangular portion of a pixbuf and thresholds
them to produce a bi-level alpha mask that can be used as a clipping mask for
a drawable.</para>
<para>

</para><informaltable pgwide=1 frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>pixbuf</parameter>&nbsp;:</entry>
<entry> A pixbuf.
</entry></row>
<row><entry align="right"><parameter>bitmap</parameter>&nbsp;:</entry>
<entry> Bitmap where the bilevel mask will be painted to.
</entry></row>
<row><entry align="right"><parameter>src_x</parameter>&nbsp;:</entry>
<entry> Source X coordinate.
</entry></row>
<row><entry align="right"><parameter>src_y</parameter>&nbsp;:</entry>
<entry> source Y coordinate.
</entry></row>
<row><entry align="right"><parameter>dest_x</parameter>&nbsp;:</entry>
<entry> Destination X coordinate.
</entry></row>
<row><entry align="right"><parameter>dest_y</parameter>&nbsp;:</entry>
<entry> Destination Y coordinate.
</entry></row>
<row><entry align="right"><parameter>width</parameter>&nbsp;:</entry>
<entry> Width of region to threshold.
</entry></row>
<row><entry align="right"><parameter>height</parameter>&nbsp;:</entry>
<entry> Height of region to threshold.
</entry></row>
<row><entry align="right"><parameter>alpha_threshold</parameter>&nbsp;:</entry>
<entry> Opacity values below this will be painted as zero; all
other values will be painted as one.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-pixbuf-xlib-render-to-drawable">gdk_pixbuf_xlib_render_to_drawable ()</title>
<programlisting>void        gdk_pixbuf_xlib_render_to_drawable
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                             <link linkend="Drawable">Drawable</link> drawable,
                                             <link linkend="GC">GC</link> gc,
                                             int src_x,
                                             int src_y,
                                             int dest_x,
                                             int dest_y,
                                             int width,
                                             int height,
                                             <link linkend="XlibRgbDither">XlibRgbDither</link> dither,
                                             int x_dither,
                                             int y_dither);</programlisting>
<para>
Renders a rectangular portion of a pixbuf to a drawable while using the
specified GC.  This is done using XlibRGB, so the specified drawable must
have the XlibRGB visual and colormap.  Note that this function will ignore
the opacity information for images with an alpha channel; the GC must already
have the clipping mask set if you want transparent regions to show through.
</para>
<para>
For an explanation of dither offsets, see the XlibRGB documentation.  In
brief, the dither offset is important when re-rendering partial regions of an
image to a rendered version of the full image, or for when the offsets to a
base position change, as in scrolling.  The dither matrix has to be shifted
for consistent visual results.  If you do not have any of these cases, the
dither offsets can be both zero.</para>
<para>

</para><informaltable pgwide=1 frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>pixbuf</parameter>&nbsp;:</entry>
<entry> A pixbuf.
</entry></row>
<row><entry align="right"><parameter>drawable</parameter>&nbsp;:</entry>
<entry> Destination drawable.
</entry></row>
<row><entry align="right"><parameter>gc</parameter>&nbsp;:</entry>
<entry> GC used for rendering.
</entry></row>
<row><entry align="right"><parameter>src_x</parameter>&nbsp;:</entry>
<entry> Source X coordinate within pixbuf.
</entry></row>
<row><entry align="right"><parameter>src_y</parameter>&nbsp;:</entry>
<entry> Source Y coordinate within pixbuf.
</entry></row>
<row><entry align="right"><parameter>dest_x</parameter>&nbsp;:</entry>
<entry> Destination X coordinate within drawable.
</entry></row>
<row><entry align="right"><parameter>dest_y</parameter>&nbsp;:</entry>
<entry> Destination Y coordinate within drawable.
</entry></row>
<row><entry align="right"><parameter>width</parameter>&nbsp;:</entry>
<entry> Width of region to render, in pixels.
</entry></row>
<row><entry align="right"><parameter>height</parameter>&nbsp;:</entry>
<entry> Height of region to render, in pixels.
</entry></row>
<row><entry align="right"><parameter>dither</parameter>&nbsp;:</entry>
<entry> Dithering mode for XlibRGB.
</entry></row>
<row><entry align="right"><parameter>x_dither</parameter>&nbsp;:</entry>
<entry> X offset for dither.
</entry></row>
<row><entry align="right"><parameter>y_dither</parameter>&nbsp;:</entry>
<entry> Y offset for dither.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-pixbuf-xlib-render-to-drawable-alpha">gdk_pixbuf_xlib_render_to_drawable_alpha ()</title>
<programlisting>void        gdk_pixbuf_xlib_render_to_drawable_alpha
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                             <link linkend="Drawable">Drawable</link> drawable,
                                             int src_x,
                                             int src_y,
                                             int dest_x,
                                             int dest_y,
                                             int width,
                                             int height,
                                             <link linkend="GdkPixbufAlphaMode">GdkPixbufAlphaMode</link> alpha_mode,
                                             int alpha_threshold,
                                             <link linkend="XlibRgbDither">XlibRgbDither</link> dither,
                                             int x_dither,
                                             int y_dither);</programlisting>
<para>
Renders a rectangular portion of a pixbuf to a drawable.  This is done using
XlibRGB, so the specified drawable must have the XlibRGB visual and colormap.
</para>
<para>
When used with <link linkend="GDK-PIXBUF-ALPHA-BILEVEL">GDK_PIXBUF_ALPHA_BILEVEL</link>, this function has to create a bitmap
out of the thresholded alpha channel of the image and, it has to set this
bitmap as the clipping mask for the GC used for drawing.  This can be a
significant performance penalty depending on the size and the complexity of
the alpha channel of the image.  If performance is crucial, consider handling
the alpha channel yourself (possibly by caching it in your application) and
using <link linkend="gdk-pixbuf-xlib-render-to-drawable">gdk_pixbuf_xlib_render_to_drawable</link>() or GdkRGB directly instead.</para>
<para>

</para><informaltable pgwide=1 frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>pixbuf</parameter>&nbsp;:</entry>
<entry> A pixbuf.
</entry></row>
<row><entry align="right"><parameter>drawable</parameter>&nbsp;:</entry>
<entry> Destination drawable.
</entry></row>
<row><entry align="right"><parameter>src_x</parameter>&nbsp;:</entry>
<entry> Source X coordinate within pixbuf.
</entry></row>
<row><entry align="right"><parameter>src_y</parameter>&nbsp;:</entry>
<entry> Source Y coordinates within pixbuf.
</entry></row>
<row><entry align="right"><parameter>dest_x</parameter>&nbsp;:</entry>
<entry> Destination X coordinate within drawable.
</entry></row>
<row><entry align="right"><parameter>dest_y</parameter>&nbsp;:</entry>
<entry> Destination Y coordinate within drawable.
</entry></row>
<row><entry align="right"><parameter>width</parameter>&nbsp;:</entry>
<entry> Width of region to render, in pixels.
</entry></row>
<row><entry align="right"><parameter>height</parameter>&nbsp;:</entry>
<entry> Height of region to render, in pixels.
</entry></row>
<row><entry align="right"><parameter>alpha_mode</parameter>&nbsp;:</entry>
<entry> If the image does not have opacity information, this is ignored.
Otherwise, specifies how to handle transparency when rendering.
</entry></row>
<row><entry align="right"><parameter>alpha_threshold</parameter>&nbsp;:</entry>
<entry> If the image does have opacity information and <parameter>alpha_mode</parameter>
is GDK_PIXBUF_ALPHA_BILEVEL, specifies the threshold value for opacity
values.
</entry></row>
<row><entry align="right"><parameter>dither</parameter>&nbsp;:</entry>
<entry> Dithering mode for XlibRGB.
</entry></row>
<row><entry align="right"><parameter>x_dither</parameter>&nbsp;:</entry>
<entry> X offset for dither.
</entry></row>
<row><entry align="right"><parameter>y_dither</parameter>&nbsp;:</entry>
<entry> Y offset for dither.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-pixbuf-xlib-render-pixmap-and-mask">gdk_pixbuf_xlib_render_pixmap_and_mask ()</title>
<programlisting>void        gdk_pixbuf_xlib_render_pixmap_and_mask
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                             <link linkend="Pixmap">Pixmap</link> *pixmap_return,
                                             <link linkend="Pixmap">Pixmap</link> *mask_return,
                                             int alpha_threshold);</programlisting>
<para>
Creates a pixmap and a mask bitmap which are returned in the <parameter>pixmap_return</parameter>
and <parameter>mask_return</parameter> arguments, respectively, and renders a pixbuf and its
corresponding tresholded alpha mask to them.  This is merely a convenience
function; applications that need to render pixbufs with dither offsets or to
given drawables should use <link linkend="gdk-pixbuf-xlib-render-to-drawable-alpha">gdk_pixbuf_xlib_render_to_drawable_alpha</link>() or
<link linkend="gdk-pixbuf-xlib-render-to-drawable">gdk_pixbuf_xlib_render_to_drawable</link>(), and
<link linkend="gdk-pixbuf-xlib-render-threshold-alpha">gdk_pixbuf_xlib_render_threshold_alpha</link>().
</para>
<para>
If the pixbuf does not have an alpha channel, then *<parameter>mask_return</parameter> will be set
to None.</para>
<para>

</para><informaltable pgwide=1 frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>pixbuf</parameter>&nbsp;:</entry>
<entry> A pixbuf.
</entry></row>
<row><entry align="right"><parameter>pixmap_return</parameter>&nbsp;:</entry>
<entry> Return value for the created pixmap.
</entry></row>
<row><entry align="right"><parameter>mask_return</parameter>&nbsp;:</entry>
<entry> Return value for the created mask.
</entry></row>
<row><entry align="right"><parameter>alpha_threshold</parameter>&nbsp;:</entry>
<entry> Threshold value for opacity values.
</entry></row>
</tbody></tgroup></informaltable></refsect2>

</refsect1>




</refentry>
