diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-09-19 20:13:16 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-09-19 20:13:16 +0000 |
commit | 32b708985d90a2fc62aa826dd3d54e4ec21e44ea (patch) | |
tree | 209415b1203f66cdab873ef71399c71902f4092b /gdk | |
parent | de24d6cd79d59bb7a085868cff54af557791ee37 (diff) | |
download | gdk-pixbuf-32b708985d90a2fc62aa826dd3d54e4ec21e44ea.tar.gz |
Allow -1 for width/height to mean "width/height of pixbuf" (Patch from
Wed Sep 19 16:12:16 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkpixbuf-render.c: Allow -1 for width/height
to mean "width/height of pixbuf" (Patch from Matthias Clasen,
#59723)
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdkpixbuf-render.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/gdk/gdkpixbuf-render.c b/gdk/gdkpixbuf-render.c index 5a534be73..23c75121b 100644 --- a/gdk/gdkpixbuf-render.c +++ b/gdk/gdkpixbuf-render.c @@ -35,8 +35,8 @@ * @src_y: source Y coordinate. * @dest_x: Destination X coordinate. * @dest_y: Destination Y coordinate. - * @width: Width of region to threshold. - * @height: Height of region to threshold. + * @width: Width of region to threshold, or -1 to use pixbuf width + * @height: Height of region to threshold, or -1 to use pixbuf height * @alpha_threshold: Opacity values below this will be painted as zero; all * other values will be painted as one. * @@ -60,11 +60,16 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, int start, start_status; int status; - g_return_if_fail (pixbuf != NULL); + 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); + if (width == -1) + width = pixbuf->width; + if (height == -1) + height = pixbuf->height; + g_return_if_fail (bitmap != NULL); g_return_if_fail (width >= 0 && height >= 0); g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width); @@ -139,8 +144,8 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, * @src_y: Source Y coordinate within pixbuf. * @dest_x: Destination X coordinate within drawable. * @dest_y: Destination Y coordinate within drawable. - * @width: Width of region to render, in pixels. - * @height: Height of region to render, in pixels. + * @width: Width of region to render, in pixels, or -1 to use pixbuf width + * @height: Height of region to render, in pixels, or -1 to use pixbuf height * @dither: Dithering mode for GdkRGB. * @x_dither: X offset for dither. * @y_dither: Y offset for dither. @@ -171,7 +176,7 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, int rowstride; guchar *buf; - g_return_if_fail (pixbuf != NULL); + 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); @@ -179,6 +184,11 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, g_return_if_fail (drawable != NULL); g_return_if_fail (gc != 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); @@ -225,8 +235,8 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf, * @src_y: Source Y coordinates within pixbuf. * @dest_x: Destination X coordinate within drawable. * @dest_y: Destination Y coordinate within drawable. - * @width: Width of region to render, in pixels. - * @height: Height of region to render, in pixels. + * @width: Width of region to render, in pixels, or -1 to use pixbuf width. + * @height: Height of region to render, in pixels, or -1 to use pixbuf height. * @alpha_mode: If the image does not have opacity information, this is ignored. * Otherwise, specifies how to handle transparency when rendering. * @alpha_threshold: If the image does have opacity information and @alpha_mode @@ -271,12 +281,18 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkRegion *drect; GdkRectangle tmp_rect; - g_return_if_fail (pixbuf != NULL); + 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); |