Skip to content

Instantly share code, notes, and snippets.

@mara004
Last active April 14, 2025 01:06
Show Gist options
  • Save mara004/428a9aad5d553d4631ab0b5119eb74b2 to your computer and use it in GitHub Desktop.
Save mara004/428a9aad5d553d4631ab0b5119eb74b2 to your computer and use it in GitHub Desktop.
PDF rendering with Ghostscript, revisited (ABI bindings, in-memory approach)
# Four lines intentionally left blank
# SPDX-FileCopyrightText: 2025 geisserml <[email protected]>
# SPDX-License-Identifier: MPL-2.0 OR GPL-3.0-or-later
# Note that Ghostscript is AGPL-licensed, so this code is altogether affected by copyleft
# Written with Ghostscript 9.56.1 on Fedora.
# Dev Resources:
# - The comments in ghostscript's public headers. They are actually more straightforward than the HTML pages IMO.
# - https://ghostscript.readthedocs.io/en/latest/API.html
# - https://ghostscript.readthedocs.io/en/latest/Use.html
# - https://ghostscript.readthedocs.io/en/latest/Devices.html
# - https://ghostscript.readthedocs.io/en/latest/LanguageBindingsPython.html
# - https://github.com/ArtifexSoftware/ghostpdl/tree/master/demos/python
# - https://gitlab.com/pdftools/python-ghostscript
# - https://github.com/albel727/rust-ghostscript/tree/master/ghostscript-rs/examples/memory-render
# Auto-generate the libgs bindings module via pypdfium2-ctypesgen:
# ctypesgen -i /usr/include/ghostscript/*.h -o libgs.py -l gs --no-symbol-guards --no-macro-guards
# FIXME ctypes.util.find_library() may not be able to find ghostscript on Windows
from libgs import *
from ctypes import *
import libgs
import ctypes
import sys
import atexit
import signal
from pathlib import Path
if sys.version_info < (3, 8):
from functools import lru_cache
def cached_property(func):
return property( lru_cache(maxsize=1)(func) )
else:
from functools import cached_property
def log(*args, **kwargs):
print(*args, **kwargs, file=sys.stderr)
class _LazyClass:
@cached_property
def numpy(self):
log("Evaluating lazy import 'numpy' ...")
import numpy; return numpy
@cached_property
def PIL_Image(self):
log("Evaluating lazy import 'PIL.Image' ...")
import PIL.Image; return PIL.Image
Lazy = _LazyClass()
GLOBAL_RC = 0
def _interrupt_handler(signum, frame):
global GLOBAL_RC
log("\n*** SIGINT received ***")
GLOBAL_RC = -1 # or maybe gs_error_InterpreterExit
# Always propagate the interrupt so we don't have to wait on python code in callbacks.
# This seems to cause some pollution compared to just waiting until the callback returns, but quick exit is more important to us.
raise KeyboardInterrupt()
signal.signal(signal.SIGINT, _interrupt_handler)
# Library scope
def init_gs():
minst = c_void_p()
rc = gsapi_new_instance(minst, None)
assert rc >= 0
rc = gsapi_set_arg_encoding(minst, GS_ARG_ENCODING_UTF8)
assert rc == 0
return minst
minst = init_gs()
atexit.register(gsapi_delete_instance, minst)
def run_args(py_args):
enc_args = [(a+"\0").encode("utf-8") for a in py_args]
enc_args.insert(0, b"")
gsargv = (c_char_p * len(enc_args))(*enc_args)
gsargv_ptr = cast(gsargv, POINTER(POINTER(c_char)))
try:
rc = gsapi_init_with_args(minst, len(enc_args), gsargv_ptr)
assert rc in (0, gs_error_Quit), rc
finally:
rc = gsapi_exit(minst)
assert rc in (0, gs_error_Quit), rc
class Bitmap:
def __init__(self, width, height, stride, format, buffer):
self.width, self.height, self.stride, self.format, self.buffer = \
width, height, stride, format, buffer
def __repr__(self):
return f"{Bitmap.__name__}{tuple(vars(self).values())}"
# TODO: to_*(): handle self.format instead of hard-coding RGB
def to_pil(self):
return Lazy.PIL_Image.frombuffer(
"RGB", # dest mode
(self.width, self.height), # size
self.buffer, # buffer
"raw", # decoder
"RGB", # src mode
self.stride, # bytes per row
1 # orientation (top->bottom)
)
def to_numpy(self):
n_channels = 3
return Lazy.numpy.ndarray(
# layout: row major
shape = (self.height, self.width, n_channels),
dtype = c_ubyte,
buffer = self.buffer,
# number of bytes per item for each nesting level (outer->inner: row, pixel, value)
strides = (self.stride, n_channels, 1),
)
class DisplayImpls:
__slots__ = ("bitmap", "buffer", "callback", "count")
def __init__(self):
self.buffer, self.bitmap = None, None
def _assert_mem_match(self, mem):
buffer_addr = addressof(self.buffer)
if mem != buffer_addr:
log(f"!!! PANIC: addresses don't match: {mem} != {buffer_addr}")
return -1
return GLOBAL_RC
def display_size(self, _, device, width, height, stride, format, pimage):
# Note, this function may be called multiple times per page (typically twice). Ghostscript's API design is flawed.
log("SIZE", device, width, height, stride, format, pimage)
rc = self._assert_mem_match( addressof(pimage.contents) )
if rc != 0: return rc
self.bitmap = Bitmap(width, height, stride, format, None)
return GLOBAL_RC
def display_page(self, _, device, copies, flush):
log("PAGE", device, copies, flush)
if not (self.buffer and self.bitmap and self.callback):
log("!!! PANIC: required attribute(s) not set")
return -1
self.bitmap.buffer = self.buffer
self.callback(self.bitmap, self.count)
self.count += 1
self.bitmap = None
return GLOBAL_RC
def display_memalloc(self, _, device, size):
log("MEMALLOC", size)
self.buffer = (c_ubyte * size)()
# Important: don't use cast(self.buffer, c_void_p).value - this causes a memory leak, probably due to a persistent reference or something.
# Thus, we have to assume that address and pointer values are identical on the host platform.
return addressof(self.buffer) if GLOBAL_RC == 0 else None
def display_memfree(self, _, device, mem):
# We do not need to actually free the memory here because the buffer has been allocated by ctypes and will be automatically released after its refcount has reached zero.
log("MEMFREE (intentionally ignored)", device, mem)
rc = self._assert_mem_match(mem)
if rc != 0: return rc
self.buffer = None
return GLOBAL_RC
impls_obj = DisplayImpls()
dsp_fields = dict(display_callback_s._fields_)
WITH_DEBUG = True # whether to show dummy calls
def dummy_field(name):
functype = dsp_fields[f"display_{name}"]
@functype
def dummy_impl(*args):
if WITH_DEBUG: print(name.upper(), *args)
return GLOBAL_RC
return dummy_impl
def actual_field(name):
return dsp_fields[f"display_{name}"]( getattr(impls_obj, f"display_{name}") )
# def null_field(name):
# return cast(None, dsp_fields[f"display_{name}"])
def _get_dsp_struct_ver():
if DISPLAY_VERSION_MAJOR <= 3:
return DISPLAY_VERSION_MAJOR, DISPLAY_VERSION_MINOR
else:
return 3, getattr(libgs, "DISPLAY_VERSION_MINOR_V3", 0)
dsp_major_v, dsp_minor_v = _get_dsp_struct_ver()
print(f"Display struct version: {dsp_major_v}, {dsp_minor_v}", file=sys.stderr)
m_callback_s = display_callback_s(
size = sizeof(display_callback_s),
version_major = dsp_major_v,
version_minor = dsp_minor_v,
display_open = dummy_field("open"),
display_preclose = dummy_field("preclose"),
display_close = dummy_field("close"),
display_presize = dummy_field("presize"),
display_size = actual_field("size"),
display_sync = dummy_field("sync"),
display_page = actual_field("page"),
# display_update = null_field("update"),
display_memalloc = actual_field("memalloc"),
display_memfree = actual_field("memfree"),
# display_separation = null_field("separation"), # v2
# display_adjust_band_height = null_field("adjust_band_height"), # v3
# display_rectangle_request = null_field("rectangle_request"), # v3
)
LEGACY_METHOD_OK = False
if LEGACY_METHOD_OK:
# we don't care about the handle, so no need to pass -dDisplayHandle=... later
rc = gsapi_set_display_callback(minst, byref(m_callback_s))
assert rc == 0
else:
@gs_callout
def m_callout_handler(instance, callout_handle, device_name, id, size, data):
if not device_name or string_at(device_name) != b"display":
return -1
if id == DISPLAY_CALLOUT_GET_CALLBACK:
cb = cast(data, POINTER(gs_display_get_callback_t)).contents
cb.callback = pointer(m_callback_s)
cb.caller_handle = callout_handle
return 0
return -1
# we don't care about the handle, so pass through None
rc = gsapi_register_callout(minst, m_callout_handler, None)
assert rc == 0
def render(input_f, password=None, pages=None, dpi=300, output_prefix=None, device="png16m", display_format="16#804", display_callback=None):
# See https://ghostscript.readthedocs.io/en/latest/Use.html
dpi = round(dpi, 6)
args = [
"-dNOPAUSE",
"-dBATCH",
"-dSAFER",
# "-dQUIET",
"-dNOPROMPT",
f"-sDEVICE={device}",
f"-r{dpi:f}x{dpi:f}",
# The options below are for smoother text rendering. The default text render mode is unbearable.
"-dInterpolateControl=-1",
"-dTextAlphaBits=4",
"-dGraphicsAlphaBits=4",
]
if pages:
# alternatively -dFirstPage and -dLastPage
args.append(f"-sPageList={pages}")
if password:
args.append(f"-sPDFPassword={password}")
is_display = device == "display"
if is_display:
assert display_format and display_callback
impls_obj.count = 0
impls_obj.callback = display_callback
args.append(f"-dDisplayFormat={display_format}") # see Devices.html
else:
assert output_prefix
args.append(f"-sOutputFile={output_prefix}_%d.png")
try:
args.extend(["-f", str(input_f)])
print(args)
run_args(args)
finally:
if is_display:
impls_obj.count, impls_obj.callback = 0, None
class SaverClass:
def __init__(self, prefix, ext="jpg"):
self.prefix = prefix
self.ext = ext
def _get_path(self, count):
return f"{self.prefix}_{count+1}.{self.ext}"
def write_pil(self, bitmap, count):
pil_image = bitmap.to_pil()
pil_image.save( self._get_path(count) )
def write_pil_from_numpy(self, bitmap, count):
# TODO: handle bitmap.format instead of hardcoding RGB
pil_image = PIL.Image.fromarray(bitmap.to_numpy(), "RGB")
pil_image.save( self._get_path(count) )
def main():
# e.g. ~/Downloads/move/pdfs/CinelerraGG_Manual.pdf ./out/test 1-30 200
input_f = Path(sys.argv[1]).expanduser().resolve()
output_prefix = Path(sys.argv[2]).expanduser().resolve()
pages = sys.argv[3]
dpi = int(sys.argv[4])
saver = SaverClass(output_prefix, ext="jpg")
render(input_f, pages=pages, dpi=dpi, device="display", display_callback=saver.write_pil)
if __name__ == "__main__":
main()
@mara004
Copy link
Author

mara004 commented Mar 29, 2025

For an older version using subprocess and file IO, see https://gist.github.com/mara004/8ef3a803531fdd42b29bbfa2889ff7f3.
subprocess adds some overhead (which I would like to avoid), but it might have licensing advantages, as per https://www.gnu.org/licenses/gpl-faq.en.html#MereAggregation.

@mara004
Copy link
Author

mara004 commented Mar 29, 2025

Sample libgs ctypesgen bindings interface:

click to expand
R"""
Auto-generated by:
ctypesgen -i /usr/include/ghostscript/gdevdsp.h /usr/include/ghostscript/gserrors.h /usr/include/ghostscript/iapi.h /usr/include/ghostscript/ierrors.h -o libgs.py -l gs --no-symbol-guards --no-macro-guards
"""

import ctypes
from ctypes import *


# -- Begin library loader --

import sys
import ctypes
import ctypes.util
import pathlib

def _find_library(name, dirs, search_sys):
    
    if sys.platform.startswith(("win32", "cygwin", "msys")):
        patterns = ["{}.dll", "lib{}.dll", "{}"]
    elif sys.platform.startswith(("darwin", "ios")):
        patterns = ["lib{}.dylib", "{}.dylib", "lib{}.so", "{}.so", "{}"]
    else:  # assume unix pattern or plain name
        patterns = ["lib{}.so", "{}.so", "{}"]
    
    for dir in dirs:
        dir = pathlib.Path(dir)
        if not dir.is_absolute():
            dir = (pathlib.Path(__file__).parent / dir).resolve(strict=False)
        for pat in patterns:
            libpath = dir / pat.format(name)
            if libpath.is_file():
                return str(libpath)
    
    libpath = ctypes.util.find_library(name) if search_sys else None
    if not libpath:
        raise ImportError(f"Could not find library '{name}' (dirs={dirs}, search_sys={search_sys})")
    
    return libpath

_libs_info, _libs = {}, {}

def _register_library(name, dllclass, **kwargs):
    libpath = _find_library(name, **kwargs)
    _libs_info[name] = {**kwargs, "path": libpath}
    _libs[name] = dllclass(libpath)

# -- End library loader --


# -- Begin templates --

# AOTW, ctypes does not support non-primitive result types in callbacks,
# so we remap custom pointer types to unchecked c_void_p.
def UNCHECKED(t):
    if hasattr(t, "_type_") and not isinstance(t._type_, str):
        return ctypes.c_void_p
    else:
        return t

# -- End templates --


# Load library 'gs'

_register_library(
    name = 'gs',
    dllclass = ctypes.CDLL,
    dirs = [],
    search_sys = True,
)


# -- Begin header members --

# /usr/include/ghostscript/gdevdsp.h: 117
enum_anon_1 = c_int

# /usr/include/ghostscript/gdevdsp.h: 117
DISPLAY_COLORS_NATIVE = (1 << 0)

# /usr/include/ghostscript/gdevdsp.h: 117
DISPLAY_COLORS_GRAY = (1 << 1)

# /usr/include/ghostscript/gdevdsp.h: 117
DISPLAY_COLORS_RGB = (1 << 2)

# /usr/include/ghostscript/gdevdsp.h: 117
DISPLAY_COLORS_CMYK = (1 << 3)

# /usr/include/ghostscript/gdevdsp.h: 117
DISPLAY_COLORS_SEPARATION = (1 << 19)

# /usr/include/ghostscript/gdevdsp.h: 117
DISPLAY_FORMAT_COLOR = enum_anon_1

# /usr/include/ghostscript/gdevdsp.h: 128
enum_anon_2 = c_int

# /usr/include/ghostscript/gdevdsp.h: 128
DISPLAY_ALPHA_NONE = (0 << 4)

# /usr/include/ghostscript/gdevdsp.h: 128
DISPLAY_ALPHA_FIRST = (1 << 4)

# /usr/include/ghostscript/gdevdsp.h: 128
DISPLAY_ALPHA_LAST = (1 << 5)

# /usr/include/ghostscript/gdevdsp.h: 128
DISPLAY_UNUSED_FIRST = (1 << 6)

# /usr/include/ghostscript/gdevdsp.h: 128
DISPLAY_UNUSED_LAST = (1 << 7)

# /usr/include/ghostscript/gdevdsp.h: 128
DISPLAY_FORMAT_ALPHA = enum_anon_2

# /usr/include/ghostscript/gdevdsp.h: 145
enum_anon_3 = c_int

# /usr/include/ghostscript/gdevdsp.h: 145
DISPLAY_DEPTH_1 = (1 << 8)

# /usr/include/ghostscript/gdevdsp.h: 145
DISPLAY_DEPTH_2 = (1 << 9)

# /usr/include/ghostscript/gdevdsp.h: 145
DISPLAY_DEPTH_4 = (1 << 10)

# /usr/include/ghostscript/gdevdsp.h: 145
DISPLAY_DEPTH_8 = (1 << 11)

# /usr/include/ghostscript/gdevdsp.h: 145
DISPLAY_DEPTH_12 = (1 << 12)

# /usr/include/ghostscript/gdevdsp.h: 145
DISPLAY_DEPTH_16 = (1 << 13)

# /usr/include/ghostscript/gdevdsp.h: 145
DISPLAY_FORMAT_DEPTH = enum_anon_3

# /usr/include/ghostscript/gdevdsp.h: 154
enum_anon_4 = c_int

# /usr/include/ghostscript/gdevdsp.h: 154
DISPLAY_BIGENDIAN = (0 << 16)

# /usr/include/ghostscript/gdevdsp.h: 154
DISPLAY_LITTLEENDIAN = (1 << 16)

# /usr/include/ghostscript/gdevdsp.h: 154
DISPLAY_FORMAT_ENDIAN = enum_anon_4

# /usr/include/ghostscript/gdevdsp.h: 161
enum_anon_5 = c_int

# /usr/include/ghostscript/gdevdsp.h: 161
DISPLAY_TOPFIRST = (0 << 17)

# /usr/include/ghostscript/gdevdsp.h: 161
DISPLAY_BOTTOMFIRST = (1 << 17)

# /usr/include/ghostscript/gdevdsp.h: 161
DISPLAY_FORMAT_FIRSTROW = enum_anon_5

# /usr/include/ghostscript/gdevdsp.h: 170
enum_anon_6 = c_int

# /usr/include/ghostscript/gdevdsp.h: 170
DISPLAY_NATIVE_555 = (0 << 18)

# /usr/include/ghostscript/gdevdsp.h: 170
DISPLAY_NATIVE_565 = (1 << 18)

# /usr/include/ghostscript/gdevdsp.h: 170
DISPLAY_FORMAT_555 = enum_anon_6

# /usr/include/ghostscript/gdevdsp.h: 188
enum_anon_7 = c_int

# /usr/include/ghostscript/gdevdsp.h: 188
DISPLAY_ROW_ALIGN_DEFAULT = (0 << 20)

# /usr/include/ghostscript/gdevdsp.h: 188
DISPLAY_ROW_ALIGN_4 = (3 << 20)

# /usr/include/ghostscript/gdevdsp.h: 188
DISPLAY_ROW_ALIGN_8 = (4 << 20)

# /usr/include/ghostscript/gdevdsp.h: 188
DISPLAY_ROW_ALIGN_16 = (5 << 20)

# /usr/include/ghostscript/gdevdsp.h: 188
DISPLAY_ROW_ALIGN_32 = (6 << 20)

# /usr/include/ghostscript/gdevdsp.h: 188
DISPLAY_ROW_ALIGN_64 = (7 << 20)

# /usr/include/ghostscript/gdevdsp.h: 188
DISPLAY_FORMAT_ROW_ALIGN = enum_anon_7

# /usr/include/ghostscript/gdevdsp.h: 197
enum_anon_8 = c_int

# /usr/include/ghostscript/gdevdsp.h: 197
DISPLAY_CHUNKY = (0 << 23)

# /usr/include/ghostscript/gdevdsp.h: 197
DISPLAY_PLANAR = (1 << 23)

# /usr/include/ghostscript/gdevdsp.h: 197
DISPLAY_PLANAR_INTERLEAVED = (2 << 23)

# /usr/include/ghostscript/gdevdsp.h: 197
DISPLAY_FORMAT_PLANARNESS = enum_anon_8

# /usr/include/ghostscript/gdevdsp.h: 209
class struct_display_callback_s (Structure):
    __slots__ = ['size', 'version_major', 'version_minor', 'display_open', 'display_preclose', 'display_close', 'display_presize', 'display_size', 'display_sync', 'display_page', 'display_update', 'display_memalloc', 'display_memfree', 'display_separation', 'display_adjust_band_height', 'display_rectangle_request']

# /usr/include/ghostscript/gdevdsp.h: 201
display_callback = struct_display_callback_s

struct_display_callback_s._fields_ = [
    ('size', c_int),
    ('version_major', c_int),
    ('version_minor', c_int),
    ('display_open', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_preclose', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_close', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_presize', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int, c_int, c_uint)),
    ('display_size', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int, c_int, c_uint, POINTER(c_ubyte))),
    ('display_sync', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_page', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int)),
    ('display_update', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int, c_int, c_int)),
    ('display_memalloc', CFUNCTYPE(UNCHECKED(POINTER(None)), POINTER(None), POINTER(None), c_size_t)),
    ('display_memfree', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), POINTER(None))),
    ('display_separation', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, POINTER(c_char), c_ushort, c_ushort, c_ushort, c_ushort)),
    ('display_adjust_band_height', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int)),
    ('display_rectangle_request', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), POINTER(POINTER(None)), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int))),
]

# /usr/include/ghostscript/gdevdsp.h: 349
class struct_display_callback_v2_s (Structure):
    __slots__ = ['size', 'version_major', 'version_minor', 'display_open', 'display_preclose', 'display_close', 'display_presize', 'display_size', 'display_sync', 'display_page', 'display_update', 'display_memalloc', 'display_memfree', 'display_separation']

struct_display_callback_v2_s._fields_ = [
    ('size', c_int),
    ('version_major', c_int),
    ('version_minor', c_int),
    ('display_open', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_preclose', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_close', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_presize', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int, c_int, c_uint)),
    ('display_size', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int, c_int, c_uint, POINTER(c_ubyte))),
    ('display_sync', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_page', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int)),
    ('display_update', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int, c_int, c_int)),
    ('display_memalloc', CFUNCTYPE(UNCHECKED(POINTER(None)), POINTER(None), POINTER(None), c_ulong)),
    ('display_memfree', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), POINTER(None))),
    ('display_separation', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, POINTER(c_char), c_ushort, c_ushort, c_ushort, c_ushort)),
]

# /usr/include/ghostscript/gdevdsp.h: 373
class struct_display_callback_v1_s (Structure):
    __slots__ = ['size', 'version_major', 'version_minor', 'display_open', 'display_preclose', 'display_close', 'display_presize', 'display_size', 'display_sync', 'display_page', 'display_update', 'display_memalloc', 'display_memfree']

struct_display_callback_v1_s._fields_ = [
    ('size', c_int),
    ('version_major', c_int),
    ('version_minor', c_int),
    ('display_open', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_preclose', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_close', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_presize', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int, c_int, c_uint)),
    ('display_size', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int, c_int, c_uint, POINTER(c_ubyte))),
    ('display_sync', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None))),
    ('display_page', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int)),
    ('display_update', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), c_int, c_int, c_int, c_int)),
    ('display_memalloc', CFUNCTYPE(UNCHECKED(POINTER(None)), POINTER(None), POINTER(None), c_ulong)),
    ('display_memfree', CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), POINTER(None))),
]

# /usr/include/ghostscript/gdevdsp.h: 400
class struct_anon_9 (Structure):
    __slots__ = ['callback', 'caller_handle']

struct_anon_9._fields_ = [
    ('callback', POINTER(display_callback)),
    ('caller_handle', POINTER(None)),
]

# /usr/include/ghostscript/gdevdsp.h: 400
gs_display_get_callback_t = struct_anon_9

# /usr/include/ghostscript/gserrors.h: 27
enum_gs_error_type = c_int

# /usr/include/ghostscript/gserrors.h: 27
gs_error_ok = 0

# /usr/include/ghostscript/gserrors.h: 27
gs_error_unknownerror = (-1)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_dictfull = (-2)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_dictstackoverflow = (-3)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_dictstackunderflow = (-4)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_execstackoverflow = (-5)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_interrupt = (-6)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_invalidaccess = (-7)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_invalidexit = (-8)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_invalidfileaccess = (-9)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_invalidfont = (-10)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_invalidrestore = (-11)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_ioerror = (-12)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_limitcheck = (-13)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_nocurrentpoint = (-14)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_rangecheck = (-15)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_stackoverflow = (-16)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_stackunderflow = (-17)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_syntaxerror = (-18)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_timeout = (-19)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_typecheck = (-20)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_undefined = (-21)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_undefinedfilename = (-22)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_undefinedresult = (-23)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_unmatchedmark = (-24)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_VMerror = (-25)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_configurationerror = (-26)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_undefinedresource = (-27)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_unregistered = (-28)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_invalidcontext = (-29)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_invalidid = (-30)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_hit_detected = (-99)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_Fatal = (-100)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_Quit = (-101)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_InterpreterExit = (-102)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_Remap_Color = (-103)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_ExecStackUnderflow = (-104)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_VMreclaim = (-105)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_NeedInput = (-106)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_NeedFile = (-107)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_Info = (-110)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_handled = (-111)

# /usr/include/ghostscript/gserrors.h: 27
gs_error_circular_reference = (-112)

# /usr/include/ghostscript/gserrors.h: 129
gs_error_t = enum_gs_error_type

# /usr/include/ghostscript/gserrors.h: 131
gs_log_error = _libs['gs']['gs_log_error']
gs_log_error.argtypes = [c_int, POINTER(c_char), c_int]
gs_log_error.restype = c_int

# /usr/include/ghostscript/gserrors.h: 164
gs_errstr = _libs['gs']['gs_errstr']
gs_errstr.argtypes = [c_int]
gs_errstr.restype = POINTER(c_char)

# /usr/include/ghostscript/gserrors.h: 166
gs_throw_imp = _libs['gs']['gs_throw_imp']
gs_throw_imp.argtypes = [POINTER(c_char), POINTER(c_char), c_int, c_int, c_int, POINTER(c_char)]
gs_throw_imp.restype = c_int

# /usr/include/ghostscript/iapi.h: 126
class struct_gs_memory_s (Structure):
    pass

# /usr/include/ghostscript/iapi.h: 126
gs_memory_t = struct_gs_memory_s

# /usr/include/ghostscript/iapi.h: 131
class struct_gp_file_s (Structure):
    pass

# /usr/include/ghostscript/iapi.h: 131
gp_file = struct_gp_file_s

# /usr/include/ghostscript/iapi.h: 139
class struct_gsapi_revision_s (Structure):
    __slots__ = ['product', 'copyright', 'revision', 'revisiondate']

struct_gsapi_revision_s._fields_ = [
    ('product', POINTER(c_char)),
    ('copyright', POINTER(c_char)),
    ('revision', c_long),
    ('revisiondate', c_long),
]

# /usr/include/ghostscript/iapi.h: 139
gsapi_revision_t = struct_gsapi_revision_s

# /usr/include/ghostscript/iapi.h: 152
gsapi_revision = _libs['gs']['gsapi_revision']
gsapi_revision.argtypes = [POINTER(gsapi_revision_t), c_int]
gsapi_revision.restype = c_int

# /usr/include/ghostscript/iapi.h: 169
gsapi_new_instance = _libs['gs']['gsapi_new_instance']
gsapi_new_instance.argtypes = [POINTER(POINTER(None)), POINTER(None)]
gsapi_new_instance.restype = c_int

# /usr/include/ghostscript/iapi.h: 185
gsapi_delete_instance = _libs['gs']['gsapi_delete_instance']
gsapi_delete_instance.argtypes = [POINTER(None)]
gsapi_delete_instance.restype = None

# /usr/include/ghostscript/iapi.h: 195
gsapi_set_stdio = _libs['gs']['gsapi_set_stdio']
gsapi_set_stdio.argtypes = [POINTER(None), CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int), CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int), CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int)]
gsapi_set_stdio.restype = c_int

# /usr/include/ghostscript/iapi.h: 203
gsapi_set_stdio_with_handle = _libs['gs']['gsapi_set_stdio_with_handle']
gsapi_set_stdio_with_handle.argtypes = [POINTER(None), CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int), CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int), CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int), POINTER(None)]
gsapi_set_stdio_with_handle.restype = c_int

# /usr/include/ghostscript/iapi.h: 218
gsapi_set_poll = _libs['gs']['gsapi_set_poll']
gsapi_set_poll.argtypes = [POINTER(None), CFUNCTYPE(UNCHECKED(c_int), POINTER(None))]
gsapi_set_poll.restype = c_int

# /usr/include/ghostscript/iapi.h: 223
gsapi_set_poll_with_handle = _libs['gs']['gsapi_set_poll_with_handle']
gsapi_set_poll_with_handle.argtypes = [POINTER(None), CFUNCTYPE(UNCHECKED(c_int), POINTER(None)), POINTER(None)]
gsapi_set_poll_with_handle.restype = c_int

# /usr/include/ghostscript/iapi.h: 232
gsapi_set_display_callback = _libs['gs']['gsapi_set_display_callback']
gsapi_set_display_callback.argtypes = [POINTER(None), POINTER(display_callback)]
gsapi_set_display_callback.restype = c_int

# /usr/include/ghostscript/iapi.h: 249
gs_callout = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(None), POINTER(c_char), c_int, c_int, POINTER(None))

# /usr/include/ghostscript/iapi.h: 260
gsapi_register_callout = _libs['gs']['gsapi_register_callout']
gsapi_register_callout.argtypes = [POINTER(None), gs_callout, POINTER(None)]
gsapi_register_callout.restype = c_int

# /usr/include/ghostscript/iapi.h: 264
gsapi_deregister_callout = _libs['gs']['gsapi_deregister_callout']
gsapi_deregister_callout.argtypes = [POINTER(None), gs_callout, POINTER(None)]
gsapi_deregister_callout.restype = None

# /usr/include/ghostscript/iapi.h: 276
gsapi_set_default_device_list = _libs['gs']['gsapi_set_default_device_list']
gsapi_set_default_device_list.argtypes = [POINTER(None), POINTER(c_char), c_int]
gsapi_set_default_device_list.restype = c_int

# /usr/include/ghostscript/iapi.h: 282
gsapi_get_default_device_list = _libs['gs']['gsapi_get_default_device_list']
gsapi_get_default_device_list.argtypes = [POINTER(None), POINTER(POINTER(c_char)), POINTER(c_int)]
gsapi_get_default_device_list.restype = c_int

# /usr/include/ghostscript/iapi.h: 291
gsapi_set_arg_encoding = _libs['gs']['gsapi_set_arg_encoding']
gsapi_set_arg_encoding.argtypes = [POINTER(None), c_int]
gsapi_set_arg_encoding.restype = c_int

# /usr/include/ghostscript/iapi.h: 294
enum_anon_10 = c_int

# /usr/include/ghostscript/iapi.h: 294
GS_ARG_ENCODING_LOCAL = 0

# /usr/include/ghostscript/iapi.h: 294
GS_ARG_ENCODING_UTF8 = 1

# /usr/include/ghostscript/iapi.h: 294
GS_ARG_ENCODING_UTF16LE = 2

# /usr/include/ghostscript/iapi.h: 312
gsapi_init_with_args = _libs['gs']['gsapi_init_with_args']
gsapi_init_with_args.argtypes = [POINTER(None), c_int, POINTER(POINTER(c_char))]
gsapi_init_with_args.restype = c_int

# /usr/include/ghostscript/iapi.h: 333
gsapi_run_string_begin = _libs['gs']['gsapi_run_string_begin']
gsapi_run_string_begin.argtypes = [POINTER(None), c_int, POINTER(c_int)]
gsapi_run_string_begin.restype = c_int

# /usr/include/ghostscript/iapi.h: 337
gsapi_run_string_continue = _libs['gs']['gsapi_run_string_continue']
gsapi_run_string_continue.argtypes = [POINTER(None), POINTER(c_char), c_uint, c_int, POINTER(c_int)]
gsapi_run_string_continue.restype = c_int

# /usr/include/ghostscript/iapi.h: 341
gsapi_run_string_end = _libs['gs']['gsapi_run_string_end']
gsapi_run_string_end.argtypes = [POINTER(None), c_int, POINTER(c_int)]
gsapi_run_string_end.restype = c_int

# /usr/include/ghostscript/iapi.h: 345
gsapi_run_string_with_length = _libs['gs']['gsapi_run_string_with_length']
gsapi_run_string_with_length.argtypes = [POINTER(None), POINTER(c_char), c_uint, c_int, POINTER(c_int)]
gsapi_run_string_with_length.restype = c_int

# /usr/include/ghostscript/iapi.h: 349
gsapi_run_string = _libs['gs']['gsapi_run_string']
gsapi_run_string.argtypes = [POINTER(None), POINTER(c_char), c_int, POINTER(c_int)]
gsapi_run_string.restype = c_int

# /usr/include/ghostscript/iapi.h: 353
gsapi_run_file = _libs['gs']['gsapi_run_file']
gsapi_run_file.argtypes = [POINTER(None), POINTER(c_char), c_int, POINTER(c_int)]
gsapi_run_file.restype = c_int

# /usr/include/ghostscript/iapi.h: 371
gsapi_exit = _libs['gs']['gsapi_exit']
gsapi_exit.argtypes = [POINTER(None)]
gsapi_exit.restype = c_int

# /usr/include/ghostscript/iapi.h: 396
enum_anon_11 = c_int

# /usr/include/ghostscript/iapi.h: 396
gs_spt_invalid = (-1)

# /usr/include/ghostscript/iapi.h: 396
gs_spt_null = 0

# /usr/include/ghostscript/iapi.h: 396
gs_spt_bool = 1

# /usr/include/ghostscript/iapi.h: 396
gs_spt_int = 2

# /usr/include/ghostscript/iapi.h: 396
gs_spt_float = 3

# /usr/include/ghostscript/iapi.h: 396
gs_spt_name = 4

# /usr/include/ghostscript/iapi.h: 396
gs_spt_string = 5

# /usr/include/ghostscript/iapi.h: 396
gs_spt_long = 6

# /usr/include/ghostscript/iapi.h: 396
gs_spt_i64 = 7

# /usr/include/ghostscript/iapi.h: 396
gs_spt_size_t = 8

# /usr/include/ghostscript/iapi.h: 396
gs_spt_parsed = 9

# /usr/include/ghostscript/iapi.h: 396
gs_spt_more_to_come = (1 << 31)

# /usr/include/ghostscript/iapi.h: 396
gs_set_param_type = enum_anon_11

# /usr/include/ghostscript/iapi.h: 400
gsapi_set_param = _libs['gs']['gsapi_set_param']
gsapi_set_param.argtypes = [POINTER(None), POINTER(c_char), POINTER(None), gs_set_param_type]
gsapi_set_param.restype = c_int

# /usr/include/ghostscript/iapi.h: 410
gsapi_get_param = _libs['gs']['gsapi_get_param']
gsapi_get_param.argtypes = [POINTER(None), POINTER(c_char), POINTER(None), gs_set_param_type]
gsapi_get_param.restype = c_int

# /usr/include/ghostscript/iapi.h: 432
gsapi_enumerate_params = _libs['gs']['gsapi_enumerate_params']
gsapi_enumerate_params.argtypes = [POINTER(None), POINTER(POINTER(None)), POINTER(POINTER(c_char)), POINTER(gs_set_param_type)]
gsapi_enumerate_params.restype = c_int

# /usr/include/ghostscript/iapi.h: 434
enum_anon_12 = c_int

# /usr/include/ghostscript/iapi.h: 434
GS_PERMIT_FILE_READING = 0

# /usr/include/ghostscript/iapi.h: 434
GS_PERMIT_FILE_WRITING = 1

# /usr/include/ghostscript/iapi.h: 434
GS_PERMIT_FILE_CONTROL = 2

# /usr/include/ghostscript/iapi.h: 442
gsapi_add_control_path = _libs['gs']['gsapi_add_control_path']
gsapi_add_control_path.argtypes = [POINTER(None), c_int, POINTER(c_char)]
gsapi_add_control_path.restype = c_int

# /usr/include/ghostscript/iapi.h: 446
gsapi_remove_control_path = _libs['gs']['gsapi_remove_control_path']
gsapi_remove_control_path.argtypes = [POINTER(None), c_int, POINTER(c_char)]
gsapi_remove_control_path.restype = c_int

# /usr/include/ghostscript/iapi.h: 450
gsapi_purge_control_paths = _libs['gs']['gsapi_purge_control_paths']
gsapi_purge_control_paths.argtypes = [POINTER(None), c_int]
gsapi_purge_control_paths.restype = None

# /usr/include/ghostscript/iapi.h: 453
gsapi_activate_path_control = _libs['gs']['gsapi_activate_path_control']
gsapi_activate_path_control.argtypes = [POINTER(None), c_int]
gsapi_activate_path_control.restype = None

# /usr/include/ghostscript/iapi.h: 456
gsapi_is_path_control_active = _libs['gs']['gsapi_is_path_control_active']
gsapi_is_path_control_active.argtypes = [POINTER(None)]
gsapi_is_path_control_active.restype = c_int

# /usr/include/ghostscript/iapi.h: 497
class struct_anon_13 (Structure):
    __slots__ = ['open_file', 'open_pipe', 'open_scratch', 'open_printer', 'open_handle']

struct_anon_13._fields_ = [
    ('open_file', CFUNCTYPE(UNCHECKED(c_int), POINTER(gs_memory_t), POINTER(None), POINTER(c_char), POINTER(c_char), POINTER(POINTER(gp_file)))),
    ('open_pipe', CFUNCTYPE(UNCHECKED(c_int), POINTER(gs_memory_t), POINTER(None), POINTER(c_char), POINTER(c_char), POINTER(c_char), POINTER(POINTER(gp_file)))),
    ('open_scratch', CFUNCTYPE(UNCHECKED(c_int), POINTER(gs_memory_t), POINTER(None), POINTER(c_char), POINTER(c_char), POINTER(c_char), c_int, POINTER(POINTER(gp_file)))),
    ('open_printer', CFUNCTYPE(UNCHECKED(c_int), POINTER(gs_memory_t), POINTER(None), POINTER(c_char), c_int, POINTER(POINTER(gp_file)))),
    ('open_handle', CFUNCTYPE(UNCHECKED(c_int), POINTER(gs_memory_t), POINTER(None), POINTER(c_char), POINTER(c_char), POINTER(POINTER(gp_file)))),
]

# /usr/include/ghostscript/iapi.h: 497
gsapi_fs_t = struct_anon_13

# /usr/include/ghostscript/iapi.h: 500
gsapi_add_fs = _libs['gs']['gsapi_add_fs']
gsapi_add_fs.argtypes = [POINTER(None), POINTER(gsapi_fs_t), POINTER(None)]
gsapi_add_fs.restype = c_int

# /usr/include/ghostscript/iapi.h: 503
gsapi_remove_fs = _libs['gs']['gsapi_remove_fs']
gsapi_remove_fs.argtypes = [POINTER(None), POINTER(gsapi_fs_t), POINTER(None)]
gsapi_remove_fs.restype = None

# /usr/include/ghostscript/iapi.h: 506
PFN_gsapi_revision = CFUNCTYPE(UNCHECKED(c_int), POINTER(gsapi_revision_t), c_int)

# /usr/include/ghostscript/iapi.h: 508
PFN_gsapi_new_instance = CFUNCTYPE(UNCHECKED(c_int), POINTER(POINTER(None)), POINTER(None))

# /usr/include/ghostscript/iapi.h: 510
PFN_gsapi_delete_instance = CFUNCTYPE(UNCHECKED(None), POINTER(None))

# /usr/include/ghostscript/iapi.h: 512
PFN_gsapi_set_stdio = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int), CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int), CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int))

# /usr/include/ghostscript/iapi.h: 516
PFN_gsapi_set_poll = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), CFUNCTYPE(UNCHECKED(c_int), POINTER(None)))

# /usr/include/ghostscript/iapi.h: 518
PFN_gsapi_set_display_callback = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(display_callback))

# /usr/include/ghostscript/iapi.h: 520
PFN_gsapi_set_default_device_list = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int)

# /usr/include/ghostscript/iapi.h: 522
PFN_gsapi_get_default_device_list = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(POINTER(c_char)), POINTER(c_int))

# /usr/include/ghostscript/iapi.h: 524
PFN_gsapi_init_with_args = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), c_int, POINTER(POINTER(c_char)))

# /usr/include/ghostscript/iapi.h: 532
PFN_gsapi_set_arg_encoding = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), c_int)

# /usr/include/ghostscript/iapi.h: 534
PFN_gsapi_run_string_begin = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), c_int, POINTER(c_int))

# /usr/include/ghostscript/iapi.h: 536
PFN_gsapi_run_string_continue = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_uint, c_int, POINTER(c_int))

# /usr/include/ghostscript/iapi.h: 539
PFN_gsapi_run_string_end = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), c_int, POINTER(c_int))

# /usr/include/ghostscript/iapi.h: 541
PFN_gsapi_run_string_with_length = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_uint, c_int, POINTER(c_int))

# /usr/include/ghostscript/iapi.h: 544
PFN_gsapi_run_string = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int, POINTER(c_int))

# /usr/include/ghostscript/iapi.h: 547
PFN_gsapi_run_file = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), c_int, POINTER(c_int))

# /usr/include/ghostscript/iapi.h: 555
PFN_gsapi_exit = CFUNCTYPE(UNCHECKED(c_int), POINTER(None))

# /usr/include/ghostscript/iapi.h: 556
PFN_gsapi_set_param = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(c_char), POINTER(None), gs_set_param_type)

# /usr/include/ghostscript/iapi.h: 558
PFN_gsapi_add_control_path = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), c_int, POINTER(c_char))

# /usr/include/ghostscript/iapi.h: 559
PFN_gsapi_remove_control_path = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), c_int, POINTER(c_char))

# /usr/include/ghostscript/iapi.h: 560
PFN_gsapi_purge_control_paths = CFUNCTYPE(UNCHECKED(None), POINTER(None), c_int)

# /usr/include/ghostscript/iapi.h: 561
PFN_gsapi_activate_path_control = CFUNCTYPE(UNCHECKED(None), POINTER(None), c_int)

# /usr/include/ghostscript/iapi.h: 562
PFN_gsapi_is_path_control_active = CFUNCTYPE(UNCHECKED(c_int), POINTER(None))

# /usr/include/ghostscript/iapi.h: 563
PFN_gsapi_add_fs = CFUNCTYPE(UNCHECKED(c_int), POINTER(None), POINTER(gsapi_fs_t), POINTER(None))

# /usr/include/ghostscript/iapi.h: 564
PFN_gsapi_remove_fs = CFUNCTYPE(UNCHECKED(None), POINTER(None), POINTER(gsapi_fs_t), POINTER(None))

# /usr/include/ghostscript/ierrors.h: 38
gs_error_names = (POINTER(c_char) * int(0)).in_dll(_libs['gs'], 'gs_error_names')

# /usr/include/ghostscript/gdevdsp.h: 99
DISPLAY_VERSION_MAJOR = 3

# /usr/include/ghostscript/gdevdsp.h: 100
DISPLAY_VERSION_MINOR = 0

# /usr/include/ghostscript/gdevdsp.h: 102
DISPLAY_VERSION_MAJOR_V1 = 1

# /usr/include/ghostscript/gdevdsp.h: 103
DISPLAY_VERSION_MINOR_V1 = 0

# /usr/include/ghostscript/gdevdsp.h: 105
DISPLAY_VERSION_MAJOR_V2 = 2

# /usr/include/ghostscript/gdevdsp.h: 106
DISPLAY_VERSION_MINOR_V2 = 0

# /usr/include/ghostscript/gdevdsp.h: 118
DISPLAY_COLORS_MASK = 0x8000f

# /usr/include/ghostscript/gdevdsp.h: 129
DISPLAY_ALPHA_MASK = 0x00f0

# /usr/include/ghostscript/gdevdsp.h: 146
DISPLAY_DEPTH_MASK = 0xff00

# /usr/include/ghostscript/gdevdsp.h: 155
DISPLAY_ENDIAN_MASK = 0x00010000

# /usr/include/ghostscript/gdevdsp.h: 162
DISPLAY_FIRSTROW_MASK = 0x00020000

# /usr/include/ghostscript/gdevdsp.h: 171
DISPLAY_555_MASK = 0x00040000

# /usr/include/ghostscript/gdevdsp.h: 189
DISPLAY_ROW_ALIGN_MASK = 0x00700000

# /usr/include/ghostscript/gdevdsp.h: 392
DISPLAY_CALLBACK_V1_SIZEOF = sizeof(struct_display_callback_v1_s)

# /usr/include/ghostscript/gdevdsp.h: 394
DISPLAY_CALLOUT_GET_CALLBACK = 0

# /usr/include/ghostscript/gdevdsp.h: 395
DISPLAY_CALLOUT_GET_CALLBACK_LEGACY = 1

# /usr/include/ghostscript/gserrors.h: 133
def gs_log_error(err, file, line):
    return err

# /usr/include/ghostscript/gserrors.h: 271
gs_okay = 0

# /usr/include/ghostscript/iapi.h: 464
gp_file_name_sizeof = 4096

# /usr/include/ghostscript/ierrors.h: 66
def GS_ERROR_IS_INTERRUPT(ecode):
    return ((ecode == gs_error_interrupt) or (ecode == gs_error_timeout))

# /usr/include/ghostscript/gdevdsp.h: 209
display_callback_s = struct_display_callback_s

# /usr/include/ghostscript/gdevdsp.h: 349
display_callback_v2_s = struct_display_callback_v2_s

# /usr/include/ghostscript/gdevdsp.h: 373
display_callback_v1_s = struct_display_callback_v1_s

# /usr/include/ghostscript/iapi.h: 126
gs_memory_s = struct_gs_memory_s

# /usr/include/ghostscript/iapi.h: 131
gp_file_s = struct_gp_file_s

# /usr/include/ghostscript/iapi.h: 139
gsapi_revision_s = struct_gsapi_revision_s

# -- End header members --

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment