summaryrefslogtreecommitdiff
path: root/gdk/gdkpixbuf-render.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-01-17 01:48:21 +0000
committerArturo Espinosa <unammx@src.gnome.org>2000-01-17 01:48:21 +0000
commit4f0f733060a0644a7d10b646b6b0868ee2d13ba8 (patch)
treef394ab7079c39415000cf096462f2f0b43b8f064 /gdk/gdkpixbuf-render.c
parentef80871e0aecfdc81495eb45589f28864bee4494 (diff)
downloadgdk-pixbuf-4f0f733060a0644a7d10b646b6b0868ee2d13ba8.tar.gz
Removed the broken --enable-canvas-pixbuf option. Added the stuff
2000-01-16 Federico Mena Quintero <federico@helixcode.com> * configure.in: Removed the broken --enable-canvas-pixbuf option. Added the stuff necessary to substitute the variables in gnomecanvaspixbufConf.sh.in. * gnomecanvaspixbufConf.sh.in: New gnome-config handler for the tiny gnomecanvaspixbuf library. * Makefile.am: Build gnomecanvaspixbufConf.sh. * gdk-pixbuf/Makefile.am: Create a libgnomecanvaspixbuf and only build it if gdk-pixbuf is being built outside of gnome-libs. * doc/gdk-pixbuf-sections.txt: Added gdk_pixbuf_render_pixmap_and_mask(). * gdk-pixbuf/gdk-pixbuf-render.c (gdk_pixbuf_render_pixmap_and_mask): Renamed from gdk_pixbuf_render_pixmap(). Do not create the mask if it is not needed, and do not use a clipping mask when rendering the pixmap. Tweaked documentation a little. * HACKING: New file with hacking policies for the gdk-pixbuf module. * doc/Makefile.am (tmpl_sources): Added missing backslash. * doc/Makefile.am: Use gnomecanvaspixbuf in gnome-config when scanning for docstrings. * gdk-pixbuf/gdk-pixbuf-util.c (gdk_pixbuf_copy_area): Made sanity checks more stringent. Removed "gint" abominations. Made documentation consistent with the rest of the functions. * doc/gdk-pixbuf-sections.txt: Added gdk_pixbuf_copy_area() to the utilities section.
Diffstat (limited to 'gdk/gdkpixbuf-render.c')
-rw-r--r--gdk/gdkpixbuf-render.c104
1 files changed, 42 insertions, 62 deletions
diff --git a/gdk/gdkpixbuf-render.c b/gdk/gdkpixbuf-render.c
index 5496aeb5d..742e49c4c 100644
--- a/gdk/gdkpixbuf-render.c
+++ b/gdk/gdkpixbuf-render.c
@@ -170,7 +170,7 @@ remove_alpha (ArtPixBuf *apb, int x, int y, int width, int height, int *rowstrid
* @dither: Dithering mode for GdkRGB.
* @x_dither: X offset for dither.
* @y_dither: Y offset for dither.
- *
+ *
* Renders a rectangular portion of a pixbuf to a drawable while using the
* specified GC. This is done using GdkRGB, so the specified drawable must have
* the GdkRGB visual and colormap. Note that this function will ignore the
@@ -199,7 +199,7 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
g_return_if_fail (pixbuf != NULL);
apb = pixbuf->art_pixbuf;
-
+
g_return_if_fail (apb->format == ART_PIX_RGB);
g_return_if_fail (apb->n_channels == 3 || apb->n_channels == 4);
g_return_if_fail (apb->bits_per_sample == 8);
@@ -321,69 +321,49 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
}
/**
- * gdk_pixbuf_render_pixmap:
+ * gdk_pixbuf_render_pixmap_and_mask:
* @pixbuf: A pixbuf
- * @pixmap: A pointer to a pixmap to fill in.
- * @mask_retval: A pointer to the mask to be filled in.
- * @alpha_threshold: Specifies the threshold value for opacity
- * values if the pixbuf has opacity.
+ * @pixmap_return: Return value for the created pixmap.
+ * @mask_return: Return value for the created mask.
+ * @alpha_threshold: Threshold value for opacity values.
*
- * Generates a #GdkPixmap from a #GdkPixbuf, along with an optional mask. The
- * alpha threshold can be used to determine how the mask is created, if the
- * pixbuf has an alpha channel. This function is mainly provided for
- * compatibility reasons, as you will rarely want a #GdkPixmap.
- *
+ * 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().
**/
void
-gdk_pixbuf_render_pixmap (GdkPixbuf *pixbuf,
- GdkPixmap **pixmap,
- GdkBitmap **mask_retval,
- gint alpha_threshold)
+gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
+ GdkPixmap **pixmap_return, GdkBitmap **mask_return,
+ int alpha_threshold)
{
- GdkBitmap *mask = NULL;
-
- g_return_if_fail(pixbuf != NULL);
-
- /* generate mask */
- if (gdk_pixbuf_get_has_alpha(pixbuf)) {
- mask = gdk_pixmap_new(NULL,
- gdk_pixbuf_get_width(pixbuf),
- gdk_pixbuf_get_height(pixbuf),
- 1);
-
- gdk_pixbuf_render_threshold_alpha(pixbuf, mask,
- 0, 0, 0, 0,
- gdk_pixbuf_get_width(pixbuf),
- gdk_pixbuf_get_height(pixbuf),
- alpha_threshold);
- }
-
- /* Draw to pixmap */
- if (pixmap != NULL) {
- GdkGC* gc;
-
- *pixmap = gdk_pixmap_new(NULL,
- gdk_pixbuf_get_width(pixbuf),
- gdk_pixbuf_get_height(pixbuf),
- gdk_rgb_get_visual()->depth);
-
- gc = gdk_gc_new(*pixmap);
-
- gdk_gc_set_clip_mask(gc, mask);
-
- gdk_pixbuf_render_to_drawable(pixbuf, *pixmap,
- 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);
- }
-
- if (mask_retval)
- *mask_retval = mask;
- else
- gdk_bitmap_unref(mask);
+ ArtPixBuf *apb;
+
+ g_return_if_fail (pixbuf != NULL);
+
+ apb = pixbuf->art_pixbuf;
+
+ if (pixmap_return) {
+ GdkGC *gc;
+
+ *pixmap_return = gdk_pixmap_new (NULL, apb->width, apb->height,
+ gdk_rgb_get_visual ()->depth);
+ gc = gdk_gc_new (*pixmap_return);
+ gdk_pixbuf_render_to_drawable (pixbuf, *pixmap_return, gc,
+ 0, 0, 0, 0,
+ apb->width, apb->height,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+ gdk_gc_unref (gc);
+ }
+
+ if (mask_return) {
+ *mask_return = gdk_pixmap_new (NULL, apb->width, apb->height, 1);
+ gdk_pixbuf_render_threshold_alpha (pixbuf, *mask_return,
+ 0, 0, 0, 0,
+ apb->width, apb->height,
+ alpha_threshold);
+ }
}