#include <gtk/gtk.h>
#include <stdio.h>
#include <gdk/gdk.h>
#include <gdk_imlib.h>
int main(int argc, char *argv[]){
GtkWidget *mainwindow;
GdkImlibImage *im;
GdkPixmap *pixmap;
gint nheight,nwidth;
GdkBitmap *mask;
GdkWindow *win;
gtk_init(&argc,&argv);
gdk_imlib_init();
gtk_widget_push_visual(gdk_imlib_get_visual());
gtk_widget_push_colormap(gdk_imlib_get_colormap());
im=gdk_imlib_load_image("test.png");
if(!im){
fprintf(stderr,"Couldn't load image");
throw;
}
nwidth=im->rgb_width;
nheight=im->rgb_height;
fprintf(stderr,"width: %d height: %d\n", nwidth,nheight);
gdk_imlib_render(im,nwidth,nheight); //nwidth,nheight);
mask = gdk_imlib_move_mask(im);
pixmap = gdk_imlib_move_image(im);
mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_app_paintable(mainwindow,TRUE);
gtk_window_set_title(GTK_WINDOW(mainwindow),"mainwindow");
gtk_window_set_policy(GTK_WINDOW(mainwindow),FALSE,FALSE,FALSE);
gtk_widget_realize(mainwindow);
gdk_window_set_back_pixmap(mainwindow->window,pixmap,0);
gdk_window_shape_combine_mask(mainwindow->window,mask,0,0);
gdk_window_set_decorations(mainwindow->window,(GdkWMDecoration)0);
gtk_widget_set_usize(mainwindow,nwidth,nheight); //500,500);
gtk_widget_show(mainwindow);
gtk_main();
return 0;
} |