<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">

<!ENTITY gdk-pixbuf "<application>gdk-pixbuf</application>">
<!ENTITY Imlib "<application>Imlib</application>">
]>
<refentry id="gdk-pixbuf-gdk-pixbuf-xlib-rendering">
<refmeta>
<refentrytitle role="top_of_page" id="gdk-pixbuf-gdk-pixbuf-xlib-rendering.top_of_page">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 id="gdk-pixbuf-gdk-pixbuf-xlib-rendering.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

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

<link linkend="void">void</link>                <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,
                                                         <link linkend="int">int</link> src_x,
                                                         <link linkend="int">int</link> src_y,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> width,
                                                         <link linkend="int">int</link> height,
                                                         <link linkend="int">int</link> alpha_threshold);
<link linkend="void">void</link>                <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--CAPS">GC</link> gc,
                                                         <link linkend="int">int</link> src_x,
                                                         <link linkend="int">int</link> src_y,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> width,
                                                         <link linkend="int">int</link> height,
                                                         <link linkend="XlibRgbDither">XlibRgbDither</link> dither,
                                                         <link linkend="int">int</link> x_dither,
                                                         <link linkend="int">int</link> y_dither);
<link linkend="void">void</link>                <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,
                                                         <link linkend="int">int</link> src_x,
                                                         <link linkend="int">int</link> src_y,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> width,
                                                         <link linkend="int">int</link> height,
                                                         <link linkend="GdkPixbufAlphaMode">GdkPixbufAlphaMode</link> alpha_mode,
                                                         <link linkend="int">int</link> alpha_threshold,
                                                         <link linkend="XlibRgbDither">XlibRgbDither</link> dither,
                                                         <link linkend="int">int</link> x_dither,
                                                         <link linkend="int">int</link> y_dither);
<link linkend="void">void</link>                <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,
                                                         <link linkend="int">int</link> alpha_threshold);
</synopsis>
</refsynopsisdiv>









<refsect1 id="gdk-pixbuf-gdk-pixbuf-xlib-rendering.description" role="desc">
<title role="desc.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 id="gdk-pixbuf-gdk-pixbuf-xlib-rendering.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="gdk-pixbuf-xlib-render-threshold-alpha" role="function">
<title>gdk_pixbuf_xlib_render_threshold_alpha ()</title>
<indexterm zone="gdk-pixbuf-xlib-render-threshold-alpha"><primary sortas="xlib_render_threshold_alpha">gdk_pixbuf_xlib_render_threshold_alpha</primary></indexterm><programlisting><link linkend="void">void</link>                gdk_pixbuf_xlib_render_threshold_alpha
                                                        (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                                         <link linkend="Pixmap">Pixmap</link> bitmap,
                                                         <link linkend="int">int</link> src_x,
                                                         <link linkend="int">int</link> src_y,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> width,
                                                         <link linkend="int">int</link> height,
                                                         <link linkend="int">int</link> 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><variablelist role="params">
<varlistentry><term><parameter>pixbuf</parameter>&#160;:</term>
<listitem><simpara> A pixbuf.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>bitmap</parameter>&#160;:</term>
<listitem><simpara> Bitmap where the bilevel mask will be painted to.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>src_x</parameter>&#160;:</term>
<listitem><simpara> Source X coordinate.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>src_y</parameter>&#160;:</term>
<listitem><simpara> source Y coordinate.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_x</parameter>&#160;:</term>
<listitem><simpara> Destination X coordinate.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_y</parameter>&#160;:</term>
<listitem><simpara> Destination Y coordinate.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>width</parameter>&#160;:</term>
<listitem><simpara> Width of region to threshold.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>height</parameter>&#160;:</term>
<listitem><simpara> Height of region to threshold.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>alpha_threshold</parameter>&#160;:</term>
<listitem><simpara> Opacity values below this will be painted as zero; all
other values will be painted as one.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gdk-pixbuf-xlib-render-to-drawable" role="function">
<title>gdk_pixbuf_xlib_render_to_drawable ()</title>
<indexterm zone="gdk-pixbuf-xlib-render-to-drawable"><primary sortas="xlib_render_to_drawable">gdk_pixbuf_xlib_render_to_drawable</primary></indexterm><programlisting><link linkend="void">void</link>                gdk_pixbuf_xlib_render_to_drawable  (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                                         <link linkend="Drawable">Drawable</link> drawable,
                                                         <link linkend="GC--CAPS">GC</link> gc,
                                                         <link linkend="int">int</link> src_x,
                                                         <link linkend="int">int</link> src_y,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> width,
                                                         <link linkend="int">int</link> height,
                                                         <link linkend="XlibRgbDither">XlibRgbDither</link> dither,
                                                         <link linkend="int">int</link> x_dither,
                                                         <link linkend="int">int</link> 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><variablelist role="params">
<varlistentry><term><parameter>pixbuf</parameter>&#160;:</term>
<listitem><simpara> A pixbuf.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>drawable</parameter>&#160;:</term>
<listitem><simpara> Destination drawable.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>gc</parameter>&#160;:</term>
<listitem><simpara> GC used for rendering.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>src_x</parameter>&#160;:</term>
<listitem><simpara> Source X coordinate within pixbuf.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>src_y</parameter>&#160;:</term>
<listitem><simpara> Source Y coordinate within pixbuf.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_x</parameter>&#160;:</term>
<listitem><simpara> Destination X coordinate within drawable.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_y</parameter>&#160;:</term>
<listitem><simpara> Destination Y coordinate within drawable.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>width</parameter>&#160;:</term>
<listitem><simpara> Width of region to render, in pixels.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>height</parameter>&#160;:</term>
<listitem><simpara> Height of region to render, in pixels.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dither</parameter>&#160;:</term>
<listitem><simpara> Dithering mode for XlibRGB.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>x_dither</parameter>&#160;:</term>
<listitem><simpara> X offset for dither.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>y_dither</parameter>&#160;:</term>
<listitem><simpara> Y offset for dither.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gdk-pixbuf-xlib-render-to-drawable-alpha" role="function">
<title>gdk_pixbuf_xlib_render_to_drawable_alpha ()</title>
<indexterm zone="gdk-pixbuf-xlib-render-to-drawable-alpha"><primary sortas="xlib_render_to_drawable_alpha">gdk_pixbuf_xlib_render_to_drawable_alpha</primary></indexterm><programlisting><link linkend="void">void</link>                gdk_pixbuf_xlib_render_to_drawable_alpha
                                                        (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
                                                         <link linkend="Drawable">Drawable</link> drawable,
                                                         <link linkend="int">int</link> src_x,
                                                         <link linkend="int">int</link> src_y,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> width,
                                                         <link linkend="int">int</link> height,
                                                         <link linkend="GdkPixbufAlphaMode">GdkPixbufAlphaMode</link> alpha_mode,
                                                         <link linkend="int">int</link> alpha_threshold,
                                                         <link linkend="XlibRgbDither">XlibRgbDither</link> dither,
                                                         <link linkend="int">int</link> x_dither,
                                                         <link linkend="int">int</link> 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--CAPS"><type>GDK_PIXBUF_ALPHA_BILEVEL</type></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"><function>gdk_pixbuf_xlib_render_to_drawable()</function></link> or GdkRGB directly instead.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>pixbuf</parameter>&#160;:</term>
<listitem><simpara> A pixbuf.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>drawable</parameter>&#160;:</term>
<listitem><simpara> Destination drawable.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>src_x</parameter>&#160;:</term>
<listitem><simpara> Source X coordinate within pixbuf.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>src_y</parameter>&#160;:</term>
<listitem><simpara> Source Y coordinates within pixbuf.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_x</parameter>&#160;:</term>
<listitem><simpara> Destination X coordinate within drawable.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_y</parameter>&#160;:</term>
<listitem><simpara> Destination Y coordinate within drawable.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>width</parameter>&#160;:</term>
<listitem><simpara> Width of region to render, in pixels.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>height</parameter>&#160;:</term>
<listitem><simpara> Height of region to render, in pixels.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>alpha_mode</parameter>&#160;:</term>
<listitem><simpara> If the image does not have opacity information, this is ignored.
Otherwise, specifies how to handle transparency when rendering.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>alpha_threshold</parameter>&#160;:</term>
<listitem><simpara> If the image does have opacity information and <parameter>alpha_mode</parameter>
is GDK_PIXBUF_ALPHA_BILEVEL, specifies the threshold value for opacity
values.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dither</parameter>&#160;:</term>
<listitem><simpara> Dithering mode for XlibRGB.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>x_dither</parameter>&#160;:</term>
<listitem><simpara> X offset for dither.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>y_dither</parameter>&#160;:</term>
<listitem><simpara> Y offset for dither.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gdk-pixbuf-xlib-render-pixmap-and-mask" role="function">
<title>gdk_pixbuf_xlib_render_pixmap_and_mask ()</title>
<indexterm zone="gdk-pixbuf-xlib-render-pixmap-and-mask"><primary sortas="xlib_render_pixmap_and_mask">gdk_pixbuf_xlib_render_pixmap_and_mask</primary></indexterm><programlisting><link linkend="void">void</link>                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,
                                                         <link linkend="int">int</link> 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"><function>gdk_pixbuf_xlib_render_to_drawable_alpha()</function></link> or
<link linkend="gdk-pixbuf-xlib-render-to-drawable"><function>gdk_pixbuf_xlib_render_to_drawable()</function></link>, and
<link linkend="gdk-pixbuf-xlib-render-threshold-alpha"><function>gdk_pixbuf_xlib_render_threshold_alpha()</function></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><variablelist role="params">
<varlistentry><term><parameter>pixbuf</parameter>&#160;:</term>
<listitem><simpara> A pixbuf.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>pixmap_return</parameter>&#160;:</term>
<listitem><simpara> Return value for the created pixmap.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>mask_return</parameter>&#160;:</term>
<listitem><simpara> Return value for the created mask.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>alpha_threshold</parameter>&#160;:</term>
<listitem><simpara> Threshold value for opacity values.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
