本文整理汇总了Python中quodlibet.qltk.image.get_surface_for_pixbuf函数的典型用法代码示例。如果您正苦于以下问题:Python get_surface_for_pixbuf函数的具体用法?Python get_surface_for_pixbuf怎么用?Python get_surface_for_pixbuf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_surface_for_pixbuf函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: do_draw
def do_draw(self, cairo_context):
pixbuf = self._get_pixbuf()
if not pixbuf:
return
alloc = self.get_allocation()
width, height = alloc.width, alloc.height
scale_factor = self.get_scale_factor()
width *= scale_factor
height *= scale_factor
if self._path:
if width < (2 * scale_factor) or height < (2 * scale_factor):
return
pixbuf = scale(
pixbuf, (width - 2 * scale_factor, height - 2 * scale_factor))
pixbuf = add_border_widget(pixbuf, self)
else:
pixbuf = scale(pixbuf, (width, height))
style_context = self.get_style_context()
surface = get_surface_for_pixbuf(self, pixbuf)
Gtk.render_icon_surface(style_context, cairo_context, surface, 0, 0)
开发者ID:zsau,项目名称:quodlibet,代码行数:26,代码来源:cover.py
示例2: _no_cover
def _no_cover(self):
"""Returns a cairo surface representing a missing cover"""
cover_size = get_cover_size()
scale_factor = self.get_scale_factor()
pb = get_no_cover_pixbuf(cover_size, cover_size, scale_factor)
return get_surface_for_pixbuf(self, pb)
开发者ID:urielz,项目名称:quodlibet,代码行数:7,代码来源:main.py
示例3: cell_data_pb
def cell_data_pb(column, cell, model, iter_, data):
album = model.get_album(iter_)
if album is None:
cell.set_property('icon-name', Icons.FOLDER)
else:
cover = get_scaled_cover(album)
if cover:
cover = add_border_widget(cover, view)
surface = get_surface_for_pixbuf(self, cover)
cell.set_property("surface", surface)
else:
cell.set_property('icon-name', Icons.MEDIA_OPTICAL)
开发者ID:faubiguy,项目名称:quodlibet,代码行数:12,代码来源:main.py
示例4: __scale_pixbuf
def __scale_pixbuf(self, *data):
if not self.current_pixbuf:
return
pixbuf = self.current_pixbuf
if self.window_fit.get_active():
alloc = self.scrolled.get_allocation()
width = alloc.width
height = alloc.height
scale_factor = self.get_scale_factor()
boundary = (width * scale_factor, height * scale_factor)
pixbuf = scale(pixbuf, boundary, scale_up=False)
surface = get_surface_for_pixbuf(self, pixbuf)
self.image.set_from_surface(surface)
开发者ID:urielz,项目名称:quodlibet,代码行数:15,代码来源:albumart.py
示例5: __init__
def __init__(self, title, fileobj, parent):
super(BigCenteredImage, self).__init__(type=Gtk.WindowType.POPUP)
self.set_type_hint(Gdk.WindowTypeHint.TOOLTIP)
assert parent
parent = qltk.get_top_parent(parent)
self.set_transient_for(parent)
if qltk.is_wayland():
# no screen size with wayland, the parent window is
# the next best thing..
width, height = parent.get_size()
width = int(width / 1.1)
height = int(height / 1.1)
else:
width = int(Gdk.Screen.width() / 1.75)
height = int(Gdk.Screen.height() / 1.75)
self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
scale_factor = self.get_scale_factor()
pixbuf = None
try:
pixbuf = pixbuf_from_file(fileobj, (width, height), scale_factor)
except GLib.GError:
pass
# failed to load, abort
if not pixbuf:
self.destroy()
return
image = Gtk.Image()
image.set_from_surface(get_surface_for_pixbuf(self, pixbuf))
event_box = Gtk.EventBox()
event_box.add(image)
frame = Gtk.Frame()
frame.set_shadow_type(Gtk.ShadowType.OUT)
frame.add(event_box)
self.add(frame)
event_box.connect('button-press-event', self.__destroy)
event_box.connect('key-press-event', self.__destroy)
self.get_child().show_all()
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:48,代码来源:cover.py
示例6: cell_data_pb
def cell_data_pb(column, cell, model, iter_, no_cover):
item = model.get_value(iter_)
if item.album is None:
surface = None
elif item.cover:
pixbuf = item.cover
pixbuf = add_border_widget(pixbuf, self.view)
surface = get_surface_for_pixbuf(self, pixbuf)
# don't cache, too much state has an effect on the result
self.__last_render_surface = None
else:
surface = no_cover
if self.__last_render_surface == surface:
return
self.__last_render_surface = surface
cell.set_property("surface", surface)
开发者ID:urielz,项目名称:quodlibet,代码行数:18,代码来源:main.py
示例7: __add_cover_to_list
def __add_cover_to_list(self, cover):
try:
pbloader = GdkPixbuf.PixbufLoader()
pbloader.write(get_url(cover['thumbnail'])[0])
pbloader.close()
scale_factor = self.get_scale_factor()
size = self.THUMB_SIZE * scale_factor - scale_factor * 2
pixbuf = pbloader.get_pixbuf().scale_simple(size, size,
GdkPixbuf.InterpType.BILINEAR)
pixbuf = add_border_widget(pixbuf, self)
surface = get_surface_for_pixbuf(self, pixbuf)
except (GLib.GError, IOError):
pass
else:
def append(data):
self.liststore.append(data)
GLib.idle_add(append, [surface, cover])
开发者ID:urielz,项目名称:quodlibet,代码行数:18,代码来源:albumart.py
示例8: set_image
def set_image(self, file, parent):
scale_factor = self.get_scale_factor()
(width, height) = self.__calculate_screen_width(parent)
pixbuf = None
try:
pixbuf = pixbuf_from_file(file, (width, height), scale_factor)
except GLib.GError:
return False
# failed to load, abort
if not pixbuf:
return False
self.__image = Gtk.Image()
self.__image.set_from_surface(get_surface_for_pixbuf(self, pixbuf))
return True
开发者ID:zsau,项目名称:quodlibet,代码行数:19,代码来源:cover.py
示例9: __init__
def __init__(self, conf, song):
Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP)
self.set_type_hint(Gdk.WindowTypeHint.NOTIFICATION)
screen = self.get_screen()
rgba = screen.get_rgba_visual()
if rgba is not None:
self.set_visual(rgba)
self.conf = conf
self.iteration_source = None
self.fading_in = False
self.fade_start_time = 0
mgeo = screen.get_monitor_geometry(conf.monitor)
textwidth = mgeo.width - 2 * (self.BORDER + self.MARGIN)
scale_factor = self.get_scale_factor()
cover_pixbuf = app.cover_manager.get_pixbuf(
song, conf.coversize * scale_factor, conf.coversize * scale_factor)
coverheight = 0
coverwidth = 0
if cover_pixbuf:
self.cover_surface = get_surface_for_pixbuf(self, cover_pixbuf)
coverwidth = cover_pixbuf.get_width() // scale_factor
coverheight = cover_pixbuf.get_height() // scale_factor
textwidth -= coverwidth + self.BORDER
else:
self.cover_surface = None
layout = self.create_pango_layout('')
layout.set_alignment((Pango.Alignment.LEFT, Pango.Alignment.CENTER,
Pango.Alignment.RIGHT)[conf.align])
layout.set_spacing(Pango.SCALE * 7)
layout.set_font_description(Pango.FontDescription(conf.font))
try:
layout.set_markup(pattern.XMLFromMarkupPattern(conf.string) % song)
except pattern.error:
layout.set_markup("")
layout.set_width(Pango.SCALE * textwidth)
layoutsize = layout.get_pixel_size()
if layoutsize[0] < textwidth:
layout.set_width(Pango.SCALE * layoutsize[0])
layoutsize = layout.get_pixel_size()
self.title_layout = layout
winw = layoutsize[0] + 2 * self.BORDER
if coverwidth:
winw += coverwidth + self.BORDER
winh = max(coverheight, layoutsize[1]) + 2 * self.BORDER
self.set_default_size(winw, winh)
rect = namedtuple("Rect", ["x", "y", "width", "height"])
rect.x = self.BORDER
rect.y = (winh - coverheight) // 2
rect.width = coverwidth
rect.height = coverheight
self.cover_rectangle = rect
winx = int((mgeo.width - winw) * self.POS_X)
winx = max(self.MARGIN, min(mgeo.width - self.MARGIN - winw, winx))
winy = int((mgeo.height - winh) * conf.pos_y)
winy = max(self.MARGIN, min(mgeo.height - self.MARGIN - winh, winy))
self.move(winx + mgeo.x, winy + mgeo.y)
开发者ID:Muges,项目名称:quodlibet,代码行数:65,代码来源:osdwindow.py
示例10: test_get_surface_for_pixbuf
def test_get_surface_for_pixbuf(self):
w = Gtk.Button()
rgb = GdkPixbuf.Colorspace.RGB
newpb = GdkPixbuf.Pixbuf.new(rgb, True, 8, 10, 10)
surface = get_surface_for_pixbuf(w, newpb)
self.assertTrue(isinstance(surface, cairo.Surface))
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:6,代码来源:test_qltk_image.py
示例11: idle_set
def idle_set():
if pixbuf is not None:
surface = get_surface_for_pixbuf(self, pixbuf)
self.image.set_from_surface(surface)
开发者ID:urielz,项目名称:quodlibet,代码行数:4,代码来源:albumart.py
示例12: __init__
def __init__(self, title, fileobj, parent):
super(BigCenteredImage, self).__init__(type=Gtk.WindowType.POPUP)
self.set_type_hint(Gdk.WindowTypeHint.TOOLTIP)
assert parent
parent = qltk.get_top_parent(parent)
self.set_transient_for(parent)
if qltk.is_wayland():
# no screen size with wayland, the parent window is
# the next best thing..
width, height = parent.get_size()
width = int(width / 1.1)
height = int(height / 1.1)
else:
win = parent.get_window()
if win:
if qltk.gtk_version[:2] >= (3, 22):
disp = Gdk.Display.get_default()
mon = disp.get_monitor_at_window(win)
rect = mon.get_geometry()
else:
# The result should be the same as above, just using
# deprecated methods instead
screen = Gdk.Screen.get_default()
mon_num = screen.get_monitor_at_window(win)
rect = screen.get_monitor_geometry(mon_num)
width = int(rect.width / 1.8)
height = int(rect.height / 1.8)
else:
width = int(Gdk.Screen.width() / 1.8)
height = int(Gdk.Screen.height() / 1.8)
self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
scale_factor = self.get_scale_factor()
pixbuf = None
try:
pixbuf = pixbuf_from_file(fileobj, (width, height), scale_factor)
except GLib.GError:
pass
# failed to load, abort
if not pixbuf:
self.destroy()
return
image = Gtk.Image()
image.set_from_surface(get_surface_for_pixbuf(self, pixbuf))
event_box = Gtk.EventBox()
event_box.add(image)
frame = Gtk.Frame()
frame.set_shadow_type(Gtk.ShadowType.OUT)
frame.add(event_box)
self.add(frame)
event_box.connect('button-press-event', self.__destroy)
event_box.connect('key-press-event', self.__destroy)
self.get_child().show_all()
开发者ID:LudoBike,项目名称:quodlibet,代码行数:63,代码来源:cover.py
注:本文中的quodlibet.qltk.image.get_surface_for_pixbuf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论