當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。