gtk2/docs/reference/gdk-pixbuf/tmpl/scaling.sgml

71 lines
2.7 KiB
Plaintext
Raw Normal View History

<!-- ##### SECTION Title ##### -->
Scaling
<!-- ##### SECTION Short_Description ##### -->
Scaling pixbufs and scaling and compositing pixbufs
<!-- ##### SECTION Long_Description ##### -->
Your eyes are bloodshot. Your eyes are bloodshot. Your mouth starts to foam. Your hands are shaking. You know your need your fix. NEED MORE ABSTRACTION! 2000-04-12 Federico Mena Quintero <federico@helixcode.com> This comes from an excellent idea by Tim Janik (timj@gtk.org) to hook to the last unref operation. * gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_set_last_unref_handler): New function to set the last unref handler for a pixbuf. (gdk_pixbuf_finalize): New function to actually finalize a pixbuf. It calls the pixbuf's destroy notification function and frees the GdkPixbuf structure itself. (gdk_pixbuf_unref): Use the last unref function of the pixbuf if available. * gdk-pixbuf/gdk-pixbuf-private.h (struct _GdkPixbuf): New fields for the last unref handler and its user data. * gdk-pixbuf/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Use g_new0() to allocate the pixbuf. * gdk-pixbuf/gdk-pixbuf-loader.c (gdk_pixbuf_loader_class_init): Fixed the call to gtk_signal_new() for the "frame_done" signal; it was not specifying the `frame' argument. * gdk-pixbuf/gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_width): Fixed docstring. (gdk_pixbuf_animation_get_height): Likewise. (gdk_pixbuf_animation_get_num_frames): Likewise. (gdk_pixbuf_animation_get_frames): Likewise. * doc/gdk-pixbuf-sections.txt: Updated with the new functions and types. * doc/tmpl/gdk-pixbuf.sgml: Added the description for GdkColorspace. * doc/tmpl/scaling.sgml: Added the description for GdkInterpType. * doc/tmpl/refcounting.sgml: Updated with the information about the last unref handler. * doc/tmpl/*.sgml: Markup tweaks. * gdk-pixbuf/Makefile.am (libgnomecanvaspixbuf_la_LDFLAGS): Sigh, update the libtool version number for libgnomecanvaspixbuf as well. (libpixbufloader_*_la_LDFLAGS): The loaders need to be versioned as well, or the old ones won't work with the new stuff. Also, renamed the modules as follows. * gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_load_module): Now the modules are called "libpixbufloader-<format>.so" instead of "libpixbuf-<format>.so". They needed renaming so that the new loaders won't overwrite the old ones; even with the versioning stuff, the new .so symlink to the .so.1.0.0 would overwrite the old real .so file.
2000-04-13 01:18:41 +00:00
<para>
contrib subdir 2000-10-06 Havoc Pennington <hp@redhat.com> * Makefile.am (SRC_SUBDIRS): contrib subdir * gdk/gdkpixbuf.h: Move GdkPixbufAlphaMode to gdk-pixbuf library, so it can be used in Xlib version * demos/testpixbuf.c (update_timeout): error checking from 1.0 tree * gtk/gdk-pixbuf-loader.c (gdk_pixbuf_loader_get_pixbuf): Sync change from 1.0 tree that returns first frame of animation if the loaded file is an animation. * contrib: add new directory to hold stuff that comes with GTK+ but isn't really part of GTK+ (for now, gdk-pixbuf-xlib) * configure.in: add contrib/* 2000-10-06 Havoc Pennington <hp@redhat.com> * gdk-pixbuf.h: add GdkPixbufAlphaMode 2000-10-06 Havoc Pennington <hp@redhat.com> This entry is a summary of the merged-in changes from 1.0. Relevant original ChangeLog entries are spliced in after this entry; the files they refer to are from the 1.0 gdk-pixbuf sources. * pixops/pixops.c (pixops_composite_nearest): sync a small fix from 1.0 * io-xpm.c (xpm_seek_string): add fscanf error check from 1.0 Add progressive loader from 1.0 * io-tiff.c (gdk_pixbuf__tiff_image_begin_load): mem leak fixes from 1.0 tree * io-pnm.c: new version from 1.0 tree * io-jpeg.c (gdk_pixbuf__jpeg_image_load): sync from 1.0, use malloc not g_malloc * io-gif.c (lzw_read_byte): sync from 1.0, change a g_error to g_warning (gif_get_next_step): return 0 here, sync from 1.0 * gdk-pixbuf-util.c: sync email address change for Cody Russell 2000-09-11 Jeffrey Stedfast <fejj@helixcode.com> * gdk-pixbuf/io-pnm.c: Pretty much totally rewrote again because last nights code was still "broken". Should now properly handle all error conditions gracefully. 2000-09-10 Jeffrey Stedfast <fejj@helixcode.com> * gdk-pixbuf/io-pnm.c: Rewrote. 2000-09-09 Federico Mena Quintero <federico@helixcode.com> * gdk-pixbuf/pixops/pixops.c (pixops_composite_nearest): Compute the correct dest offset. 2000-08-25 Federico Mena Quintero <federico@helixcode.com> * gdk-pixbuf/io-xpm.c: #include <unistd.h> 2000-08-05 Larry Ewing <lewing@helixcode.com> * gdk-pixbuf/io-tiff.c: stop leaking context->tempname. * gdk-pixbuf/io-xpm.c: same as above. 2000-07-26 Michael Meeks <michael@helixcode.com> * gdk-pixbuf/io-jpeg.c (gdk_pixbuf__jpeg_image_load): make g_malloc a malloc. 2000-07-21 Larry Ewing <lewing@helixcode.com> * gdk-pixbuf/io-xpm.c: add a fake progressive loader so that xpm at least supports the progressive interface like the one in io-tiff.c. This should be reimplemented as an actual progressive loader. 2000-07-19 Jonathan Blandford <jrb@redhat.com> * demo/pixbuf-demo.c (update_timeout): changed scaling level to make it look better. * gdk-pixbuf/testpixbuf.c (update_timeout): Patch from michael meeks to handle errors better.
2000-10-09 17:22:20 +00:00
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.
Your eyes are bloodshot. Your eyes are bloodshot. Your mouth starts to foam. Your hands are shaking. You know your need your fix. NEED MORE ABSTRACTION! 2000-04-12 Federico Mena Quintero <federico@helixcode.com> This comes from an excellent idea by Tim Janik (timj@gtk.org) to hook to the last unref operation. * gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_set_last_unref_handler): New function to set the last unref handler for a pixbuf. (gdk_pixbuf_finalize): New function to actually finalize a pixbuf. It calls the pixbuf's destroy notification function and frees the GdkPixbuf structure itself. (gdk_pixbuf_unref): Use the last unref function of the pixbuf if available. * gdk-pixbuf/gdk-pixbuf-private.h (struct _GdkPixbuf): New fields for the last unref handler and its user data. * gdk-pixbuf/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Use g_new0() to allocate the pixbuf. * gdk-pixbuf/gdk-pixbuf-loader.c (gdk_pixbuf_loader_class_init): Fixed the call to gtk_signal_new() for the "frame_done" signal; it was not specifying the `frame' argument. * gdk-pixbuf/gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_width): Fixed docstring. (gdk_pixbuf_animation_get_height): Likewise. (gdk_pixbuf_animation_get_num_frames): Likewise. (gdk_pixbuf_animation_get_frames): Likewise. * doc/gdk-pixbuf-sections.txt: Updated with the new functions and types. * doc/tmpl/gdk-pixbuf.sgml: Added the description for GdkColorspace. * doc/tmpl/scaling.sgml: Added the description for GdkInterpType. * doc/tmpl/refcounting.sgml: Updated with the information about the last unref handler. * doc/tmpl/*.sgml: Markup tweaks. * gdk-pixbuf/Makefile.am (libgnomecanvaspixbuf_la_LDFLAGS): Sigh, update the libtool version number for libgnomecanvaspixbuf as well. (libpixbufloader_*_la_LDFLAGS): The loaders need to be versioned as well, or the old ones won't work with the new stuff. Also, renamed the modules as follows. * gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_load_module): Now the modules are called "libpixbufloader-<format>.so" instead of "libpixbuf-<format>.so". They needed renaming so that the new loaders won't overwrite the old ones; even with the versioning stuff, the new .so symlink to the .so.1.0.0 would overwrite the old real .so file.
2000-04-13 01:18:41 +00:00
</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
new pixmap.
</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>
<programlisting>
gboolean
expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
GdkPixbuf *dest;
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
Your eyes are bloodshot. Your eyes are bloodshot. Your mouth starts to foam. Your hands are shaking. You know your need your fix. NEED MORE ABSTRACTION! 2000-04-12 Federico Mena Quintero <federico@helixcode.com> This comes from an excellent idea by Tim Janik (timj@gtk.org) to hook to the last unref operation. * gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_set_last_unref_handler): New function to set the last unref handler for a pixbuf. (gdk_pixbuf_finalize): New function to actually finalize a pixbuf. It calls the pixbuf's destroy notification function and frees the GdkPixbuf structure itself. (gdk_pixbuf_unref): Use the last unref function of the pixbuf if available. * gdk-pixbuf/gdk-pixbuf-private.h (struct _GdkPixbuf): New fields for the last unref handler and its user data. * gdk-pixbuf/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Use g_new0() to allocate the pixbuf. * gdk-pixbuf/gdk-pixbuf-loader.c (gdk_pixbuf_loader_class_init): Fixed the call to gtk_signal_new() for the "frame_done" signal; it was not specifying the `frame' argument. * gdk-pixbuf/gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_width): Fixed docstring. (gdk_pixbuf_animation_get_height): Likewise. (gdk_pixbuf_animation_get_num_frames): Likewise. (gdk_pixbuf_animation_get_frames): Likewise. * doc/gdk-pixbuf-sections.txt: Updated with the new functions and types. * doc/tmpl/gdk-pixbuf.sgml: Added the description for GdkColorspace. * doc/tmpl/scaling.sgml: Added the description for GdkInterpType. * doc/tmpl/refcounting.sgml: Updated with the information about the last unref handler. * doc/tmpl/*.sgml: Markup tweaks. * gdk-pixbuf/Makefile.am (libgnomecanvaspixbuf_la_LDFLAGS): Sigh, update the libtool version number for libgnomecanvaspixbuf as well. (libpixbufloader_*_la_LDFLAGS): The loaders need to be versioned as well, or the old ones won't work with the new stuff. Also, renamed the modules as follows. * gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_load_module): Now the modules are called "libpixbufloader-<format>.so" instead of "libpixbuf-<format>.so". They needed renaming so that the new loaders won't overwrite the old ones; even with the versioning stuff, the new .so symlink to the .so.1.0.0 would overwrite the old real .so file.
2000-04-13 01:18:41 +00:00
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,
Your eyes are bloodshot. Your eyes are bloodshot. Your mouth starts to foam. Your hands are shaking. You know your need your fix. NEED MORE ABSTRACTION! 2000-04-12 Federico Mena Quintero <federico@helixcode.com> This comes from an excellent idea by Tim Janik (timj@gtk.org) to hook to the last unref operation. * gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_set_last_unref_handler): New function to set the last unref handler for a pixbuf. (gdk_pixbuf_finalize): New function to actually finalize a pixbuf. It calls the pixbuf's destroy notification function and frees the GdkPixbuf structure itself. (gdk_pixbuf_unref): Use the last unref function of the pixbuf if available. * gdk-pixbuf/gdk-pixbuf-private.h (struct _GdkPixbuf): New fields for the last unref handler and its user data. * gdk-pixbuf/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Use g_new0() to allocate the pixbuf. * gdk-pixbuf/gdk-pixbuf-loader.c (gdk_pixbuf_loader_class_init): Fixed the call to gtk_signal_new() for the "frame_done" signal; it was not specifying the `frame' argument. * gdk-pixbuf/gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_width): Fixed docstring. (gdk_pixbuf_animation_get_height): Likewise. (gdk_pixbuf_animation_get_num_frames): Likewise. (gdk_pixbuf_animation_get_frames): Likewise. * doc/gdk-pixbuf-sections.txt: Updated with the new functions and types. * doc/tmpl/gdk-pixbuf.sgml: Added the description for GdkColorspace. * doc/tmpl/scaling.sgml: Added the description for GdkInterpType. * doc/tmpl/refcounting.sgml: Updated with the information about the last unref handler. * doc/tmpl/*.sgml: Markup tweaks. * gdk-pixbuf/Makefile.am (libgnomecanvaspixbuf_la_LDFLAGS): Sigh, update the libtool version number for libgnomecanvaspixbuf as well. (libpixbufloader_*_la_LDFLAGS): The loaders need to be versioned as well, or the old ones won't work with the new stuff. Also, renamed the modules as follows. * gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_load_module): Now the modules are called "libpixbufloader-<format>.so" instead of "libpixbuf-<format>.so". They needed renaming so that the new loaders won't overwrite the old ones; even with the versioning stuff, the new .so symlink to the .so.1.0.0 would overwrite the old real .so file.
2000-04-13 01:18:41 +00:00
(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;
}
Your eyes are bloodshot. Your eyes are bloodshot. Your mouth starts to foam. Your hands are shaking. You know your need your fix. NEED MORE ABSTRACTION! 2000-04-12 Federico Mena Quintero <federico@helixcode.com> This comes from an excellent idea by Tim Janik (timj@gtk.org) to hook to the last unref operation. * gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_set_last_unref_handler): New function to set the last unref handler for a pixbuf. (gdk_pixbuf_finalize): New function to actually finalize a pixbuf. It calls the pixbuf's destroy notification function and frees the GdkPixbuf structure itself. (gdk_pixbuf_unref): Use the last unref function of the pixbuf if available. * gdk-pixbuf/gdk-pixbuf-private.h (struct _GdkPixbuf): New fields for the last unref handler and its user data. * gdk-pixbuf/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Use g_new0() to allocate the pixbuf. * gdk-pixbuf/gdk-pixbuf-loader.c (gdk_pixbuf_loader_class_init): Fixed the call to gtk_signal_new() for the "frame_done" signal; it was not specifying the `frame' argument. * gdk-pixbuf/gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_width): Fixed docstring. (gdk_pixbuf_animation_get_height): Likewise. (gdk_pixbuf_animation_get_num_frames): Likewise. (gdk_pixbuf_animation_get_frames): Likewise. * doc/gdk-pixbuf-sections.txt: Updated with the new functions and types. * doc/tmpl/gdk-pixbuf.sgml: Added the description for GdkColorspace. * doc/tmpl/scaling.sgml: Added the description for GdkInterpType. * doc/tmpl/refcounting.sgml: Updated with the information about the last unref handler. * doc/tmpl/*.sgml: Markup tweaks. * gdk-pixbuf/Makefile.am (libgnomecanvaspixbuf_la_LDFLAGS): Sigh, update the libtool version number for libgnomecanvaspixbuf as well. (libpixbufloader_*_la_LDFLAGS): The loaders need to be versioned as well, or the old ones won't work with the new stuff. Also, renamed the modules as follows. * gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_load_module): Now the modules are called "libpixbufloader-<format>.so" instead of "libpixbuf-<format>.so". They needed renaming so that the new loaders won't overwrite the old ones; even with the versioning stuff, the new .so symlink to the .so.1.0.0 would overwrite the old real .so file.
2000-04-13 01:18:41 +00:00
</programlisting>
<!-- ##### SECTION See_Also ##### -->
Your eyes are bloodshot. Your eyes are bloodshot. Your mouth starts to foam. Your hands are shaking. You know your need your fix. NEED MORE ABSTRACTION! 2000-04-12 Federico Mena Quintero <federico@helixcode.com> This comes from an excellent idea by Tim Janik (timj@gtk.org) to hook to the last unref operation. * gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_set_last_unref_handler): New function to set the last unref handler for a pixbuf. (gdk_pixbuf_finalize): New function to actually finalize a pixbuf. It calls the pixbuf's destroy notification function and frees the GdkPixbuf structure itself. (gdk_pixbuf_unref): Use the last unref function of the pixbuf if available. * gdk-pixbuf/gdk-pixbuf-private.h (struct _GdkPixbuf): New fields for the last unref handler and its user data. * gdk-pixbuf/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Use g_new0() to allocate the pixbuf. * gdk-pixbuf/gdk-pixbuf-loader.c (gdk_pixbuf_loader_class_init): Fixed the call to gtk_signal_new() for the "frame_done" signal; it was not specifying the `frame' argument. * gdk-pixbuf/gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_width): Fixed docstring. (gdk_pixbuf_animation_get_height): Likewise. (gdk_pixbuf_animation_get_num_frames): Likewise. (gdk_pixbuf_animation_get_frames): Likewise. * doc/gdk-pixbuf-sections.txt: Updated with the new functions and types. * doc/tmpl/gdk-pixbuf.sgml: Added the description for GdkColorspace. * doc/tmpl/scaling.sgml: Added the description for GdkInterpType. * doc/tmpl/refcounting.sgml: Updated with the information about the last unref handler. * doc/tmpl/*.sgml: Markup tweaks. * gdk-pixbuf/Makefile.am (libgnomecanvaspixbuf_la_LDFLAGS): Sigh, update the libtool version number for libgnomecanvaspixbuf as well. (libpixbufloader_*_la_LDFLAGS): The loaders need to be versioned as well, or the old ones won't work with the new stuff. Also, renamed the modules as follows. * gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_load_module): Now the modules are called "libpixbufloader-<format>.so" instead of "libpixbuf-<format>.so". They needed renaming so that the new loaders won't overwrite the old ones; even with the versioning stuff, the new .so symlink to the .so.1.0.0 would overwrite the old real .so file.
2000-04-13 01:18:41 +00:00
<para>
GdkRGB
</para>