Re: gdk_draw_drawable on a non-active widget window

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 16 Dec 2008 11:43:30 +0300, zaheer ahmad <zaheer.mot@xxxxxxxxx> wrote:

hi,

iam trying to take the snapshot of a widget window in a pixmap using
gdk_draw_drawable, however it seems to work only if the widget is active
(visible on the screen).

as i understand, this process involves a peek on to the x and that may mean
that the data for the inactive window may not be available.

can somebody confirm on this and also if there is any other means to get
access to pixmaps of inactive windows

thanks,
Zaheer

My suggestion:

void save_picture_to_file(GtkWidget *da, char *filename)
{
        GdkRectangle exposed_area;
        exposed_area.x = da->allocation.x;
        exposed_area.y = da->allocation.y;
        exposed_area.width = da->allocation.width;
        exposed_area.height = da->allocation.height;

        GdkPixmap *pixmap = gtk_widget_get_snapshot(da, &exposed_area);
        GdkColormap *cmap = gdk_colormap_get_system();
        GdkPixbuf *pixbuf = gdk_pixbuf_get_from_drawable(
                NULL,
                pixmap,
                cmap,
                0, 0,
                exposed_area.x,
                exposed_area.y,
                exposed_area.width,
                exposed_area.height);

        GError * error = NULL;

        gdk_pixbuf_save(pixbuf, filename, "png", &error, NULL);

        if (error)
        {
                printf("Error saving image: %s\n", error->message);
                g_error_free(error);
        }

        g_object_unref (pixbuf);
        gdk_pixmap_unref(pixmap);
        gdk_colormap_unref(cmap);
}


--
Vyacheslav D.
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux