Re: picture slide show flicker and previous image flush problem



2011/5/11 Jerry Wang <jerry wang beonic com>:
> Hi guys,
>
> I wrote some code with GTK lib to show the image consequently and here
> is my situation.
>
>        use pixbuf to get data from files:
>        -pixbuf=gdk_pixbuf_new_from_file(filename, NULL);
>
>        use pixmap to get the mask (for transparent consideration):
>        -mask=gdk_pixmap_new(NULL, width, height, 1);
>        -gdk_pixbuf_render_threshold_alpha(pixbuf, mask, 0, 0,
>        0, 0, width, height, 1)
>
>        then combine the mask with shown window:
>        gdk_window_shape_combine_mask(window->window, mask, 0, 0);
>
>        and crate the image from pixbuf:
>        -image=gtk_image_new_from_pixbuf(pixbuf);
>
>        then add to window:
>        gtk_container_add((GtkContainer*)window, image);
>
>
>        before every image loading, remove the old one
>        gtk_container_remove((GtkContainer*)window, image);
>
> My images are around 2M high definition PNG files. And my running
> machine is a ATOM N270 1.6G. Every image will take about 0.3s to load.
>
> My problem is, there are one totally transparent image in my image
> files. After showing the total transparent image, before pop out the
> next image, it will show the previous image (before the transparent
> image) for a very short of time, just like flushing the buffer.

I'm not sure it is the cause of the problem, but using adding a new
widget to the hierarchy for every image seems like a wrong approach. A
better way would be to use Cairo to draw the pixbufs directly in the
draw event of a widget, for example a GtkDrawingArea.

This would require some rewriting of the code, but you gain a lot of
flexibility, like e.g. the possibility for crossfading. Make sure you
don't actually load the pixbuf in the draw(expose) event, but only do
the gdk_cairo_set_source_pixbuf(), cairo_paint() there.

> I was considering the root cause is double buffering. But if I disable
> the double buffering feature, the slide show will not be smooth, it
> looks flick.
>
> Also I try to disable the X's double buffer extension, but still see
> previous image.
>
> Need advice.
>
> Thanks,
> Jerry

Maarten


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