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


Python Pixbuf.new方法代码示例

本文整理汇总了Python中gi.repository.GdkPixbuf.Pixbuf.new方法的典型用法代码示例。如果您正苦于以下问题:Python Pixbuf.new方法的具体用法?Python Pixbuf.new怎么用?Python Pixbuf.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.GdkPixbuf.Pixbuf的用法示例。


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

示例1: __init__

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new [as 别名]
    def __init__(self, data, size, palette):
        if not data:
            # dummy image
            self.pixbuf = Pixbuf.new(Colorspace.RGB, False, 8,
                                     size[0] * 8 * 2, size[1] * 8 * 2)
            self.pixbuf.fill(0xAAAAAAFF)
            return

        # slice into blocks
        blocks = cut(data, BLOCK)
        # slice block content
        blocks = [cut(b, ROW) for b in blocks]
        # rearrange into blockrows (y/x coordinates)
        blocks = cut(blocks, size[0])

        bytestring = []
        # for each block row
        for y in range(0, size[1]):
            # for each final row
            for i in range(0, int(BLOCK / ROW)):
                # for each block column
                for x in range(0, size[0]):
                    r = blocks[y][x][i]
                    # extract pixels from rows
                    for j in range(4):
                        bytestring.append(r[j] & 0x0F)  # first  (....AAAA)
                        bytestring.append(r[j] >> 4)    # second (BBBB....)

        # apply palette
        result = []
        for i in bytestring:
            result += palette.colors[i]

        # get result in binary format
        result = b''+bytearray(result)

        # create image
        self.pixbuf = Pixbuf.new_from_data(
            result, 0, False, 8,
            8 * size[0], 8 * size[1], 8 * size[0] * 3, None, None)
        self.pixbuf = self.pixbuf.scale_simple(
            8 * size[0] * 2, 8 * size[1] * 2, InterpType.NEAREST)
开发者ID:euhmeuh,项目名称:gbaspritenav,代码行数:44,代码来源:gbaspritenav.py

示例2: image

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new [as 别名]
window.set_size_request(500, 500)

## Add a row without own image (easy)
treestore.append(None, [None, "data without own image"])

## Add a row with a stock icon (also easy)
iconpixbuf = Gtk.IconTheme.get_default().load_icon("folder", 16, 0)
treestore.append(None, [iconpixbuf, "data with a stock icon"])

## Add a row with an image from disk (still easy, uncomment if you have a suitable image file)
#loadedpixbuf = Pixbuf.new_from_file_at_size("../../img/logo.png", 125, 125) 
#treestore.append(None, [loadedpixbuf, "data with a custom image from disk"])

## Add a row with a flat-painted image (easy, but not always useful...)
from gi.repository import Gtk, Gdk
filledpixbuf = Pixbuf.new(Colorspace.RGB, True, 8, 16, 16)  ## In fact, it is RGBA
filledpixbuf.fill(0xff9922ff) 
treestore.append(None, [filledpixbuf, "data with a custom color filled image"])


px = PixbufLoader.new_with_type('pnm')
#color = b'\xee\xff\x2d'
#px.write(b'P6\n\n1 1\n255\n' + color)
#px.write(color)
iconpnm = b"""P2 24 7 25
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  3  3  3  3  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0 15  0
0  3  3  3  0  0  0  7  7  7  0  0  0 11 11 11  0  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0  0  0
0  3  0  0  0  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15  0  0  0  0
开发者ID:FilipDominec,项目名称:plotcommander,代码行数:33,代码来源:debug_pixbuf-cairo-gtk3.py


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