google找到了,這裡是gnome文件說明
試了一下,把長頸鹿,疊到獅子,composite可帶透明度,scale則沒有(如下)
P2疊到P3
Pixbuf.scale(P2,P3,0, 0, 50, 50, 0, 0, 1.0, 1.0, InterpType.BILINEAR)
P2疊到P 1
Pixbuf.composite(P2, P1,0, 0, 50, 50, 0, 0, 1.0, 1.0, InterpType.BILINEAR, 127)
# main.py
# Copyright (C) 2015 yplin
#
# PIXBUF_IMAGE is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIXBUF_IMAGE is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see
from gi.repository import Gtk, GdkPixbuf, Gdk
import os, sys
from gi.repository.GdkPixbuf import Pixbuf, InterpType
#Comment the first line and uncomment the second before installing
#or making the tarball (alternatively, use project variables)
UI_FILE = "src/pixbuf_image.ui"
#UI_FILE = "/usr/local/share/pixbuf_image/ui/pixbuf_image.ui"
class GUI:
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file(UI_FILE)
self.builder.connect_signals(self)
self.image1=self.builder.get_object('image1')
self.image2=self.builder.get_object('image2')
self.image3=self.builder.get_object('image3')
window = self.builder.get_object('window')
P1= Pixbuf.new_from_file("src/logo.png")
P2 = Pixbuf.new_from_file("src/p.jpeg")
P3= Pixbuf.new_from_file("src/logo.png")
Pixbuf.scale(P2,P3,0, 0, 50, 50, 0, 0, 1.0, 1.0, InterpType.BILINEAR)
Pixbuf.composite(P2, P1,0, 0, 50, 50, 0, 0, 1.0, 1.0, InterpType.BILINEAR, 127)
self.image1.set_from_pixbuf(P1)
self.image2.set_from_pixbuf(P2)
self.image3.set_from_pixbuf(P3)
#Pixbuf.composite(P2, P1,0, 0, 50, 50, 0, 0, 1.0, 1.0, InterpType.BILINEAR, 127)
window.show_all()
def on_window_destroy(self, window):
Gtk.main_quit()
def main():
app = GUI()
Gtk.main()
if __name__ == "__main__":
sys.exit(main())
沒有留言:
張貼留言