How to use the cairocffi.constants function in cairocffi

To help you get started, we’ve selected a few cairocffi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kozea / cairocffi / cairocffi / test_pixbuf.py View on Github external
def test_size():
    pixbuf_obj, format_name = pixbuf.decode_to_pixbuf(PNG_BYTES, 10, 10)
    assert format_name == 'png'
    surface = pixbuf.pixbuf_to_cairo_png(pixbuf_obj)
    assert surface.get_width() == 10
    assert surface.get_height() == 10
    assert surface.get_format() == constants.FORMAT_ARGB32
github Kozea / cairocffi / cairocffi / test_pixbuf.py View on Github external
def test_png():
    pixbuf_obj, format_name = pixbuf.decode_to_pixbuf(JPEG_BYTES)
    assert format_name == 'jpeg'
    assert_decoded(pixbuf.pixbuf_to_cairo_slices(pixbuf_obj),
                   constants.FORMAT_RGB24, b'\xff\x00\x80\xff')
github Kozea / cairocffi / cairocffi / surfaces.py View on Github external
**Note**: this unsafely inteprets an integer as a pointer.
        Make sure it actually points to a valid DC!
    :type hdc: int

    *New in cairocffi 0.6*

    """
    def __init__(self, hdc):
        pointer = cairo.cairo_win32_printing_surface_create(
            ffi.cast('void*', hdc))
        Surface.__init__(self, pointer)


SURFACE_TYPE_TO_CLASS = {
    constants.SURFACE_TYPE_IMAGE: ImageSurface,
    constants.SURFACE_TYPE_PDF: PDFSurface,
    constants.SURFACE_TYPE_SVG: SVGSurface,
    constants.SURFACE_TYPE_RECORDING: RecordingSurface,
    constants.SURFACE_TYPE_WIN32: Win32Surface,
    constants.SURFACE_TYPE_WIN32_PRINTING: Win32PrintingSurface
}
github Kozea / cairocffi / cairocffi / surfaces.py View on Github external
*New in cairocffi 0.6*

    """
    def __init__(self, hdc):
        pointer = cairo.cairo_win32_printing_surface_create(
            ffi.cast('void*', hdc))
        Surface.__init__(self, pointer)


SURFACE_TYPE_TO_CLASS = {
    constants.SURFACE_TYPE_IMAGE: ImageSurface,
    constants.SURFACE_TYPE_PDF: PDFSurface,
    constants.SURFACE_TYPE_SVG: SVGSurface,
    constants.SURFACE_TYPE_RECORDING: RecordingSurface,
    constants.SURFACE_TYPE_WIN32: Win32Surface,
    constants.SURFACE_TYPE_WIN32_PRINTING: Win32PrintingSurface
}
github Kozea / cairocffi / cairocffi / fonts.py View on Github external
def __init__(self, family='', slant=constants.FONT_SLANT_NORMAL,
                 weight=constants.FONT_WEIGHT_NORMAL):
        FontFace.__init__(self, cairo.cairo_toy_font_face_create(
            _encode_string(family), slant, weight))
github Kozea / cairocffi / cairocffi / __init__.py View on Github external
def _check_status(status):
    """Take a cairo status code and raise an exception if/as appropriate."""
    if status != constants.STATUS_SUCCESS:
        exception = STATUS_TO_EXCEPTION.get(status, CairoError)
        status_name = ffi.string(ffi.cast("cairo_status_t", status))
        message = 'cairo returned %s: %s' % (
            status_name, ffi.string(cairo.cairo_status_to_string(status)))
        raise exception(message, status)
github Kozea / cairocffi / cairocffi / pixbuf.py View on Github external
def pixbuf_to_cairo_gdk(pixbuf):
    """Convert from PixBuf to ImageSurface, using GDK.

    This method is fastest but GDK is not always available.

    """
    dummy_context = Context(ImageSurface(constants.FORMAT_ARGB32, 1, 1))
    gdk.gdk_cairo_set_source_pixbuf(
        dummy_context._pointer, pixbuf._pointer, 0, 0)
    return dummy_context.get_source().get_surface()
github Kozea / cairocffi / cairocffi / fonts.py View on Github external
    def __init__(self, family='', slant=constants.FONT_SLANT_NORMAL,
                 weight=constants.FONT_WEIGHT_NORMAL):
        FontFace.__init__(self, cairo.cairo_toy_font_face_create(
            _encode_string(family), slant, weight))
github Kozea / cairocffi / cairocffi / surfaces.py View on Github external
as obtained from :func:`win32gui.CreateDC`.
        **Note**: this unsafely inteprets an integer as a pointer.
        Make sure it actually points to a valid DC!
    :type hdc: int

    *New in cairocffi 0.6*

    """
    def __init__(self, hdc):
        pointer = cairo.cairo_win32_printing_surface_create(
            ffi.cast('void*', hdc))
        Surface.__init__(self, pointer)


SURFACE_TYPE_TO_CLASS = {
    constants.SURFACE_TYPE_IMAGE: ImageSurface,
    constants.SURFACE_TYPE_PDF: PDFSurface,
    constants.SURFACE_TYPE_SVG: SVGSurface,
    constants.SURFACE_TYPE_RECORDING: RecordingSurface,
    constants.SURFACE_TYPE_WIN32: Win32Surface,
    constants.SURFACE_TYPE_WIN32_PRINTING: Win32PrintingSurface
}
github Kozea / cairocffi / cairocffi / surfaces.py View on Github external
:type hdc: int

    *New in cairocffi 0.6*

    """
    def __init__(self, hdc):
        pointer = cairo.cairo_win32_printing_surface_create(
            ffi.cast('void*', hdc))
        Surface.__init__(self, pointer)


SURFACE_TYPE_TO_CLASS = {
    constants.SURFACE_TYPE_IMAGE: ImageSurface,
    constants.SURFACE_TYPE_PDF: PDFSurface,
    constants.SURFACE_TYPE_SVG: SVGSurface,
    constants.SURFACE_TYPE_RECORDING: RecordingSurface,
    constants.SURFACE_TYPE_WIN32: Win32Surface,
    constants.SURFACE_TYPE_WIN32_PRINTING: Win32PrintingSurface
}