Re: minor fix for GdkPixbuf
- From: Havoc Pennington <hp redhat com>
- To: Ramiro Estrugo <ramiro fateware com>
- Cc: Tim Janik <timj gtk org>, Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: minor fix for GdkPixbuf
- Date: 28 Jun 2001 02:45:06 -0400
Havoc Pennington <hp redhat com> writes:
> Owen was suggesting that we actually put the grab in gdk_image_get()
> itself though - if the grab doesn't seem to matter for speed that's
> probably feasible.
>
This is a bit more complicated than I thought -
- you can't do the grab/clip-to-screen in pixbuf_from_drawable()
because you don't know there if you're getting from the
window or the backing store
- you can't do the grab/clip-to-screen in _gdk_x11_get_image()
because the caller does not know the position of the returned
(smaller-than-expected) image in source drawable coordinates
- ditto for gdk_drawable_get_image()
I believe we really want to clip in gdk_x11_get_image(). I can add a
gruesome private hack to get the location of the returned image in
source drawable coordinates back to pixbuf_get_from_drawable(), by way
of gdk_drawable_get_image().
However anyone else using gdk_drawable_get_image() also needs this
information, it really should not be private.
I'm considering two possible solutions.
Solution #1 is to just change gdk_drawable_get_image() since it's a
new function anyway, maybe something like:
GdkImage*
gdk_drawable_get_image (GdkDrawable *drawable,
gint x,
gint y,
gint width,
gint height,
GdkRectangle *retrieved_area);
Or is that terrible? You can pass NULL for retrieved_area, and
get_image is a fairly low-level thing anyway.
What do we do with gdk_image_get(), free the image and return NULL if
gotten_image->width != requested_width, etc.?
Solution #2 I'm considering is to change _gdk_x11_get_image() to first
create the image with XCreateImage(), then use XGetSubImage() to copy
in the clipped-to-screen area of the window. So we always return an
image of the requested size, but leave parts of it undefined if they
are offscreen.
I like this solution best, because it's the same behavior as for
gdk_pixbuf_get_from_drawable(), and is likely what people usually
want. Also it avoids any possible breakage for people using
gdk_image_get() in legacy code.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]