Scale an image in GTK

后端 未结 6 1668
太阳男子
太阳男子 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 14:06

    Just FYI, here is a solution which scales the image based on window size (Implying you are implementing this in a class which extends GtkWindow).

    let [width, height] = this.get_size(); // Get size of GtkWindow
    this._image = new GtkImage();          
    let pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filePath,width,height,true);
    this._image.set_from_pixbuf(pixbuf);
    

提交回复
热议问题