X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gdk%2Fgdkpixbuf-render.c;h=2904e712f134f16aaa84087514704dc431e47ebd;hb=2e098756c1717e9e0e735ee7ea77cbaeba463550;hp=98d0b62e9c7b5bad9a4fec6ab4ea8934413bdc20;hpb=e8468d5e6d5d76d0068d4800f951a52cf6390a27;p=~andy%2Fgtk diff --git a/gdk/gdkpixbuf-render.c b/gdk/gdkpixbuf-render.c index 98d0b62e9..2904e712f 100644 --- a/gdk/gdkpixbuf-render.c +++ b/gdk/gdkpixbuf-render.c @@ -22,10 +22,11 @@ #include #include -#include "gdkinternals.h" /* _gdk_draw_pixbuf() */ #include "gdk-pixbuf-private.h" #include "gdkpixbuf.h" #include "gdkscreen.h" +#include "gdkinternals.h" +#include "gdkalias.h" @@ -82,14 +83,13 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, if (width == 0 || height == 0) return; - gc = gdk_gc_new (bitmap); + gc = _gdk_drawable_get_scratch_gc (bitmap, FALSE); if (!pixbuf->has_alpha) { color.pixel = (alpha_threshold == 255) ? 0 : 1; gdk_gc_set_foreground (gc, &color); gdk_draw_rectangle (bitmap, gc, TRUE, dest_x, dest_y, width, height); - gdk_gc_unref (gc); return; } @@ -131,8 +131,6 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, start + dest_x, y + dest_y, x - 1 + dest_x, y + dest_y); } - - gdk_gc_unref (gc); } @@ -164,6 +162,8 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, * 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. + * + * Deprecated: 2.4: This function is obsolete. Use gdk_draw_pixbuf() instead. **/ void gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, @@ -175,28 +175,9 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, GdkRgbDither dither, int x_dither, int y_dither) { - g_return_if_fail (GDK_IS_PIXBUF (pixbuf)); - g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB); - g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4); - g_return_if_fail (pixbuf->bits_per_sample == 8); - - g_return_if_fail (drawable != NULL); - - if (width == -1) - width = pixbuf->width; - if (height == -1) - height = pixbuf->height; - - g_return_if_fail (width >= 0 && height >= 0); - g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width); - g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height); - - if (width == 0 || height == 0) - return; - - _gdk_draw_pixbuf (drawable, gc, pixbuf, - src_x, src_y, dest_x, dest_y, width, height, - dither, x_dither, y_dither); + gdk_draw_pixbuf (drawable, gc, pixbuf, + src_x, src_y, dest_x, dest_y, width, height, + dither, x_dither, y_dither); } @@ -219,11 +200,13 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, * * Renders a rectangular portion of a pixbuf to a drawable. The destination * drawable must have a colormap. All windows have a colormap, however, pixmaps - * only have colormap by default if they were created with a non-NULL window argument. + * only have colormap by default if they were created with a non-%NULL window argument. * Otherwise a colormap must be set on them with gdk_drawable_set_colormap. * * On older X servers, rendering pixbufs with an alpha channel involves round trips * to the X server, and may be somewhat slow. + * + * Deprecated: 2.4: This function is obsolete. Use gdk_draw_pixbuf() instead. **/ void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, @@ -236,32 +219,33 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkRgbDither dither, int x_dither, int y_dither) { - _gdk_draw_pixbuf (drawable, NULL, pixbuf, - src_x, src_y, dest_x, dest_y, width, height, - dither, x_dither, y_dither); + gdk_draw_pixbuf (drawable, NULL, pixbuf, + src_x, src_y, dest_x, dest_y, width, height, + dither, x_dither, y_dither); } /** * gdk_pixbuf_render_pixmap_and_mask: * @pixbuf: A pixbuf. - * @pixmap_return: Return value for the created pixmap. - * @mask_return: Return value for the created mask. + * @pixmap_return: Location to store a pointer to the created pixmap, + * or %NULL if the pixmap is not needed. + * @mask_return: Location to store a pointer to the created mask, + * or %NULL if the mask is not needed. * @alpha_threshold: Threshold value for opacity values. * * Creates a pixmap and a mask bitmap which are returned in the @pixmap_return * and @mask_return arguments, respectively, and renders a pixbuf and its * corresponding thresholded 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 gdk_pixbuf_render_to_drawable_alpha() or - * gdk_pixbuf_render_to_drawable(), and gdk_pixbuf_render_threshold_alpha(). + * given drawables should use gdk_draw_pixbuf() and gdk_pixbuf_render_threshold_alpha(). * * The pixmap that is created is created for the colormap returned * by gdk_rgb_get_colormap(). You normally will want to instead use * the actual colormap for a widget, and use - * gdk_pixbuf_render_pixmap_and_mask_for_colormap. + * gdk_pixbuf_render_pixmap_and_mask_for_colormap(). * * If the pixbuf does not have an alpha channel, then *@mask_return will be set - * to NULL. + * to %NULL. **/ void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf, @@ -279,23 +263,24 @@ gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf, * gdk_pixbuf_render_pixmap_and_mask_for_colormap: * @pixbuf: A pixbuf. * @colormap: A #GdkColormap - * @pixmap_return: Return value for the created pixmap. - * @mask_return: Return value for the created mask. + * @pixmap_return: Location to store a pointer to the created pixmap, + * or %NULL if the pixmap is not needed. + * @mask_return: Location to store a pointer to the created mask, + * or %NULL if the mask is not needed. * @alpha_threshold: Threshold value for opacity values. * * Creates a pixmap and a mask bitmap which are returned in the @pixmap_return * and @mask_return 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 gdk_pixbuf_render_to_drawable_alpha() or - * gdk_pixbuf_render_to_drawable(), and gdk_pixbuf_render_threshold_alpha(). + * given drawables should use gdk_draw_pixbuf(), and gdk_pixbuf_render_threshold_alpha(). * * The pixmap that is created uses the #GdkColormap specified by @colormap. * This colormap must match the colormap of the window where the pixmap * will eventually be used or an error will result. * * If the pixbuf does not have an alpha channel, then *@mask_return will be set - * to NULL. + * to %NULL. **/ void gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf, @@ -319,13 +304,12 @@ gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf, gdk_colormap_get_visual (colormap)->depth); gdk_drawable_set_colormap (GDK_DRAWABLE (*pixmap_return), colormap); - gc = gdk_gc_new (*pixmap_return); - gdk_pixbuf_render_to_drawable (pixbuf, *pixmap_return, gc, - 0, 0, 0, 0, - gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), - GDK_RGB_DITHER_NORMAL, - 0, 0); - gdk_gc_unref (gc); + gc = _gdk_drawable_get_scratch_gc (*pixmap_return, FALSE); + gdk_draw_pixbuf (*pixmap_return, gc, pixbuf, + 0, 0, 0, 0, + gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), + GDK_RGB_DITHER_NORMAL, + 0, 0); } if (mask_return) @@ -344,3 +328,7 @@ gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf, *mask_return = NULL; } } + +#define __GDK_PIXBUF_RENDER_C__ +#include "gdkaliasdef.c" +