Scale an image in GTK

后端 未结 6 1683
太阳男子
太阳男子 2020-12-16 13:19

In GTK, how can I scale an image? Right now I load images with PIL and scale them beforehand, but is there a way to do it with GTK?

6条回答
  •  难免孤独
    2020-12-16 13:55

    anyone doing this in C. This is how it's done

    //Assuming you already loaded the file and saved the filename //GTK_IMAGE(image) is the container used to display the image

    GdkPixbuf *pb;
    
    pb = gdk_pixbuf_new_from_file(file_name, NULL);
    pb = gdk_pixbuf_scale_simple(pb,700,700,GDK_INTERP_BILINEAR);
                gtk_image_set_from_pixbuf(GTK_IMAGE(image), pb);
    

提交回复
热议问题