使用GDK的函式庫從檔案讀取圖片
放一下 簡單的code 作個備份
#include
#include
#include
int main(int argc, char**argv)
{
GtkWidget *window;
GtkWidget *frame;
GdkPixbuf *pixbuf;
GtkWidget *img;
gtk_init(&argc, &argv);
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
pixbuf = NULL;
pixbuf = gdk_pixbuf_new_from_file("test00.jpg",GError);
img = gtk_image_new_from_pixbuf(pixbuf);
gtk_container_add(GTK_CONTAINER(window),img);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
--
#include
#include
#include
int main(int argc, char**argv)
{
GtkWidget *window;
GtkWidget *frame;
GdkPixbuf *pixbuf;
GtkWidget *img;
gtk_init(&argc, &argv);
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
pixbuf = NULL;
pixbuf = gdk_pixbuf_new_from_file("test00.jpg",GError);
img = gtk_image_new_from_pixbuf(pixbuf);
gtk_container_add(GTK_CONTAINER(window),img);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
--
應該要直接用 GdkPixbuf
回覆刪除