本文整理匯總了Python中cairocffi.version方法的典型用法代碼示例。如果您正苦於以下問題:Python cairocffi.version方法的具體用法?Python cairocffi.version怎麽用?Python cairocffi.version使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cairocffi
的用法示例。
在下文中一共展示了cairocffi.version方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: draw_image
# 需要導入模塊: import cairocffi [as 別名]
# 或者: from cairocffi import version [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()