Re: how can I display jpeg pictures in my gtk applications using jpeg-6b?



On Thursday 31 May 2001 12:44 am, Zou xiaojun wrote:
Hi,

Where can I find any samples about using jpeg in gtk?

Who can give me a hint ? Thanks
I'm doing that right now, actually. With at least 1.2.8 (you might have it
earlier, but I don't know) you can use GdkPixbuf, which I found easier than 
imlib. Try something like this:

<code>
GdkPixbuf *buffer = gdk_pixbuf_new_from_file(imgeFileName);
GdkPixmap *newPixmap = gdk_pixmap_new(NULL, someWidth, someHeight, 
        gdk_visual_get_best_depth() );
GdkGC *gc = gdk_gc_new(newPixmap);

gdk_pixbuf_render_to_drawable(buffer, newPixmap, gc, 0, 0, 0, 0, someWidth,
        someHeight, GDK_RGB_DITHER_NONE, 0, 0);

gdk_gc_destroy(gc);
gdk_pixbuf_unref(buffer);
</code>

You can then use that pixmap on a whole manner of widgets. I just used the 
GtkPixmap, which _really_ simple.

[oops... didn't realize I needed to change the 'to:']

faboo
-- 
"and fuck moments                       "If there's another life,
I want an hour to once again be         And if I get to choose,
a long time."                           I'd like to be a daisy."
        -Out Loud,                              -Greening of America,
        Tim Mason                               Counting Crows




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