<?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-scaling">
<refmeta>
<refentrytitle role="top_of_page" id="gdk-pixbuf-scaling.top_of_page">Scaling</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GDK-PIXBUF Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Scaling</refname>
<refpurpose>Scaling pixbufs and scaling and compositing pixbufs</refpurpose>
</refnamediv>

<refsynopsisdiv id="gdk-pixbuf-scaling.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

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

enum                <link linkend="GdkInterpType">GdkInterpType</link>;
<link linkend="GdkPixbuf">GdkPixbuf</link> *         <link linkend="gdk-pixbuf-scale-simple">gdk_pixbuf_scale_simple</link>             (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="int">int</link> dest_width,
                                                         <link linkend="int">int</link> dest_height,
                                                         <link linkend="GdkInterpType">GdkInterpType</link> interp_type);
<link linkend="void">void</link>                <link linkend="gdk-pixbuf-scale">gdk_pixbuf_scale</link>                    (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="GdkPixbuf">GdkPixbuf</link> *dest,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> dest_width,
                                                         <link linkend="int">int</link> dest_height,
                                                         <link linkend="double">double</link> offset_x,
                                                         <link linkend="double">double</link> offset_y,
                                                         <link linkend="double">double</link> scale_x,
                                                         <link linkend="double">double</link> scale_y,
                                                         <link linkend="GdkInterpType">GdkInterpType</link> interp_type);
<link linkend="GdkPixbuf">GdkPixbuf</link> *         <link linkend="gdk-pixbuf-composite-color-simple">gdk_pixbuf_composite_color_simple</link>   (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="int">int</link> dest_width,
                                                         <link linkend="int">int</link> dest_height,
                                                         <link linkend="GdkInterpType">GdkInterpType</link> interp_type,
                                                         <link linkend="int">int</link> overall_alpha,
                                                         <link linkend="int">int</link> check_size,
                                                         <link linkend="guint32">guint32</link> color1,
                                                         <link linkend="guint32">guint32</link> color2);
<link linkend="void">void</link>                <link linkend="gdk-pixbuf-composite">gdk_pixbuf_composite</link>                (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="GdkPixbuf">GdkPixbuf</link> *dest,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> dest_width,
                                                         <link linkend="int">int</link> dest_height,
                                                         <link linkend="double">double</link> offset_x,
                                                         <link linkend="double">double</link> offset_y,
                                                         <link linkend="double">double</link> scale_x,
                                                         <link linkend="double">double</link> scale_y,
                                                         <link linkend="GdkInterpType">GdkInterpType</link> interp_type,
                                                         <link linkend="int">int</link> overall_alpha);
<link linkend="void">void</link>                <link linkend="gdk-pixbuf-composite-color">gdk_pixbuf_composite_color</link>          (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="GdkPixbuf">GdkPixbuf</link> *dest,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> dest_width,
                                                         <link linkend="int">int</link> dest_height,
                                                         <link linkend="double">double</link> offset_x,
                                                         <link linkend="double">double</link> offset_y,
                                                         <link linkend="double">double</link> scale_x,
                                                         <link linkend="double">double</link> scale_y,
                                                         <link linkend="GdkInterpType">GdkInterpType</link> interp_type,
                                                         <link linkend="int">int</link> overall_alpha,
                                                         <link linkend="int">int</link> check_x,
                                                         <link linkend="int">int</link> check_y,
                                                         <link linkend="int">int</link> check_size,
                                                         <link linkend="guint32">guint32</link> color1,
                                                         <link linkend="guint32">guint32</link> color2);
enum                <link linkend="GdkPixbufRotation">GdkPixbufRotation</link>;
<link linkend="GdkPixbuf">GdkPixbuf</link> *         <link linkend="gdk-pixbuf-rotate-simple">gdk_pixbuf_rotate_simple</link>            (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="GdkPixbufRotation">GdkPixbufRotation</link> angle);
<link linkend="GdkPixbuf">GdkPixbuf</link> *         <link linkend="gdk-pixbuf-flip">gdk_pixbuf_flip</link>                     (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="gboolean">gboolean</link> horizontal);
</synopsis>
</refsynopsisdiv>









<refsect1 id="gdk-pixbuf-scaling.description" role="desc">
<title role="desc.title">Description</title>
  <para>
    The &gdk-pixbuf; contains functions to scale pixbufs, to scale
    pixbufs and composite against an existing image, and to scale
    pixbufs and composite against a solid color or checkerboard.
    Compositing a checkerboard is a common way to show an image with
    an alpha channel in image-viewing and editing software.
  </para>
  <para>
    Since the full-featured functions (<link linkend="gdk-pixbuf-scale"><function>gdk_pixbuf_scale()</function></link>,
    <link linkend="gdk-pixbuf-composite"><function>gdk_pixbuf_composite()</function></link>, and <link linkend="gdk-pixbuf-composite-color"><function>gdk_pixbuf_composite_color()</function></link>) are
    rather complex to use and have many arguments, two simple
    convenience functions are provided, <link linkend="gdk-pixbuf-scale-simple"><function>gdk_pixbuf_scale_simple()</function></link> and
    <link linkend="gdk-pixbuf-composite-color-simple"><function>gdk_pixbuf_composite_color_simple()</function></link> which create a new pixbuf of a
    given size, scale an original image to fit, and then return the
    new pixbuf.
  </para>
  <para>
   Scaling and compositing functions take advantage of MMX hardware
   acceleration on systems where MMX is supported.  If gdk-pixbuf is built
   with the Sun mediaLib library, these functions are instead accelerated
   using mediaLib, which provides hardware acceleration on Intel, AMD,
   and Sparc chipsets.  If desired, mediaLib support can be turned off by
   setting the GDK_DISABLE_MEDIALIB environment variable.
  </para>
  <para>
    The following example demonstrates handling an expose event by
    rendering the appropriate area of a source image (which is scaled
    to fit the widget) onto the widget's window.  The source image is
    rendered against a checkerboard, which provides a visual
    representation of the alpha channel if the image has one. If the
    image doesn't have an alpha channel, calling
    <link linkend="gdk-pixbuf-composite-color"><function>gdk_pixbuf_composite_color()</function></link> function has exactly the same effect
    as calling <link linkend="gdk-pixbuf-scale"><function>gdk_pixbuf_scale()</function></link>.
  </para>
  <example>
  <title>Handling an expose event.</title>
  <programlisting>
gboolean
expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
  GdkPixbuf *dest;
  dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, event->area.width, event->area.height);
  gdk_pixbuf_composite_color (pixbuf, dest,
                              0, 0, event->area.width, event->area.height,
                              -event->area.x, -event->area.y,
                              (double) widget->allocation.width / gdk_pixbuf_get_width (pixbuf),
                              (double) widget->allocation.height / gdk_pixbuf_get_height (pixbuf),
                              GDK_INTERP_BILINEAR, 255,
                              event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
  gdk_draw_pixbuf (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], dest,
                   0, 0, event->area.x, event->area.y,
                   event->area.width, event->area.height,
                   GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y);
  gdk_pixbuf_unref (dest);
  return TRUE;
}
  </programlisting>
  </example>
</refsect1>

<refsect1 id="gdk-pixbuf-scaling.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GdkInterpType" role="enum">
<title>enum GdkInterpType</title>
<indexterm zone="GdkInterpType"><primary>GdkInterpType</primary></indexterm><programlisting>typedef enum {
	GDK_INTERP_NEAREST,
	GDK_INTERP_TILES,
	GDK_INTERP_BILINEAR,
	GDK_INTERP_HYPER
} GdkInterpType;
</programlisting>
  <para>
    This enumeration describes the different interpolation modes that
    can be used with the scaling functions. <parameter>GDK_INTERP_NEAREST</parameter> is
    the fastest scaling method, but has horrible quality when
    scaling down. <parameter>GDK_INTERP_BILINEAR</parameter> is the best choice if you
    aren't sure what to choose, it has a good speed/quality balance.
    <note>
      <para>
	Cubic filtering is missing from the list; hyperbolic
	interpolation is just as fast and results in higher quality.
      </para>
    </note>
  </para><variablelist role="enum">
<varlistentry id="GDK-INTERP-NEAREST--CAPS" role="constant">
<term><literal>GDK_INTERP_NEAREST</literal></term>
<listitem><simpara>Nearest neighbor sampling; this is the fastest
and lowest quality mode. Quality is normally unacceptable when scaling
down, but may be OK when scaling up.
</simpara></listitem>
</varlistentry>
<varlistentry id="GDK-INTERP-TILES--CAPS" role="constant">
<term><literal>GDK_INTERP_TILES</literal></term>
<listitem><simpara>This is an accurate simulation of the PostScript
image operator without any interpolation enabled.  Each pixel is
rendered as a tiny parallelogram of solid color, the edges of which
are implemented with antialiasing.  It resembles nearest neighbor for
enlargement, and bilinear for reduction.
</simpara></listitem>
</varlistentry>
<varlistentry id="GDK-INTERP-BILINEAR--CAPS" role="constant">
<term><literal>GDK_INTERP_BILINEAR</literal></term>
<listitem><simpara>Best quality/speed balance; use this mode by
default. Bilinear interpolation.  For enlargement, it is
equivalent to point-sampling the ideal bilinear-interpolated image.
For reduction, it is equivalent to laying down small tiles and
integrating over the coverage area.
</simpara></listitem>
</varlistentry>
<varlistentry id="GDK-INTERP-HYPER--CAPS" role="constant">
<term><literal>GDK_INTERP_HYPER</literal></term>
<listitem><simpara>This is the slowest and highest quality
reconstruction function. It is derived from the hyperbolic filters in
Wolberg's "Digital Image Warping", and is formally defined as the
hyperbolic-filter sampling the ideal hyperbolic-filter interpolated
image (the filter is designed to be idempotent for 1:1 pixel mapping).
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="gdk-pixbuf-scale-simple" role="function">
<title>gdk_pixbuf_scale_simple ()</title>
<indexterm zone="gdk-pixbuf-scale-simple"><primary sortas="scale_simple">gdk_pixbuf_scale_simple</primary></indexterm><programlisting><link linkend="GdkPixbuf">GdkPixbuf</link> *         gdk_pixbuf_scale_simple             (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="int">int</link> dest_width,
                                                         <link linkend="int">int</link> dest_height,
                                                         <link linkend="GdkInterpType">GdkInterpType</link> interp_type);</programlisting>
<para>
Create a new <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link> containing a copy of <parameter>src</parameter> scaled to
<parameter>dest_width</parameter> x <parameter>dest_height</parameter>. Leaves <parameter>src</parameter> unaffected.  <parameter>interp_type</parameter>
should be <link linkend="GDK-INTERP-NEAREST--CAPS"><type>GDK_INTERP_NEAREST</type></link> if you want maximum speed (but when
scaling down <link linkend="GDK-INTERP-NEAREST--CAPS"><type>GDK_INTERP_NEAREST</type></link> is usually unusably ugly).  The
default <parameter>interp_type</parameter> should be <link linkend="GDK-INTERP-BILINEAR--CAPS"><type>GDK_INTERP_BILINEAR</type></link> which offers
reasonable quality and speed.
</para>
<para>
You can scale a sub-portion of <parameter>src</parameter> by creating a sub-pixbuf
pointing into <parameter>src</parameter>; see <link linkend="gdk-pixbuf-new-subpixbuf"><function>gdk_pixbuf_new_subpixbuf()</function></link>.
</para>
<para>
For more complicated scaling/compositing see <link linkend="gdk-pixbuf-scale"><function>gdk_pixbuf_scale()</function></link>
and <link linkend="gdk-pixbuf-composite"><function>gdk_pixbuf_composite()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>src</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_width</parameter>&#160;:</term>
<listitem><simpara> the width of destination image
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_height</parameter>&#160;:</term>
<listitem><simpara> the height of destination image
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>interp_type</parameter>&#160;:</term>
<listitem><simpara> the interpolation type for the transformation.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the new <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if not enough memory could be
allocated for it.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gdk-pixbuf-scale" role="function">
<title>gdk_pixbuf_scale ()</title>
<indexterm zone="gdk-pixbuf-scale"><primary sortas="scale">gdk_pixbuf_scale</primary></indexterm><programlisting><link linkend="void">void</link>                gdk_pixbuf_scale                    (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="GdkPixbuf">GdkPixbuf</link> *dest,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> dest_width,
                                                         <link linkend="int">int</link> dest_height,
                                                         <link linkend="double">double</link> offset_x,
                                                         <link linkend="double">double</link> offset_y,
                                                         <link linkend="double">double</link> scale_x,
                                                         <link linkend="double">double</link> scale_y,
                                                         <link linkend="GdkInterpType">GdkInterpType</link> interp_type);</programlisting>
<para>
Creates a transformation of the source image <parameter>src</parameter> by scaling by
<parameter>scale_x</parameter> and <parameter>scale_y</parameter> then translating by <parameter>offset_x</parameter> and <parameter>offset_y</parameter>,
then renders the rectangle (<parameter>dest_x</parameter>, <parameter>dest_y</parameter>, <parameter>dest_width</parameter>,
<parameter>dest_height</parameter>) of the resulting image onto the destination image
replacing the previous contents.
</para>
<para>
Try to use <link linkend="gdk-pixbuf-scale-simple"><function>gdk_pixbuf_scale_simple()</function></link> first, this function is
the industrial-strength power tool you can fall back to if
<link linkend="gdk-pixbuf-scale-simple"><function>gdk_pixbuf_scale_simple()</function></link> isn't powerful enough.
</para>
<para>
If the source rectangle overlaps the destination rectangle on the
same pixbuf, it will be overwritten during the scaling which
results in rendering artifacts.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>src</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link> into which to render the results
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_x</parameter>&#160;:</term>
<listitem><simpara> the left coordinate for region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_y</parameter>&#160;:</term>
<listitem><simpara> the top coordinate for region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_width</parameter>&#160;:</term>
<listitem><simpara> the width of the region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_height</parameter>&#160;:</term>
<listitem><simpara> the height of the region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset_x</parameter>&#160;:</term>
<listitem><simpara> the offset in the X direction (currently rounded to an integer)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset_y</parameter>&#160;:</term>
<listitem><simpara> the offset in the Y direction (currently rounded to an integer)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>scale_x</parameter>&#160;:</term>
<listitem><simpara> the scale factor in the X direction
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>scale_y</parameter>&#160;:</term>
<listitem><simpara> the scale factor in the Y direction
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>interp_type</parameter>&#160;:</term>
<listitem><simpara> the interpolation type for the transformation.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gdk-pixbuf-composite-color-simple" role="function">
<title>gdk_pixbuf_composite_color_simple ()</title>
<indexterm zone="gdk-pixbuf-composite-color-simple"><primary sortas="composite_color_simple">gdk_pixbuf_composite_color_simple</primary></indexterm><programlisting><link linkend="GdkPixbuf">GdkPixbuf</link> *         gdk_pixbuf_composite_color_simple   (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="int">int</link> dest_width,
                                                         <link linkend="int">int</link> dest_height,
                                                         <link linkend="GdkInterpType">GdkInterpType</link> interp_type,
                                                         <link linkend="int">int</link> overall_alpha,
                                                         <link linkend="int">int</link> check_size,
                                                         <link linkend="guint32">guint32</link> color1,
                                                         <link linkend="guint32">guint32</link> color2);</programlisting>
<para>
Creates a new <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link> by scaling <parameter>src</parameter> to <parameter>dest_width</parameter> x
<parameter>dest_height</parameter> and compositing the result with a checkboard of colors
<parameter>color1</parameter> and <parameter>color2</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>src</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_width</parameter>&#160;:</term>
<listitem><simpara> the width of destination image
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_height</parameter>&#160;:</term>
<listitem><simpara> the height of destination image
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>interp_type</parameter>&#160;:</term>
<listitem><simpara> the interpolation type for the transformation.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>overall_alpha</parameter>&#160;:</term>
<listitem><simpara> overall alpha for source image (0..255)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>check_size</parameter>&#160;:</term>
<listitem><simpara> the size of checks in the checkboard (must be a power of two)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>color1</parameter>&#160;:</term>
<listitem><simpara> the color of check at upper left
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>color2</parameter>&#160;:</term>
<listitem><simpara> the color of the other check
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the new <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if not enough memory could be
allocated for it.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gdk-pixbuf-composite" role="function">
<title>gdk_pixbuf_composite ()</title>
<indexterm zone="gdk-pixbuf-composite"><primary sortas="composite">gdk_pixbuf_composite</primary></indexterm><programlisting><link linkend="void">void</link>                gdk_pixbuf_composite                (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="GdkPixbuf">GdkPixbuf</link> *dest,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> dest_width,
                                                         <link linkend="int">int</link> dest_height,
                                                         <link linkend="double">double</link> offset_x,
                                                         <link linkend="double">double</link> offset_y,
                                                         <link linkend="double">double</link> scale_x,
                                                         <link linkend="double">double</link> scale_y,
                                                         <link linkend="GdkInterpType">GdkInterpType</link> interp_type,
                                                         <link linkend="int">int</link> overall_alpha);</programlisting>
<para>
Creates a transformation of the source image <parameter>src</parameter> by scaling by
<parameter>scale_x</parameter> and <parameter>scale_y</parameter> then translating by <parameter>offset_x</parameter> and <parameter>offset_y</parameter>.
This gives an image in the coordinates of the destination pixbuf.
The rectangle (<parameter>dest_x</parameter>, <parameter>dest_y</parameter>, <parameter>dest_width</parameter>, <parameter>dest_height</parameter>)
is then composited onto the corresponding rectangle of the
original destination image.
</para>
<para>
When the destination rectangle contains parts not in the source 
image, the data at the edges of the source image is replicated
to infinity. 
</para>
<para>
<figure id="pixbuf-composite-diagram">
  <title>Compositing of pixbufs</title>
  <graphic fileref="composite.png" format="PNG"/>
</figure></para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>src</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link> into which to render the results
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_x</parameter>&#160;:</term>
<listitem><simpara> the left coordinate for region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_y</parameter>&#160;:</term>
<listitem><simpara> the top coordinate for region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_width</parameter>&#160;:</term>
<listitem><simpara> the width of the region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_height</parameter>&#160;:</term>
<listitem><simpara> the height of the region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset_x</parameter>&#160;:</term>
<listitem><simpara> the offset in the X direction (currently rounded to an integer)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset_y</parameter>&#160;:</term>
<listitem><simpara> the offset in the Y direction (currently rounded to an integer)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>scale_x</parameter>&#160;:</term>
<listitem><simpara> the scale factor in the X direction
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>scale_y</parameter>&#160;:</term>
<listitem><simpara> the scale factor in the Y direction
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>interp_type</parameter>&#160;:</term>
<listitem><simpara> the interpolation type for the transformation.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>overall_alpha</parameter>&#160;:</term>
<listitem><simpara> overall alpha for source image (0..255)
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gdk-pixbuf-composite-color" role="function">
<title>gdk_pixbuf_composite_color ()</title>
<indexterm zone="gdk-pixbuf-composite-color"><primary sortas="composite_color">gdk_pixbuf_composite_color</primary></indexterm><programlisting><link linkend="void">void</link>                gdk_pixbuf_composite_color          (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="GdkPixbuf">GdkPixbuf</link> *dest,
                                                         <link linkend="int">int</link> dest_x,
                                                         <link linkend="int">int</link> dest_y,
                                                         <link linkend="int">int</link> dest_width,
                                                         <link linkend="int">int</link> dest_height,
                                                         <link linkend="double">double</link> offset_x,
                                                         <link linkend="double">double</link> offset_y,
                                                         <link linkend="double">double</link> scale_x,
                                                         <link linkend="double">double</link> scale_y,
                                                         <link linkend="GdkInterpType">GdkInterpType</link> interp_type,
                                                         <link linkend="int">int</link> overall_alpha,
                                                         <link linkend="int">int</link> check_x,
                                                         <link linkend="int">int</link> check_y,
                                                         <link linkend="int">int</link> check_size,
                                                         <link linkend="guint32">guint32</link> color1,
                                                         <link linkend="guint32">guint32</link> color2);</programlisting>
<para>
Creates a transformation of the source image <parameter>src</parameter> by scaling by
<parameter>scale_x</parameter> and <parameter>scale_y</parameter> then translating by <parameter>offset_x</parameter> and <parameter>offset_y</parameter>,
then composites the rectangle (<parameter>dest_x</parameter> ,<parameter>dest_y</parameter>, <parameter>dest_width</parameter>,
<parameter>dest_height</parameter>) of the resulting image with a checkboard of the
colors <parameter>color1</parameter> and <parameter>color2</parameter> and renders it onto the destination
image.
</para>
<para>
See <link linkend="gdk-pixbuf-composite-color-simple"><function>gdk_pixbuf_composite_color_simple()</function></link> for a simpler variant of this
function suitable for many tasks.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>src</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link> into which to render the results
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_x</parameter>&#160;:</term>
<listitem><simpara> the left coordinate for region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_y</parameter>&#160;:</term>
<listitem><simpara> the top coordinate for region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_width</parameter>&#160;:</term>
<listitem><simpara> the width of the region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest_height</parameter>&#160;:</term>
<listitem><simpara> the height of the region to render
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset_x</parameter>&#160;:</term>
<listitem><simpara> the offset in the X direction (currently rounded to an integer)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset_y</parameter>&#160;:</term>
<listitem><simpara> the offset in the Y direction (currently rounded to an integer)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>scale_x</parameter>&#160;:</term>
<listitem><simpara> the scale factor in the X direction
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>scale_y</parameter>&#160;:</term>
<listitem><simpara> the scale factor in the Y direction
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>interp_type</parameter>&#160;:</term>
<listitem><simpara> the interpolation type for the transformation.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>overall_alpha</parameter>&#160;:</term>
<listitem><simpara> overall alpha for source image (0..255)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>check_x</parameter>&#160;:</term>
<listitem><simpara> the X offset for the checkboard (origin of checkboard is at -<parameter>check_x</parameter>, -<parameter>check_y</parameter>)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>check_y</parameter>&#160;:</term>
<listitem><simpara> the Y offset for the checkboard 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>check_size</parameter>&#160;:</term>
<listitem><simpara> the size of checks in the checkboard (must be a power of two)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>color1</parameter>&#160;:</term>
<listitem><simpara> the color of check at upper left
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>color2</parameter>&#160;:</term>
<listitem><simpara> the color of the other check
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="GdkPixbufRotation" role="enum">
<title>enum GdkPixbufRotation</title>
<indexterm zone="GdkPixbufRotation"><primary>GdkPixbufRotation</primary></indexterm><programlisting>typedef enum {
	GDK_PIXBUF_ROTATE_NONE             =   0,
	GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE =  90,
	GDK_PIXBUF_ROTATE_UPSIDEDOWN       = 180,
	GDK_PIXBUF_ROTATE_CLOCKWISE        = 270
} GdkPixbufRotation;
</programlisting>
<para>
The possible rotations which can be passed to <link linkend="gdk-pixbuf-rotate-simple"><function>gdk_pixbuf_rotate_simple()</function></link>.
To make them easier to use, their numerical values are the actual degrees.
</para><variablelist role="enum">
<varlistentry id="GDK-PIXBUF-ROTATE-NONE--CAPS" role="constant">
<term><literal>GDK_PIXBUF_ROTATE_NONE</literal></term>
<listitem><simpara>No rotation.
</simpara></listitem>
</varlistentry>
<varlistentry id="GDK-PIXBUF-ROTATE-COUNTERCLOCKWISE--CAPS" role="constant">
<term><literal>GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE</literal></term>
<listitem><simpara>Rotate by 90 degrees.
</simpara></listitem>
</varlistentry>
<varlistentry id="GDK-PIXBUF-ROTATE-UPSIDEDOWN--CAPS" role="constant">
<term><literal>GDK_PIXBUF_ROTATE_UPSIDEDOWN</literal></term>
<listitem><simpara>Rotate by 180 degrees.
</simpara></listitem>
</varlistentry>
<varlistentry id="GDK-PIXBUF-ROTATE-CLOCKWISE--CAPS" role="constant">
<term><literal>GDK_PIXBUF_ROTATE_CLOCKWISE</literal></term>
<listitem><simpara>Rotate by 270 degrees.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="gdk-pixbuf-rotate-simple" role="function" condition="since:2.6">
<title>gdk_pixbuf_rotate_simple ()</title>
<indexterm zone="gdk-pixbuf-rotate-simple" role="2.6"><primary sortas="rotate_simple">gdk_pixbuf_rotate_simple</primary></indexterm><programlisting><link linkend="GdkPixbuf">GdkPixbuf</link> *         gdk_pixbuf_rotate_simple            (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="GdkPixbufRotation">GdkPixbufRotation</link> angle);</programlisting>
<para>
Rotates a pixbuf by a multiple of 90 degrees, and returns the
result in a new pixbuf.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>src</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>angle</parameter>&#160;:</term>
<listitem><simpara> the angle to rotate by
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the new <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if not enough memory could be
allocated for it.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="gdk-pixbuf-flip" role="function" condition="since:2.6">
<title>gdk_pixbuf_flip ()</title>
<indexterm zone="gdk-pixbuf-flip" role="2.6"><primary sortas="flip">gdk_pixbuf_flip</primary></indexterm><programlisting><link linkend="GdkPixbuf">GdkPixbuf</link> *         gdk_pixbuf_flip                     (const <link linkend="GdkPixbuf">GdkPixbuf</link> *src,
                                                         <link linkend="gboolean">gboolean</link> horizontal);</programlisting>
<para>
Flips a pixbuf horizontally or vertically and returns the
result in a new pixbuf.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>src</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>horizontal</parameter>&#160;:</term>
<listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> to flip horizontally, <link linkend="FALSE--CAPS"><literal>FALSE</literal></link> to flip vertically
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the new <link linkend="GdkPixbuf"><type>GdkPixbuf</type></link>, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if not enough memory could be
allocated for it.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>

</refsect1>



<refsect1 id="gdk-pixbuf-scaling.see-also">
<title>See Also</title>
  <para>
    <link linkend="gdk-GdkRGB">GdkRGB</link>.
  </para>
</refsect1>

</refentry>
