Re: Re: [gdk] How use gdk-pixbuf...



GdkPixmap *pixmap;
GdkPixbuf   *pixbuf;
GdkGC *gc;
pixbuf = ....
pixmap = gdk_pixbuf_new(NULL,
                                          gdk_pixbuf_get_width(pixbuf),
                                          gdk_pixbuf_get_height(pixbuf),
                                          gdk_pixbuf_get_bits_per_sample(pixbuf));
gc = gdk_gc_new(GDK_DRAWABLE(pixmap));

gdk_draw_pixbuf(GDK_DRAWABLE(pixmap),
                             gc,
                             0, 0,
                             0, 0,
                             gdk_pixbuf_get_width(pixbuf),
                             gdk_pixbuf_get_height(pixbuf),
                             GDK_RGB_DITHER_NONE, /* Is it possible to use 24 bits */
                             0, 0); /* And what is dither? */
g_object_unref(G_OBJECT(pixbuf));
/* draw */

if you're planning on working with Pixmaps I recommend doing the following:

GdkPixbuf *pixbuf;
GdkPixmap *pixmap;

pixbuf = ...
gdk_pixbuf_render_pixmap_and_mask( pixbuf, &pixmap, NULL, 1 );
gdk_pixbuf_unref( pixbuf );

this will get you your pixmap from the pixbuf.

The commands I gave you is if you plan on making drawables straight
from the pixbuf.

As for the GDK_RGB_DITHER and what dither is, I'm not too sure. I only
started using GTK like a 2 weeks ago or so.

And why GdkPixbuf isn't a drawable I'm not too sure either.

I hope that helps,

Michal



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