2000-01-06 01:08:10 +00:00
|
|
|
<!-- ##### SECTION Title ##### -->
|
2001-02-12 17:50:13 +00:00
|
|
|
Scaling
|
2000-01-06 01:08:10 +00:00
|
|
|
|
|
|
|
<!-- ##### SECTION Short_Description ##### -->
|
2001-02-12 17:50:13 +00:00
|
|
|
Scaling pixbufs and scaling and compositing pixbufs
|
2000-01-06 01:08:10 +00:00
|
|
|
|
|
|
|
<!-- ##### SECTION Long_Description ##### -->
|
2001-02-12 17:50:13 +00:00
|
|
|
<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 (gdk_pixbuf_scale(),
|
|
|
|
gdk_pixbuf_composite(), and gdk_pixbuf_composite_color()) are
|
|
|
|
rather complex to use and have many arguments, two simple
|
|
|
|
convenience functions are provided, gdk_pixbuf_scale_simple() and
|
|
|
|
gdk_pixbuf_composite_color_simple() which create a new pixbuf of a
|
|
|
|
given size, scale an original image to fit, and then return the
|
2001-12-16 21:09:30 +00:00
|
|
|
new pixbuf.
|
2001-02-12 17:50:13 +00:00
|
|
|
</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
|
|
|
|
gdk_pixbuf_composite_color() function has exactly the same effect
|
|
|
|
as calling gdk_pixbuf_scale().
|
|
|
|
</para>
|
|
|
|
|
Markup fixes.
* gtk/gtkdialog.c, gtk/gtkrc.c, gtk/gtkwidget.c: Markup fixes.
* gdk-pixbuf-io.c: Markup fixes.
* gdk-pixbuf/tmpl/scaling.sgml, gdk/tmpl/fonts.sgml,
gdk/tmpl/general.sgml, gdk/tmpl/rgb.sgml, gdk/tmpl/visuals.sgml,
gdk/tmpl/windows.sgml, gtk/gtk-docs.sgml, gtk/tmpl/gtkaccellabel.sgml,
gtk/tmpl/gtkcombo.sgml, gtk/tmpl/gtkdialog.sgml,
gtk/tmpl/gtkdrawingarea.sgml, gtk/tmpl/gtkeditable.sgml,
gtk/tmpl/gtkfilesel.sgml, gtk/tmpl/gtkfontseldlg.sgml,
gtk/tmpl/gtkimage.sgml, gtk/tmpl/gtkmain.sgml, gtk/tmpl/gtkmenu.sgml,
gtk/tmpl/gtkmessagedialog.sgml, gtk/tmpl/gtkobject.sgml,
gtk/tmpl/gtkpaned.sgml, gtk/tmpl/gtkradiobutton.sgml,
gtk/tmpl/gtkrc.sgml, gtk/tmpl/gtkscale.sgml, gtk/tmpl/gtksignal.sgml,
gtk/tmpl/gtksocket.sgml, gtk/tmpl/gtkspinbutton.sgml,
gtk/tmpl/gtktogglebutton.sgml, gtk/tmpl/gtksignal.sgml,
gtk/tmpl/gtktooltips.sgml, gtk/tmpl/gtkwindow.sgml,
gdk/tmpl/regions.sgml, gtk/tmpl/gtkfontsel.sgml,
gtk/tmpl/gtkpixmap.sgml, gtk/tmpl/gtkprogress.sgml,
gtk/tmpl/gtkselection.sgml, gtk/tmpl/gtktable.sgml,
gtk/tmpl/gtktipsquery.sgml: Markup fixes (mainly examples).
2001-12-13 19:51:24 +00:00
|
|
|
<example>
|
|
|
|
<title>Handling an expose event.</title>
|
2001-02-12 17:50:13 +00:00
|
|
|
<programlisting>
|
|
|
|
gboolean
|
|
|
|
expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
|
|
|
{
|
|
|
|
GdkPixbuf *dest;
|
|
|
|
|
|
|
|
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
|
|
|
|
|
|
|
|
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_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
|
|
|
|
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>
|
Markup fixes.
* gtk/gtkdialog.c, gtk/gtkrc.c, gtk/gtkwidget.c: Markup fixes.
* gdk-pixbuf-io.c: Markup fixes.
* gdk-pixbuf/tmpl/scaling.sgml, gdk/tmpl/fonts.sgml,
gdk/tmpl/general.sgml, gdk/tmpl/rgb.sgml, gdk/tmpl/visuals.sgml,
gdk/tmpl/windows.sgml, gtk/gtk-docs.sgml, gtk/tmpl/gtkaccellabel.sgml,
gtk/tmpl/gtkcombo.sgml, gtk/tmpl/gtkdialog.sgml,
gtk/tmpl/gtkdrawingarea.sgml, gtk/tmpl/gtkeditable.sgml,
gtk/tmpl/gtkfilesel.sgml, gtk/tmpl/gtkfontseldlg.sgml,
gtk/tmpl/gtkimage.sgml, gtk/tmpl/gtkmain.sgml, gtk/tmpl/gtkmenu.sgml,
gtk/tmpl/gtkmessagedialog.sgml, gtk/tmpl/gtkobject.sgml,
gtk/tmpl/gtkpaned.sgml, gtk/tmpl/gtkradiobutton.sgml,
gtk/tmpl/gtkrc.sgml, gtk/tmpl/gtkscale.sgml, gtk/tmpl/gtksignal.sgml,
gtk/tmpl/gtksocket.sgml, gtk/tmpl/gtkspinbutton.sgml,
gtk/tmpl/gtktogglebutton.sgml, gtk/tmpl/gtksignal.sgml,
gtk/tmpl/gtktooltips.sgml, gtk/tmpl/gtkwindow.sgml,
gdk/tmpl/regions.sgml, gtk/tmpl/gtkfontsel.sgml,
gtk/tmpl/gtkpixmap.sgml, gtk/tmpl/gtkprogress.sgml,
gtk/tmpl/gtkselection.sgml, gtk/tmpl/gtktable.sgml,
gtk/tmpl/gtktipsquery.sgml: Markup fixes (mainly examples).
2001-12-13 19:51:24 +00:00
|
|
|
</example>
|
2000-12-12 07:32:32 +00:00
|
|
|
|
2000-01-06 01:08:10 +00:00
|
|
|
<!-- ##### SECTION See_Also ##### -->
|
2001-02-12 17:50:13 +00:00
|
|
|
<para>
|
Markup fixes.
* gtk/gtkdialog.c, gtk/gtkrc.c, gtk/gtkwidget.c: Markup fixes.
* gdk-pixbuf-io.c: Markup fixes.
* gdk-pixbuf/tmpl/scaling.sgml, gdk/tmpl/fonts.sgml,
gdk/tmpl/general.sgml, gdk/tmpl/rgb.sgml, gdk/tmpl/visuals.sgml,
gdk/tmpl/windows.sgml, gtk/gtk-docs.sgml, gtk/tmpl/gtkaccellabel.sgml,
gtk/tmpl/gtkcombo.sgml, gtk/tmpl/gtkdialog.sgml,
gtk/tmpl/gtkdrawingarea.sgml, gtk/tmpl/gtkeditable.sgml,
gtk/tmpl/gtkfilesel.sgml, gtk/tmpl/gtkfontseldlg.sgml,
gtk/tmpl/gtkimage.sgml, gtk/tmpl/gtkmain.sgml, gtk/tmpl/gtkmenu.sgml,
gtk/tmpl/gtkmessagedialog.sgml, gtk/tmpl/gtkobject.sgml,
gtk/tmpl/gtkpaned.sgml, gtk/tmpl/gtkradiobutton.sgml,
gtk/tmpl/gtkrc.sgml, gtk/tmpl/gtkscale.sgml, gtk/tmpl/gtksignal.sgml,
gtk/tmpl/gtksocket.sgml, gtk/tmpl/gtkspinbutton.sgml,
gtk/tmpl/gtktogglebutton.sgml, gtk/tmpl/gtksignal.sgml,
gtk/tmpl/gtktooltips.sgml, gtk/tmpl/gtkwindow.sgml,
gdk/tmpl/regions.sgml, gtk/tmpl/gtkfontsel.sgml,
gtk/tmpl/gtkpixmap.sgml, gtk/tmpl/gtkprogress.sgml,
gtk/tmpl/gtkselection.sgml, gtk/tmpl/gtktable.sgml,
gtk/tmpl/gtktipsquery.sgml: Markup fixes (mainly examples).
2001-12-13 19:51:24 +00:00
|
|
|
<link linkend="gdk-GdkRGB">GdkRGB</link>.
|
2001-02-12 17:50:13 +00:00
|
|
|
</para>
|
2000-12-12 07:32:32 +00:00
|
|
|
|
2000-10-29 08:03:34 +00:00
|
|
|
<!-- ##### ENUM GdkInterpType ##### -->
|
2001-02-12 17:50:13 +00:00
|
|
|
<para>
|
|
|
|
This enumeration describes the different interpolation modes that
|
2001-12-16 21:09:30 +00:00
|
|
|
can be used with the scaling functions. @GDK_INTERP_NEAREST is
|
|
|
|
the fastest scaling method, but has horrible quality when
|
|
|
|
scaling down. @GDK_INTERP_BILINEAR is the best choice if you
|
|
|
|
aren't sure what to choose, it has a good speed/quality balance.
|
2001-02-12 17:50:13 +00:00
|
|
|
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
Cubic filtering is missing from the list; hyperbolic
|
|
|
|
interpolation is just as fast and results in higher quality.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@GDK_INTERP_NEAREST: Nearest neighbor sampling; this is the fastest
|
2001-12-16 21:09:30 +00:00
|
|
|
and lowest quality mode. Quality is normally unacceptable when scaling
|
|
|
|
down, but may be OK when scaling up.
|
2001-02-12 17:50:13 +00:00
|
|
|
@GDK_INTERP_TILES: 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.
|
2001-12-16 21:09:30 +00:00
|
|
|
@GDK_INTERP_BILINEAR: Best quality/speed balance; use this mode by
|
|
|
|
default. Bilinear interpolation. For enlargement, it is
|
2001-02-12 17:50:13 +00:00
|
|
|
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.
|
|
|
|
@GDK_INTERP_HYPER: This is the slowest and highest quality
|
2001-12-16 21:09:30 +00:00
|
|
|
reconstruction function. It is derived from the hyperbolic filters in
|
2001-02-12 17:50:13 +00:00
|
|
|
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).
|
2000-10-29 08:03:34 +00:00
|
|
|
|
2001-12-17 16:46:08 +00:00
|
|
|
<!-- ##### FUNCTION gdk_pixbuf_scale_simple ##### -->
|
2000-10-29 08:03:34 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@src:
|
|
|
|
@dest_width:
|
|
|
|
@dest_height:
|
|
|
|
@interp_type:
|
2001-12-17 16:46:08 +00:00
|
|
|
@Returns:
|
2000-10-29 08:03:34 +00:00
|
|
|
|
|
|
|
|
2001-12-17 16:46:08 +00:00
|
|
|
<!-- ##### FUNCTION gdk_pixbuf_scale ##### -->
|
2000-10-29 08:03:34 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@src:
|
|
|
|
@dest:
|
|
|
|
@dest_x:
|
|
|
|
@dest_y:
|
|
|
|
@dest_width:
|
|
|
|
@dest_height:
|
|
|
|
@offset_x:
|
|
|
|
@offset_y:
|
|
|
|
@scale_x:
|
|
|
|
@scale_y:
|
|
|
|
@interp_type:
|
|
|
|
|
|
|
|
|
2001-12-17 16:46:08 +00:00
|
|
|
<!-- ##### FUNCTION gdk_pixbuf_composite_color_simple ##### -->
|
2000-10-29 08:03:34 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@src:
|
|
|
|
@dest_width:
|
|
|
|
@dest_height:
|
|
|
|
@interp_type:
|
|
|
|
@overall_alpha:
|
|
|
|
@check_size:
|
|
|
|
@color1:
|
|
|
|
@color2:
|
2001-12-17 16:46:08 +00:00
|
|
|
@Returns: <!--
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
|
|
|
|
End:
|
|
|
|
-->
|
2000-10-29 08:03:34 +00:00
|
|
|
|
|
|
|
|
2001-12-17 16:46:08 +00:00
|
|
|
<!-- ##### FUNCTION gdk_pixbuf_composite ##### -->
|
2000-10-29 08:03:34 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@src:
|
2001-12-17 16:46:08 +00:00
|
|
|
@dest:
|
|
|
|
@dest_x:
|
|
|
|
@dest_y:
|
2000-10-29 08:03:34 +00:00
|
|
|
@dest_width:
|
|
|
|
@dest_height:
|
2001-12-17 16:46:08 +00:00
|
|
|
@offset_x:
|
|
|
|
@offset_y:
|
|
|
|
@scale_x:
|
|
|
|
@scale_y:
|
2000-10-29 08:03:34 +00:00
|
|
|
@interp_type:
|
2001-12-17 16:46:08 +00:00
|
|
|
@overall_alpha:
|
2000-10-29 08:03:34 +00:00
|
|
|
|
|
|
|
|
2001-12-17 16:46:08 +00:00
|
|
|
<!-- ##### FUNCTION gdk_pixbuf_composite_color ##### -->
|
2000-10-29 08:03:34 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@src:
|
2001-12-17 16:46:08 +00:00
|
|
|
@dest:
|
|
|
|
@dest_x:
|
|
|
|
@dest_y:
|
2000-10-29 08:03:34 +00:00
|
|
|
@dest_width:
|
|
|
|
@dest_height:
|
2001-12-17 16:46:08 +00:00
|
|
|
@offset_x:
|
|
|
|
@offset_y:
|
|
|
|
@scale_x:
|
|
|
|
@scale_y:
|
2000-10-29 08:03:34 +00:00
|
|
|
@interp_type:
|
|
|
|
@overall_alpha:
|
2001-12-17 16:46:08 +00:00
|
|
|
@check_x:
|
|
|
|
@check_y:
|
2000-10-29 08:03:34 +00:00
|
|
|
@check_size:
|
|
|
|
@color1:
|
|
|
|
@color2:
|
|
|
|
|
|
|
|
|
2004-07-12 20:25:34 +00:00
|
|
|
<!-- ##### ENUM GdkPixbufRotation ##### -->
|
|
|
|
<para>
|
2004-10-26 17:35:41 +00:00
|
|
|
The possible rotations which can be passed to gdk_pixbuf_rotate_simple().
|
|
|
|
To make them easier to use, their numerical values are the actual degrees.
|
2004-07-12 20:25:34 +00:00
|
|
|
</para>
|
|
|
|
|
2004-10-26 17:35:41 +00:00
|
|
|
@GDK_PIXBUF_ROTATE_NONE: No rotation.
|
|
|
|
@GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE: Rotate by 90 degrees.
|
|
|
|
@GDK_PIXBUF_ROTATE_UPSIDEDOWN: Rotate by 180 degrees.
|
|
|
|
@GDK_PIXBUF_ROTATE_CLOCKWISE: Rotate by 270 degrees.
|
2004-07-12 20:25:34 +00:00
|
|
|
|
|
|
|
<!-- ##### FUNCTION gdk_pixbuf_rotate_simple ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@src:
|
|
|
|
@angle:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION gdk_pixbuf_flip ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@src:
|
|
|
|
@horizontal:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|