diff options
author | Havoc Pennington <hp@pobox.com> | 2000-11-01 07:07:46 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2000-11-01 07:07:46 +0000 |
commit | fe9f9d03f41936fc9ace154db4904e32f2ec3304 (patch) | |
tree | b7948e3ad25559ae7b231f8e209a86687bbd927e /gdk/gdkpixbuf-drawable.c | |
parent | da5fdc1360a6002b06b0196e33e294527069a90c (diff) | |
download | gtk+-fe9f9d03f41936fc9ace154db4904e32f2ec3304.tar.gz |
New function to create a pixbuf pointing to a subregion of another pixbuf.
2000-11-01 Havoc Pennington <hp@pobox.com>
* gdk-pixbuf.c (gdk_pixbuf_new_subpixbuf): New function to create
a pixbuf pointing to a subregion of another pixbuf.
2000-11-01 Havoc Pennington <hp@pobox.com>
* gtk/gtklabel.c (gtk_label_set_attributes): Set a PangoAttrList
on a label
(gtk_label_finalize): unref the attr list if any.
* gtk/testgtk.c (create_get_image): close test on second click
(make_message_dialog): close dialog if it exists
* gdk/gdkpango.c (gdk_draw_layout): Handle rise attribute
* gdk-2.0.pc.in (Requires): Make it require gdk-pixbuf-2.0 not
gdk-pixbuf
* gtk/gtklabel.c (gtk_label_set_markup): new function to set label
from Pango markup format
(gtk_label_set_markup_with_accel): ditto but with accelerator
parsing
* gtk/gtkimage.c (gtk_image_expose): reformatting.
* gdk/gdkpixbuf-drawable.c (gdk_pixbuf_get_from_drawable): Hack to
reflect current state of GDK - use gdk_drawable_get_colormap, etc.
Check GDK_IS_WINDOW() not !GDK_IS_PIXMAP() to decide whether to
call gdk_window_get_origin().
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha):
implement GDK_PIXBUF_ALPHA_FULL
Diffstat (limited to 'gdk/gdkpixbuf-drawable.c')
-rw-r--r-- | gdk/gdkpixbuf-drawable.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c index 07175a6381..776ebe6067 100644 --- a/gdk/gdkpixbuf-drawable.c +++ b/gdk/gdkpixbuf-drawable.c @@ -1195,14 +1195,12 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, int src_width, src_height; GdkImage *image; int rowstride, bpp, alpha; - + /* General sanity checks */ g_return_val_if_fail (src != NULL, NULL); - if (GDK_IS_PIXMAP (src)) - g_return_val_if_fail (cmap != NULL, NULL); - else + if (GDK_IS_WINDOW (src)) /* FIXME: this is not perfect, since is_viewable() only tests * recursively up the Gdk parent window tree, but stops at * foreign windows or Gdk toplevels. I.e. if a window manager @@ -1219,6 +1217,17 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, g_return_val_if_fail (dest->bits_per_sample == 8, NULL); } + if (cmap == NULL) + cmap = gdk_drawable_get_colormap (src); + + if (cmap == NULL) + { + g_warning ("%s: Source drawable has no colormap; either pass " + "in a colormap, or set the colormap on the drawable " + "with gdk_drawable_set_colormap()", G_STRLOC); + return NULL; + } + /* Coordinate sanity checks */ gdk_drawable_get_size (src, &src_width, &src_height); @@ -1233,7 +1242,7 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, g_return_val_if_fail (dest_y + height <= dest->height, NULL); } - if (!GDK_IS_PIXMAP (src)) + if (GDK_IS_WINDOW (src)) { int ret; int src_xorigin, src_yorigin; @@ -1269,10 +1278,6 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, } } - /* Get the colormap if needed */ - if (!GDK_IS_PIXMAP (src)) - cmap = gdk_window_get_colormap (src); - alpha = dest->has_alpha; rowstride = dest->rowstride; bpp = alpha ? 4 : 3; |