当前位置: 首页>>代码示例>>Python>>正文


Python image.get_scale_factor函数代码示例

本文整理汇总了Python中quodlibet.qltk.image.get_scale_factor函数的典型用法代码示例。如果您正苦于以下问题:Python get_scale_factor函数的具体用法?Python get_scale_factor怎么用?Python get_scale_factor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_scale_factor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _no_cover

    def _no_cover(self):
        """Returns a cairo surface of pixbuf representing a missing cover"""

        cover_size = Album.COVER_SIZE
        scale_factor = get_scale_factor(self)
        pb = get_no_cover_pixbuf(cover_size, cover_size, scale_factor)
        return get_pbosf_for_pixbuf(self, pb)
开发者ID:tintinyoung,项目名称:quodlibet,代码行数:7,代码来源:main.py

示例2: 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 = get_scale_factor(self)

        width *= scale_factor
        height *= scale_factor

        if self._path:
            if width < 2 or height < 2:
                return
            round_thumbs = config.getboolean("albumart", "round")
            pixbuf = scale(
                pixbuf, (width - 2 * scale_factor, height - 2 * scale_factor))
            pixbuf = add_border_widget(pixbuf, self, None, round_thumbs)
        else:
            pixbuf = scale(pixbuf, (width, height))

        style_context = self.get_style_context()

        pbosf = get_pbosf_for_pixbuf(self, pixbuf)
        pbosf_render(style_context, cairo_context, pbosf, 0, 0)
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:27,代码来源:cover.py

示例3: 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 = get_scale_factor(self)

        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()

        pbosf = get_pbosf_for_pixbuf(self, pixbuf)
        pbosf_render(style_context, cairo_context, pbosf, 0, 0)
开发者ID:MikeiLL,项目名称:quodlibet,代码行数:26,代码来源:cover.py

示例4: test_pbosf_get_width_height

 def test_pbosf_get_width_height(self):
     w = Gtk.Button()
     rgb = GdkPixbuf.Colorspace.RGB
     s = get_scale_factor(w)
     newpb = GdkPixbuf.Pixbuf.new(rgb, True, 8, 10 * s, 15 * s)
     pbosf = get_pbosf_for_pixbuf(w, newpb)
     self.assertEqual(pbosf_get_width(pbosf), 10)
     self.assertEqual(pbosf_get_height(pbosf), 15)
开发者ID:bp0,项目名称:quodlibet,代码行数:8,代码来源:test_qltk_image.py

示例5: add_border_widget

def add_border_widget(pixbuf, widget, round=False):
    """Like add_border() but uses the widget to get a border color and a
    border width.
    """

    from quodlibet.qltk.image import get_scale_factor

    context = widget.get_style_context()
    color = context.get_color(context.get_state())
    scale_factor = get_scale_factor(widget)

    return add_border(pixbuf, color, round=round, width=scale_factor)
开发者ID:mistotebe,项目名称:quodlibet,代码行数:12,代码来源:image.py

示例6: get_scaled_cover

 def get_scaled_cover(album):
     # XXX: Cache this somewhere else
     cover = None
     if not hasattr(album, "_scaled_cover"):
         scale_factor = get_scale_factor(self)
         album.scan_cover(scale_factor=scale_factor)
         if album.cover:
             s = 25 * scale_factor
             cover = scale(album.cover, (s, s))
             album._scaled_cover = cover
     else:
         cover = album._scaled_cover
     return cover
开发者ID:Tjorriemorrie,项目名称:quodlibet,代码行数:13,代码来源:main.py

示例7: add_border_widget

def add_border_widget(pixbuf, widget):
    """Like add_border() but uses the widget to get a border color and a
    border width.
    """

    from quodlibet.qltk.image import get_scale_factor

    context = widget.get_style_context()
    color = context.get_color(context.get_state())
    scale_factor = get_scale_factor(widget)
    border_radius = get_border_radius() * scale_factor

    return add_border(pixbuf, color, width=scale_factor, radius=border_radius)
开发者ID:MikeiLL,项目名称:quodlibet,代码行数:13,代码来源:image.py

示例8: _update_row

    def _update_row(self, filter_model, iter_):
        sort_model = filter_model.get_model()
        model = sort_model.get_model()
        iter_ = filter_model.convert_iter_to_child_iter(iter_)
        iter_ = sort_model.convert_iter_to_child_iter(iter_)
        tref = Gtk.TreeRowReference.new(model, model.get_path(iter_))

        def callback():
            path = tref.get_path()
            if path is not None:
                model.row_changed(path, model.get_iter(path))

        album = model.get_album(iter_)
        scale_factor = get_scale_factor(self)
        album.scan_cover(scale_factor=scale_factor, callback=callback, cancel=self._cover_cancel)
开发者ID:mistotebe,项目名称:quodlibet,代码行数:15,代码来源:main.py

示例9: __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 = get_scale_factor(self)

        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()
        set_image_from_pbosf(image, get_pbosf_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:MikeiLL,项目名称:quodlibet,代码行数:48,代码来源:cover.py

示例10: add_border_widget

def add_border_widget(pixbuf, widget, cell=None, round=False):
    """Like add_border() but uses the widget to get a border color and a
    border width.
    """

    from quodlibet.qltk.image import get_scale_factor

    context = widget.get_style_context()
    if cell is not None:
        state = cell.get_state(widget, 0)
    else:
        state = widget.get_state_flags()
    color = context.get_color(state)
    scale_factor = get_scale_factor(widget)

    return add_border(pixbuf, color, round=round, width=scale_factor)
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:16,代码来源:image.py

示例11: _get_pixbuf

    def _get_pixbuf(self):
        if not self._dirty:
            return self._pixbuf
        self._dirty = False

        max_size = 256 * get_scale_factor(self)

        self._pixbuf = None
        if self._file:
            self._pixbuf = thumbnails.get_thumbnail_from_file(
                self._file, (max_size, max_size))

        if not self._pixbuf:
            self._pixbuf = get_no_cover_pixbuf(max_size, max_size)

        return self._pixbuf
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:16,代码来源:cover.py

示例12: __scale_pixbuf

    def __scale_pixbuf(self, *data):
        if not self.current_pixbuf:
            return
        pixbuf = self.current_pixbuf

        if not self.window_fit.get_active():
            pbosf = pixbuf
        else:
            alloc = self.scrolled.get_allocation()
            width = alloc.width
            height = alloc.height
            scale_factor = get_scale_factor(self)
            boundary = (width * scale_factor, height * scale_factor)
            pixbuf = scale(pixbuf, boundary, scale_up=False)
            pbosf = get_pbosf_for_pixbuf(self, pixbuf)

        set_image_from_pbosf(self.image, pbosf)
开发者ID:vrasidas,项目名称:quodlibet,代码行数:17,代码来源:albumart.py

示例13: __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 = get_scale_factor(self)
            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, None, round=True)
            thumb = get_pbosf_for_pixbuf(self, pixbuf)
        except (GLib.GError, IOError):
            pass
        else:
            def append(data):
                self.liststore.append(data)
            GLib.idle_add(append, [thumb, cover])
开发者ID:vrasidas,项目名称:quodlibet,代码行数:18,代码来源:albumart.py

示例14: pbosf_get_height

def pbosf_get_height(widget, pbosf):
    """The scale independent height"""

    return pbosf.get_height() / get_scale_factor(widget)
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:4,代码来源:image.py

示例15: pbosf_get_width

def pbosf_get_width(widget, pbosf):
    """The scale independent width"""

    return pbosf.get_width() / get_scale_factor(widget)
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:4,代码来源:image.py


注:本文中的quodlibet.qltk.image.get_scale_factor函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。