Hi<br> I am using GTK+ to do with my application. I have a bitmap without alpha channel as my background, another bitmap with alpha channel to show above through to see the background. At first, I tried to use gdk to do this, still not succeed yet, always show only the last one gdk_draw_pixbuf invokes in the expose handler.
<br> here is my gdk sample code:<br><br>#include <gtk/gtk.h><br>#define STD_WIDTH 680<br>#define STD_HEIGHT 480<br><br>static GdkPixbuf * s_basePix;<br>static GdkPixbuf * s_homeMenuPix;<br><br>gboolean on_expose(GtkWidget * widget,
<br> GdkEventExpose * ps,<br> gpointer data)<br>{<br> GdkPixbuf * basePix;<br> GdkPixbuf * homeMenuPix;<br><br> homeMenuPix = s_homeMenuPix;<br> basePix = s_basePix;<br><br>
gdk_draw_pixbuf(widget->window, widget->style->bg_gc[GTK_STATE_NORMAL],<br> s_basePix, 0, 0, 0, 0, <br> STD_WIDTH, <br> STD_HEIGHT,<br> GDK_RGB_DITHER_NONE,
<br> 0, 0);<br><br> gdk_draw_pixbuf(widget->window, widget->style->bg_gc[GTK_STATE_NORMAL],<br> s_homeMenuPix, 0, 0, 0, 0, <br> STD_WIDTH, <br> STD_HEIGHT,
<br> GDK_RGB_DITHER_NONE,<br> 0, 0);<br><br> return FALSE;<br>}<br><br><br>int main(int argc, char * argv[])<br>{<br> GtkWidget * mainWnd = NULL;<br> GdkDrawable * pixMap = NULL;
<br> GtkWidget * img = NULL;<br> GtkWidget * box = NULL;<br> GtkWidget * button = NULL;<br> GdkBitmap * msk = NULL;<br> GdkBitmap * homeMenu = NULL;<br> GdkColormap * colorMap = NULL;
<br> GdkScreen * screen = NULL;<br><br> gtk_init(&argc, &argv);<br><br> mainWnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);<br> <br> gtk_window_set_title(GTK_WINDOW(mainWnd), "test draw...\n");
<br> <br> gtk_signal_connect(GTK_OBJECT(mainWnd), "destroy", gtk_main_quit, NULL);<br><br> img = gtk_image_new();<br> gtk_container_add(GTK_CONTAINER(mainWnd), img);<br> gtk_signal_connect(GTK_OBJECT(img),
<br> "expose-event",<br> GTK_SIGNAL_FUNC(on_expose),<br> NULL);<br><br> gtk_container_set_border_width(GTK_CONTAINER(mainWnd), 5);<br><br> gtk_widget_show_all(mainWnd);
<br><br> screen = gdk_screen_get_default();<br> colorMap = gdk_screen_get_rgba_colormap(screen);<br> if(!colorMap)<br> colorMap = gdk_screen_get_rgb_colormap(screen);<br><br> homeMenu = gdk_pixmap_create_from_xpm(mainWnd->window,
<br> &msk,<br> &mainWnd->style->bg[GTK_STATE_NORMAL],<br> "f:/homemenu.bmp");
<br> s_homeMenuPix =<br> gdk_pixbuf_get_from_drawable(s_homeMenuPix,<br> homeMenu, <br> colorMap,<br> 0, 0, 0, 0, <br> STD_WIDTH,
<br> STD_HEIGHT);<br><br> pixMap = gdk_pixmap_create_from_xpm(mainWnd->window, <br> &msk, <br> &mainWnd->style->bg[GTK_STATE_NORMAL],
<br> "f:/Sunset.bmp");<br> s_basePix =<br> gdk_pixbuf_get_from_drawable(s_basePix,<br> pixMap, <br> colorMap,
<br> 0, 0, 0, 0, <br> STD_WIDTH,<br> STD_HEIGHT);<br><br> gtk_main();<br> <br> return 0;<br>}<br><br>I have posted this to gtk maillist, but noone reply.
<br>Is there any cairo api can help me to composite pixbuf as my expect.<br>Any advice would be appreciated!<br><br><br>Laowb<br><br><br><br> <br><br><br>