- 论坛徽章:
- 0
|
GtkWidget *image;
GdkPixbuf *pixbuf;
char *data;
int width,height,stride,bpp;
cairo_t *cr;
cairo_surface_t *surface;
image = gtk_image_new_from_file("f11.bmp");
pixbuf = gtk_image_get_pixbuf(image);
data = gdk_pixbuf_get_pixels(pixbuf);
width = gdk_pixbuf_get_width(pixbuf);
height = gdk_pixbuf_get_height(pixbuf);
stride = gdk_pixbuf_get_rowstride(pixbuf);
bpp = gdk_pixbuf_get_bits_per_sample(pixbuf);
dprintk("width=%d,height=%d,stride=%d,bpp=%d\n",width,height,stride,bpp);
cr = gdk_cairo_create(wbus->drawingarea->window);
surface = cairo_image_surface_create_for_data(data,CAIRO_FORMAT_A8,width,height,stride);
cairo_set_source_surface (cr, surface, 100, 300);
cairo_paint_with_alpha(cr,1);
//cairo_paint(cr);
cairo_destroy(cr);
cairo_surface_destroy(surface);
gtk_widget_destroy(image); |
|