本文整理汇总了Python中gi.repository.GdkPixbuf.Pixbuf.scale_simple方法的典型用法代码示例。如果您正苦于以下问题:Python Pixbuf.scale_simple方法的具体用法?Python Pixbuf.scale_simple怎么用?Python Pixbuf.scale_simple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.GdkPixbuf.Pixbuf
的用法示例。
在下文中一共展示了Pixbuf.scale_simple方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_thumbnail_to_image
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import scale_simple [as 别名]
def set_thumbnail_to_image(self, image_to_use):
try:
loader = PixbufLoader()
loader.write(image_to_use)
loader.close()
thumbnail = loader.get_pixbuf()
h = thumbnail.get_height()
w = thumbnail.get_width()
r = h/w # Preserve Aspect Ratio
pixbuf = Pixbuf.scale_simple(thumbnail, cover_width, cover_width*r, True)
self.thumbnail = pixbuf
return True
except Exception:
print(Exception)
return False
示例2: addPages
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import scale_simple [as 别名]
def addPages(self, issue):
zf = zipfile.ZipFile(issue.containing_directory + "/" + issue.file)
for file_in_zip in zf.namelist():
if ".jpg" in file_in_zip.lower() or ".png" in file_in_zip.lower():
print(file_in_zip)
loader = PixbufLoader()
loader.write(zf.read(file_in_zip))
loader.close()
thumbnail = loader.get_pixbuf()
h = thumbnail.get_height()
w = thumbnail.get_width()
r = h/w # Preserve Aspect Ratio
windowwidth= self.get_size()[0]
pixbuf = Pixbuf.scale_simple(thumbnail, windowwidth, windowwidth*r, True)
self.get_child().get_child().get_child().add(Gtk.Image.new_from_pixbuf(pixbuf))
示例3: set_image
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import scale_simple [as 别名]
def set_image(self, filename):
Gtk.Window.set_title(self, filename)
self.remove(self.image)
pb = Pixbuf.new_from_file(filename)
iw = Pixbuf.get_width(pb)
ih = Pixbuf.get_height(pb)
ar = (float)(iw) / ih
(w, h) = Gtk.Window.get_size(self)
if iw > ih:
nw = w
nh = (int)(nw / ar)
else:
nh = h
nw = (int)(nh * ar)
pb2 = Pixbuf.scale_simple(pb, nw, nh, InterpType.BILINEAR)
self.image.set_from_pixbuf(pb2)
self.add(self.image)