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


Python cairocffi.FORMAT_ARGB32属性代码示例

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


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

示例1: draw_image

# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import FORMAT_ARGB32 [as 别名]
def draw_image(self, gc, x, y, im):
        # bbox - not currently used
        if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))

        im.flipud_out()

        rows, cols, buf = im.color_conv (BYTE_FORMAT)
        surface = cairo.ImageSurface.create_for_data (
                      buf, cairo.FORMAT_ARGB32, cols, rows, cols*4)
        ctx = gc.ctx
        y = self.height - y - rows

        ctx.save()
        ctx.set_source_surface (surface, x, y)
        if gc.get_alpha() != 1.0:
            ctx.paint_with_alpha(gc.get_alpha())
        else:
            ctx.paint()
        ctx.restore()

        im.flipud_out() 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:23,代码来源:backend_cairo.py

示例2: __init__

# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import FORMAT_ARGB32 [as 别名]
def __init__(self, dpi):
        self.dpi = dpi
        self.gc = GraphicsContextCairo(renderer=self)
        self.text_ctx = cairo.Context(
           cairo.ImageSurface(cairo.FORMAT_ARGB32, 1, 1))
        self.mathtext_parser = MathTextParser('Cairo')
        RendererBase.__init__(self) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:9,代码来源:backend_cairo.py

示例3: draw_image

# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import FORMAT_ARGB32 [as 别名]
def draw_image(self, gc, x, y, im):
        im = cbook._unmultiplied_rgba8888_to_premultiplied_argb32(im[::-1])
        surface = cairo.ImageSurface.create_for_data(
            im.ravel().data, cairo.FORMAT_ARGB32,
            im.shape[1], im.shape[0], im.shape[1] * 4)
        ctx = gc.ctx
        y = self.height - y - im.shape[0]

        ctx.save()
        ctx.set_source_surface(surface, float(x), float(y))
        ctx.paint()
        ctx.restore() 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:14,代码来源:backend_cairo.py

示例4: _get_printed_image_surface

# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import FORMAT_ARGB32 [as 别名]
def _get_printed_image_surface(self):
        width, height = self.get_width_height()
        renderer = RendererCairo(self.figure.dpi)
        renderer.set_width_height(width, height)
        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
        renderer.set_ctx_from_surface(surface)
        self.figure.draw(renderer)
        return surface 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:10,代码来源:backend_cairo.py

示例5: __init__

# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import FORMAT_ARGB32 [as 别名]
def __init__(self, dpi):
        """
        """
        if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))
        self.dpi = dpi
        self.gc = GraphicsContextCairo (renderer=self)
        self.text_ctx = cairo.Context (
           cairo.ImageSurface (cairo.FORMAT_ARGB32,1,1))
        self.mathtext_parser = MathTextParser('Cairo')

        RendererBase.__init__(self) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:13,代码来源:backend_cairo.py

示例6: print_png

# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import FORMAT_ARGB32 [as 别名]
def print_png(self, fobj, *args, **kwargs):
        width, height = self.get_width_height()

        renderer = RendererCairo (self.figure.dpi)
        renderer.set_width_height (width, height)
        surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, width, height)
        renderer.set_ctx_from_surface (surface)

        self.figure.draw (renderer)
        surface.write_to_png (fobj) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:12,代码来源:backend_cairo.py

示例7: draw_image

# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import FORMAT_ARGB32 [as 别名]
def draw_image(self, gc, x, y, im):
        # bbox - not currently used
        if sys.byteorder == 'little':
            im = im[:, :, (2, 1, 0, 3)]
        else:
            im = im[:, :, (3, 0, 1, 2)]
        if HAS_CAIRO_CFFI:
            # cairocffi tries to use the buffer_info from array.array
            # that we replicate in ArrayWrapper and alternatively falls back
            # on ctypes to get a pointer to the numpy array. This works
            # correctly on a numpy array in python3 but not 2.7. We replicate
            # the array.array functionality here to get cross version support.
            imbuffer = ArrayWrapper(im.flatten())
        else:
            # pycairo uses PyObject_AsWriteBuffer to get a pointer to the
            # numpy array; this works correctly on a regular numpy array but
            # not on a py2 memoryview.
            imbuffer = im.flatten()
        surface = cairo.ImageSurface.create_for_data(
            imbuffer, cairo.FORMAT_ARGB32,
            im.shape[1], im.shape[0], im.shape[1]*4)
        ctx = gc.ctx
        y = self.height - y - im.shape[0]

        ctx.save()
        ctx.set_source_surface(surface, float(x), float(y))
        if gc.get_alpha() != 1.0:
            ctx.paint_with_alpha(gc.get_alpha())
        else:
            ctx.paint()
        ctx.restore() 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:33,代码来源:backend_cairo.py

示例8: print_png

# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import FORMAT_ARGB32 [as 别名]
def print_png(self, fobj, *args, **kwargs):
        width, height = self.get_width_height()

        renderer = RendererCairo(self.figure.dpi)
        renderer.set_width_height(width, height)
        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
        renderer.set_ctx_from_surface(surface)

        self.figure.draw(renderer)
        surface.write_to_png(fobj) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:12,代码来源:backend_cairo.py


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