/* Generated by Cython 0.16 on Fri Jul 13 22:15:59 2012 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02040000
    #error Cython requires Python 2.4+.
#else
#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif

#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif

#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif

#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyCFunction_Call PyObject_Call
#else
  #define __Pyx_PyCFunction_Call PyCFunction_Call
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  #define __PYX_BUILD_PY_SSIZE_T "i"
#else
  #define __PYX_BUILD_PY_SSIZE_T "n"
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)

  typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif

#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
  #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif


#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_GET_LENGTH)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif

#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)

#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif

#if PY_VERSION_HEX < 0x03020000
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif

#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif

#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__smc__freeimage___freeimage
#define __PYX_HAVE_API__smc__freeimage___freeimage
#include "stdio.h"
#include "pythread.h"
#include "stddef.h"
#include "smc_fi.h"
#include "wchar.h"
#include "time.h"
#include "inttypes.h"
#include "FreeImage.h"
#include "stdlib.h"
#include "string.h"
#include "errno.h"
#include "lcms2.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* inline attribute */
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))

#ifdef __GNUC__
  /* Test for GCC > 2.95 */
  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
    #define likely(x)   __builtin_expect(!!(x), 1)
    #define unlikely(x) __builtin_expect(!!(x), 0)
  #else /* __GNUC__ > 2 ... */
    #define likely(x)   (x)
    #define unlikely(x) (x)
  #endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "_lcms.pxi",
  "_freeimage.pyx",
  "bool.pxd",
  "complex.pxd",
};

/*--- Type declarations ---*/
struct __pyx_obj_3smc_9freeimage_10_freeimage_Image;
struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo;
struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache;
struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo;
struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation;
struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO;
struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo;
struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper;
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_createHProfile;
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setOutProfile;
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation__createProfile;
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setTransform;
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readMLU;
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIEXYZ;
struct __pyx_t_3smc_9freeimage_10_freeimage_SmcFiError;

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":98
 *     pass
 * 
 * cdef lcms.cmsHPROFILE createHProfile(char * iccprofile, unsigned int size, mode="in") except * :             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsHPROFILE hProfile = NULL
 *     cdef lcms.cmsToneCurve * curve
 */
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_createHProfile {
  int __pyx_n;
  PyObject *mode;
};

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":159
 *         self.hInProfile = createHProfile(iccprofile, size, "in")
 * 
 *     cdef setOutProfile(self, char * iccprofile, unsigned int size=0):             # <<<<<<<<<<<<<<
 *         self.hOutProfile = createHProfile(iccprofile, size, "out")
 * 
 */
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setOutProfile {
  int __pyx_n;
  unsigned int size;
};

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":162
 *         self.hOutProfile = createHProfile(iccprofile, size, "out")
 * 
 *     cdef lcms.cmsHPROFILE _createProfile(self, char * iccprofile, unsigned int size, mode="in") except * :             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsHPROFILE hProfile = NULL
 *         cdef lcms.cmsToneCurve * curve
 */
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation__createProfile {
  int __pyx_n;
  PyObject *mode;
};

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":191
 *         return hProfile
 * 
 *     cdef setTransform(self, int inputformat, int outputformat,             # <<<<<<<<<<<<<<
 *                       int intent=lcms.INTENT_PERCEPTUAL,
 *                       unsigned long flags=0):
 */
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setTransform {
  int __pyx_n;
  int intent;
  unsigned long flags;
};

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":443
 *             lcms.cmsCloseProfile(self.hProfile)
 * 
 *     cdef _readMLU(self, lcms.cmsTagSignature info, char * language="en", char * country=lcms.cmsNoCountry):             # <<<<<<<<<<<<<<
 *         cdef int read
 *         cdef lcms.const_cmsMLU * mlu
 */
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readMLU {
  int __pyx_n;
  char *language;
  char *country;
};

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":464
 *         return uni
 * 
 *     cdef _readCIEXYZ(self, lcms.cmsTagSignature info, multi=False):             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsCIEXYZ * XYZ
 *         if not lcms.cmsIsTag(self.hProfile, info):
 */
struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIEXYZ {
  int __pyx_n;
  PyObject *multi;
};

/* "smc/freeimage/_freeimage.pyx":180
 * cdef int tls_key = -1
 * 
 * cdef struct SmcFiError:             # <<<<<<<<<<<<<<
 *     fi.FREE_IMAGE_FORMAT format
 *     char *msg
 */
struct __pyx_t_3smc_9freeimage_10_freeimage_SmcFiError {
  enum FREE_IMAGE_FORMAT format;
  char *msg;
  int msglen;
};

/* "smc/freeimage/_freeimage.pyx":51
 * # ***
 * # forward declarations
 * cdef class Image             # <<<<<<<<<<<<<<
 * cdef class FormatInfo
 * 
 */
struct __pyx_obj_3smc_9freeimage_10_freeimage_Image {
  PyObject_HEAD
  struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *__pyx_vtab;
  unsigned int width;
  unsigned int height;
  enum FREE_IMAGE_FORMAT _format;
  char *_filename;
  unsigned int buffers;
  FIBITMAP *_dib;
  FIICCPROFILE *_icc;
};


/* "smc/freeimage/_freeimage.pyx":52
 * # forward declarations
 * cdef class Image
 * cdef class FormatInfo             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "errno.h" nogil:
 */
struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo {
  PyObject_HEAD
  enum FREE_IMAGE_FORMAT _format;
};


/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":235
 * 
 * 
 * cdef class LCMSIccCache(object):             # <<<<<<<<<<<<<<
 *     cdef object _cache
 *     cdef readonly int creations
 */
struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache {
  PyObject_HEAD
  struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_vtab;
  PyObject *_cache;
  int creations;
};


/* "smc/freeimage/_freeimage.pyx":372
 * 
 * 
 * cdef class _BitmapInfo:             # <<<<<<<<<<<<<<
 *     """Wrapper for bitmap info header
 *     """
 */
struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo {
  PyObject_HEAD
  DWORD size;
  LONG width;
  LONG height;
  WORD planes;
  WORD bit_count;
  DWORD compression;
  DWORD size_image;
  LONG xppm;
  LONG yppm;
  DWORD colors_used;
  DWORD colors_important;
};


/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":128
 * 
 * 
 * cdef class LCMSTransformation(object):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsHPROFILE hInProfile
 *     cdef lcms.cmsHPROFILE hOutProfile
 */
struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation {
  PyObject_HEAD
  struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_vtab;
  cmsHPROFILE hInProfile;
  cmsHPROFILE hOutProfile;
  cmsHTRANSFORM hTransform;
  PyObject *inprofile;
  PyObject *outprofile;
  int format;
  int intent;
  unsigned long flags;
  PyObject *hash;
};


/* "smc/freeimage/_freeimage.pyx":431
 * 
 * 
 * cdef class _MemoryIO:             # <<<<<<<<<<<<<<
 *     """Memory IO interface to an image
 * 
 */
struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO {
  PyObject_HEAD
  struct FIMEMORY *_mem;
  int size;
  enum FREE_IMAGE_FORMAT _format;
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *_img;
};


/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":416
 * _illu_map = {0: "unknown", 1: "D50", 2: "D65", 3: "D93", 4: "F2", 5: "D55", 6: "A", 7: "E", 8: "F8"}
 * 
 * cdef class LCMSProfileInfo(object):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsHPROFILE hProfile
 *     cdef public dict info
 */
struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo {
  PyObject_HEAD
  struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_vtab;
  cmsHPROFILE hProfile;
  PyObject *info;
};


/* "smc/freeimage/_freeimage.pyx":355
 * #    return rgb
 * 
 * cdef class _DibWrapper:             # <<<<<<<<<<<<<<
 *     """Wrapper for bitmaps
 *     """
 */
struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper {
  PyObject_HEAD
  FIBITMAP *dib;
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *oldimg;
};



/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":128
 * 
 * 
 * cdef class LCMSTransformation(object):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsHPROFILE hInProfile
 *     cdef lcms.cmsHPROFILE hOutProfile
 */

struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSTransformation {
  PyObject *(*setInProfile)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *, char *, unsigned int);
  PyObject *(*setOutProfile)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *, char *, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setOutProfile *__pyx_optional_args);
  cmsHPROFILE (*_createProfile)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *, char *, unsigned int, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation__createProfile *__pyx_optional_args);
  PyObject *(*setTransform)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *, int, int, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setTransform *__pyx_optional_args);
};
static struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSTransformation;


/* "smc/freeimage/_freeimage.pyx":647
 * 
 * 
 * cdef class Image:             # <<<<<<<<<<<<<<
 *     """Image(filename[, buffer=None[, flags=0]])
 * 
 */

struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image {
  PyObject *(*from_filename)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, PyObject *, int);
  PyObject *(*from_bitmap)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *);
  PyObject *(*from_buffer)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, PyObject *, int);
  PyObject *(*_init_infos)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *);
  PyObject *(*_check_closed)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *);
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *(*convert_helper)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, FI_ConvertFunction);
  int (*hline_rgb24)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, RGBQUAD *, unsigned int, unsigned int, unsigned int, unsigned int);
  int (*hline_mono)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, BYTE, unsigned int, unsigned int, unsigned int, unsigned int);
  int (*vline_rgb24)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, RGBQUAD *, unsigned int, unsigned int, unsigned int, unsigned int);
  int (*vline_mono)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, BYTE, unsigned int, unsigned int, unsigned int, unsigned int);
};
static struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *__pyx_vtabptr_3smc_9freeimage_10_freeimage_Image;


/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":416
 * _illu_map = {0: "unknown", 1: "D50", 2: "D65", 3: "D93", 4: "F2", 5: "D55", 6: "A", 7: "E", 8: "F8"}
 * 
 * cdef class LCMSProfileInfo(object):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsHPROFILE hProfile
 *     cdef public dict info
 */

struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo {
  PyObject *(*_readMLU)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *, cmsTagSignature, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readMLU *__pyx_optional_args);
  PyObject *(*_readCIEXYZ)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *, cmsTagSignature, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIEXYZ *__pyx_optional_args);
  PyObject *(*_calculateRGBPrimaries)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *);
  PyObject *(*_readCIEXYZWhitePointTemp)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *);
  PyObject *(*_readCIExyYTriple)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *, cmsTagSignature);
  PyObject *(*_readSignature)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *, cmsTagSignature);
  PyObject *(*_readICCMeasurementCond)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *);
  PyObject *(*_readICCViewingCond)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *);
  PyObject *(*_parse)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *);
};
static struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSProfileInfo;


/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":235
 * 
 * 
 * cdef class LCMSIccCache(object):             # <<<<<<<<<<<<<<
 *     cdef object _cache
 *     cdef readonly int creations
 */

struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSIccCache {
  PyObject *(*addEntry)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *, PyObject *, PyObject *, int, int, unsigned long);
};
static struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSIccCache;
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          if (acquire_gil) { \
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
              PyGILState_Release(__pyx_gilstate_save); \
          } else { \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext() \
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/

#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
    const char* function_name); /*proto*/

#define __Pyx_SetItemInt(o, i, v, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_SetItemInt_Fast(o, i, v) : \
                                                    __Pyx_SetItemInt_Generic(o, to_py_func(i), v))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v) {
    if (PyList_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    }
    else if (likely(i >= 0)) {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            return m->sq_ass_item(o, i, v);
        }
    }
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/

static CYTHON_INLINE int __Pyx_NegateNonNeg(int b) {
    return unlikely(b < 0) ? b : !b;
}
static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
}

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
    if (PyList_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (likely(i >= 0)) {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            return m->sq_item(o, i);
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);

#if PY_MAJOR_VERSION >= 3
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    if (unlikely(d == Py_None)) {
        __Pyx_RaiseNoneIndexingError();
        return NULL;
    }
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred())
            PyErr_SetObject(PyExc_KeyError, key);
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

#include <string.h>

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/

static PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        if (unlikely(PyDict_SetItem(d, key, default_value) == -1))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            if (unlikely(PyDict_SetItem(d, key, default_value) == -1))
                return NULL;
            value = default_value;
        }
        Py_INCREF(value);
    } else {
        PyObject *m;
        m = __Pyx_GetAttrString(d, "setdefault");
        if (!m) return NULL;
        value = PyObject_CallFunctionObjArgs(m, key, default_value, NULL);
        Py_DECREF(m);
    }
#endif
    return value;
}

static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int32_t(int32_t);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint16_t(uint16_t);

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

#include "descrobject.h"
static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name);

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname); /*proto*/

#define __Pyx_CyFunction_USED 1
#include <structmember.h>
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f) \
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f) \
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f) \
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
    int flags;
    PyObject *func_dict;
    PyObject *func_weakreflist;
    PyObject *func_name;
    PyObject *func_doc;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj; /* No-args super() class cell */
    void *defaults;
    int defaults_pyobjects;
    PyObject *defaults_tuple; /* Const defaults tuple */
    PyObject *(*defaults_getter)(PyObject *);
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_NewEx(ml, flags, self, module, code) \
    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, self, module, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *,
                                      PyMethodDef *ml, int flags,
                                      PyObject *self, PyObject *module,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static int __Pyx_CyFunction_init(void);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_cmsUInt32Number(cmsUInt32Number);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_cmsUInt64Number(cmsUInt64Number);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_cmsBool(cmsBool);

static CYTHON_INLINE cmsUInt32Number __Pyx_PyInt_from_py_cmsUInt32Number(PyObject *);

static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject *);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint8_t(uint8_t);

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename); /*proto*/

static int __Pyx_check_binary_version(void);

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);  /*proto*/

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/


/* Module declarations from 'cpython.version' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'cpython.exc' */

/* Module declarations from 'cpython.module' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'cpython.tuple' */

/* Module declarations from 'cpython.list' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.sequence' */

/* Module declarations from 'cpython.mapping' */

/* Module declarations from 'cpython.iterator' */

/* Module declarations from 'cpython.type' */

/* Module declarations from 'cpython.number' */

/* Module declarations from 'cpython.int' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;

/* Module declarations from 'cpython.long' */

/* Module declarations from 'cpython.float' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;

/* Module declarations from 'cpython.string' */

/* Module declarations from 'cpython.unicode' */

/* Module declarations from 'cpython.dict' */

/* Module declarations from 'cpython.instance' */

/* Module declarations from 'cpython.function' */

/* Module declarations from 'cpython.method' */

/* Module declarations from 'cpython.weakref' */

/* Module declarations from 'cpython.getargs' */

/* Module declarations from 'cpython.pythread' */

/* Module declarations from 'cpython.pystate' */

/* Module declarations from 'cpython.cobject' */

/* Module declarations from 'cpython.oldbuffer' */

/* Module declarations from 'cpython.set' */

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.bytes' */

/* Module declarations from 'cpython.pycapsule' */

/* Module declarations from 'cpython' */

/* Module declarations from 'libc' */

/* Module declarations from 'libc.stddef' */

/* Module declarations from 'smc.freeimage.smc_fi' */

/* Module declarations from 'smc.freeimage.freeimage' */

/* Module declarations from 'libc.stdlib' */

/* Module declarations from 'libc.string' */

/* Module declarations from 'smc.freeimage.lcms' */

/* Module declarations from 'smc.freeimage._freeimage' */
static PyTypeObject *__pyx_ptype_3smc_9freeimage_10_freeimage_Image = 0;
static PyTypeObject *__pyx_ptype_3smc_9freeimage_10_freeimage_FormatInfo = 0;
static PyTypeObject *__pyx_ptype_3smc_9freeimage_10_freeimage_LCMSTransformation = 0;
static PyTypeObject *__pyx_ptype_3smc_9freeimage_10_freeimage_LCMSIccCache = 0;
static PyTypeObject *__pyx_ptype_3smc_9freeimage_10_freeimage_LCMSProfileInfo = 0;
static PyTypeObject *__pyx_ptype_3smc_9freeimage_10_freeimage__DibWrapper = 0;
static PyTypeObject *__pyx_ptype_3smc_9freeimage_10_freeimage__BitmapInfo = 0;
static PyTypeObject *__pyx_ptype_3smc_9freeimage_10_freeimage__MemoryIO = 0;
static PyObject *__pyx_v_3smc_9freeimage_10_freeimage__logger = 0;
static int __pyx_v_3smc_9freeimage_10_freeimage_tls_key;
static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_funicode(const char*); /*proto*/
static PyObject *__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(PyObject *); /*proto*/
static void __pyx_f_3smc_9freeimage_10_freeimage_errorHandler(cmsContext, cmsUInt32Number, const char* *); /*proto*/
static cmsHPROFILE __pyx_f_3smc_9freeimage_10_freeimage_createHProfile(char *, unsigned int, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_createHProfile *__pyx_optional_args); /*proto*/
static int __pyx_f_3smc_9freeimage_10_freeimage_lcmsFI(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *); /*proto*/
static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_int2str(unsigned int); /*proto*/
static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_xyz_py(cmsCIEXYZ *); /*proto*/
static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_xyztrip_py(cmsCIEXYZTRIPLE *); /*proto*/
static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_xyz3_py(cmsCIEXYZ *); /*proto*/
static void __pyx_f_3smc_9freeimage_10_freeimage_clearError(void); /*proto*/
static void __pyx_f_3smc_9freeimage_10_freeimage_setError(enum FREE_IMAGE_FORMAT, const char*); /*proto*/
static char *__pyx_f_3smc_9freeimage_10_freeimage_getError(void); /*proto*/
static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_initErrorHandler(void); /*proto*/
static struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(FIBITMAP *, PyObject *); /*proto*/
static struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_f_3smc_9freeimage_10_freeimage_BitmapInfo(BITMAPINFOHEADER *); /*proto*/
static int __pyx_f_3smc_9freeimage_10_freeimage_floodfill(FIBITMAP *, unsigned int, unsigned int, unsigned int, unsigned int); /*proto*/
static void __pyx_f_3smc_9freeimage_10_freeimage_removeAllMetadata(FIBITMAP *); /*proto*/
static int __pyx_f_3smc_9freeimage_10_freeimage_cloneICCProfile(FIBITMAP *, FIBITMAP *); /*proto*/
static void __pyx_f_3smc_9freeimage_10_freeimage_initialize(void); /*proto*/
#define __Pyx_MODULE_NAME "smc.freeimage._freeimage"
int __pyx_module_is_main_smc__freeimage___freeimage = 0;

/* Implementation of 'smc.freeimage._freeimage' */
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_staticmethod;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_open;
static PyObject *__pyx_builtin_hex;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_IOError;
static PyObject *__pyx_builtin_SystemError;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_round;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_getLCMSVersion(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_2XYZ2xyY(CYTHON_UNUSED PyObject *__pyx_self, float __pyx_v_X, float __pyx_v_Y, float __pyx_v_Z); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_4xyY2XYZ(CYTHON_UNUSED PyObject *__pyx_self, float __pyx_v_x, float __pyx_v_y, float __pyx_v_Y); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_6tempFromWhitePoint(CYTHON_UNUSED PyObject *__pyx_self, float __pyx_v_x, float __pyx_v_y, float __pyx_v_Y); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_8getIntents(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self, PyObject *__pyx_v_inprofile, PyObject *__pyx_v_outprofile, int __pyx_v_format, int __pyx_v_intent, unsigned long __pyx_v_flags); /* proto */
static Py_hash_t __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_2__hash__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self); /* proto */
static void __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_4__dealloc__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_9inprofile___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_10outprofile___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_6format___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_6intent___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_5flags___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_2clear(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_4keys(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_6__iter__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_8__contains__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_10lookupByImage(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_img, PyObject *__pyx_v_outprofile, int __pyx_v_format, int __pyx_v_intent, unsigned long __pyx_v_flags); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_12lookup(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self, PyObject *__pyx_v_inprofile, PyObject *__pyx_v_outprofile, int __pyx_v_format, int __pyx_v_intent, unsigned long __pyx_v_flags); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_14applyTransform(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_img, PyObject *__pyx_v_inprofile, PyObject *__pyx_v_outprofile, int __pyx_v_intent, unsigned long __pyx_v_flags); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_9creations___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self, PyObject *__pyx_v_data, PyObject *__pyx_v_filename); /* proto */
static void __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_2__dealloc__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4_readNamedColorList(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self, cmsTagSignature __pyx_v_info); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_2__set__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_4__del__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10dispatchFIError(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_14FreeImageError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fimsg, PyObject *__pyx_v_args); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo___repr__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_4size___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_5width___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_6height___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_6planes___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_9bit_count___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_11compression___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_10size_image___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_4xppm___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_4yppm___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_11colors_used___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_16colors_important___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_img, int __pyx_v_format, int __pyx_v_flags); /* proto */
static void __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_2__dealloc__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self); /* proto */
#if PY_MAJOR_VERSION < 3
static Py_ssize_t __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_4__getreadbuffer__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self, int __pyx_v_index, void **__pyx_v_ptr); /* proto */
#endif
#if PY_MAJOR_VERSION < 3
static Py_ssize_t __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_6__getsegcount__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self, Py_ssize_t *__pyx_v_lenp); /* proto */
#endif
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_8__str__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_6format___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_10tell(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_12seek(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self, int __pyx_v_offset, unsigned int __pyx_v_whence); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_14read(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self, signed int __pyx_v_size); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_4size___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12_new_image(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_width, unsigned int __pyx_v_height, unsigned int __pyx_v_bpp, unsigned int __pyx_v_red_mask, unsigned int __pyx_v_green_mask, unsigned int __pyx_v_blue_mask); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_5Image___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_buffer, struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *__pyx_v__bitmap, int __pyx_v_fd, int __pyx_v_flags); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_2close(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static void __pyx_pf_3smc_9freeimage_10_freeimage_5Image_4__dealloc__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_6__sizeof__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_8__repr__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_10__enter__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_12__exit__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_exc, CYTHON_UNUSED PyObject *__pyx_v_value, CYTHON_UNUSED PyObject *__pyx_v_tb); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_8filename___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_4size___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_6format___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_4type___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_8mimetype___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_x___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_x_2__set__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_dpi); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_y___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_y_2__set__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_dpi); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_3dpi___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_x___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_x_2__set__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_dpm); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_y___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_y_2__set__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_dpm); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_3dpm___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_11colors_used___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_3bpp___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_7has_icc___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_8icc_cmyk___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_10color_type___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_15color_type_name___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_14is_transparent___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_12has_bg_color___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_8rgb_mask___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_10colororder___get__(CYTHON_UNUSED struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_10has_pixels___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_6closed___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_14floodfill(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_red, int __pyx_v_green, int __pyx_v_blue); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_16save(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, PyObject *__pyx_v_filename, int __pyx_v_format, int __pyx_v_flags); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_18toBuffer(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_format, int __pyx_v_flags); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_20toPIL(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_format, int __pyx_v_flags); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_22resize(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_width, int __pyx_v_height, int __pyx_v_filter); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_24paste(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_src, unsigned int __pyx_v_left, unsigned int __pyx_v_top, unsigned int __pyx_v_alpha); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_26clone(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_28crop(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_left, int __pyx_v_top, int __pyx_v_right, int __pyx_v_bottom); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_30convert_4bits(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_32convert_8bits(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_34greyscale(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_36convert_16bits555(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_38convert_16bits565(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_40convert_24bits(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_42convert_32bits(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_44convert_rgbf(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_46to_standard(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_scale_linear); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_48to_type(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_dst_type, int __pyx_v_scale_linear); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_50dither(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_dither_alg); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_52threshold(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_threshold); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_54flipHorizontal(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_56flipVertical(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_58rotate(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_angle); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_60rotateEx(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, double __pyx_v_angle, double __pyx_v_x_shift, double __pyx_v_y_shift, double __pyx_v_x_origin, double __pyx_v_y_origin, int __pyx_v_use_mask); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_62getICC(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_64removeICC(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_66iccTransform(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_trafo); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_68getMetadataCount(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_70getMetadata(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_72copyMetadataFrom(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_src); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_74clearMetadata(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_76getInfoHeader(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_78adjustColors(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_brightness, float __pyx_v_contrast, float __pyx_v_gamma, PyObject *__pyx_v_invert); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_80adjustGamma(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_gamma); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_82adjustBrightness(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_brigthness); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_84adjustContrast(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_contrast); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_86invert(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_88getHistogram(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_channel); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_90hline(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_y, unsigned int __pyx_v_xstart, signed int __pyx_v_xend, unsigned int __pyx_v_linewidth, unsigned int __pyx_v_red, unsigned int __pyx_v_green, unsigned int __pyx_v_blue); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_92vline(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_x, unsigned int __pyx_v_ystart, signed int __pyx_v_yend, unsigned int __pyx_v_linewidth, unsigned int __pyx_v_red, unsigned int __pyx_v_green, unsigned int __pyx_v_blue); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_5width___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_6height___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_14FormatInfo_from_filename(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_filename); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_16FormatInfo_from_file(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_filename); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18FormatInfo_from_mimetype(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_mime); /* proto */
static int __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self, int __pyx_v_format); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_2__int__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_6format___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_8mimetype___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_4name___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_11description___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_14magic_reg_expr___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_reading___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_writing___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_12supports_icc___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_17supports_nopixels___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_4getExtensions(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_6getSupportsExportType(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self, int __pyx_v_type); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_8getSupportsExportBPP(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self, int __pyx_v_bpp); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_20getVersion(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_22getCompiledFor(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_24getCopyright(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_26getFormatCount(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_28lookupX11Color(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_30lookupSVGColor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_32jpegTransform(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src, PyObject *__pyx_v_dst, unsigned int __pyx_v_op, unsigned int __pyx_v_perfect); /* proto */
static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_34hasJPEGTurbo(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static char __pyx_k_1[] = "UTF-8";
static char __pyx_k_2[] = "utf-8";
static char __pyx_k_4[] = "Failed to create sRGB %s profile";
static char __pyx_k_5[] = "Failed to create gray %s profile";
static char __pyx_k_6[] = "Failed to set %s profile";
static char __pyx_k_10[] = "No in profile";
static char __pyx_k_12[] = "No out profile";
static char __pyx_k_14[] = "Failed to create transformation";
static char __pyx_k_17[] = "Image has no data";
static char __pyx_k_19[] = "Image has no embedded ICC profile";
static char __pyx_k_21[] = "Only 8, 16, 24 and 48bpp images are supported for now, image_type = %s, bbp: %s";
static char __pyx_k_22[] = "Failed to lookup or create transformation";
static char __pyx_k_24[] = "Transformation has no transformation handle";
static char __pyx_k_28[] = "Only 24bit bitmaps are supported for now, image_type = %s, bbp: %s";
static char __pyx_k_30[] = "Failed to set in profile";
static char __pyx_k_34[] = "45/0, 0/45";
static char __pyx_k_35[] = "0d, d/0";
static char __pyx_k_36[] = "screeningDescription";
static char __pyx_k_37[] = "perceptualRenderingIntentGamut";
static char __pyx_k_38[] = "saturationRenderingIntentGamut";
static char __pyx_k_39[] = "mediaWhitePointTemperature";
static char __pyx_k_40[] = "iccMeasurementCondition";
static char __pyx_k_41[] = "Already initializes";
static char __pyx_k_43[] = "no space";
static char __pyx_k_45[] = "FreeImageMemoryError";
static char __pyx_k_46[] = "<BitmapInfo size=%lu, width=%ld, height=%ld, planes=%d, bit_count=%d, compression=%lu, size_image=%lu, xppm=%d, yppm=%d, colors_used=%lu, colors_important=%lu>";
static char __pyx_k_47[] = "Operation on closed image";
static char __pyx_k_49[] = "Invalid image format";
static char __pyx_k_51[] = "fi.FreeImage_OpenMemory() has failed";
static char __pyx_k_52[] = "Can't save image to memory";
static char __pyx_k_53[] = "accessing non-existent string segment";
static char __pyx_k_56[] = "whence must be 0, 1 or 2";
static char __pyx_k_58[] = "Failure during seek";
static char __pyx_k_59[] = "";
static char __pyx_k_60[] = "Invalid size";
static char __pyx_k_62[] = "Failed to read %i bytes (requested %i)";
static char __pyx_k_63[] = "Unable to allocate image";
static char __pyx_k_64[] = "Exactly one argument must be applied";
static char __pyx_k_66[] = "Flags argument not used";
static char __pyx_k_68[] = "<bitmap>";
static char __pyx_k_69[] = "<buffer>";
static char __pyx_k_70[] = "Image is still access from %i buffer%s.";
static char __pyx_k_71[] = "<%s %ix%i %ibpp (%s; %s) at 0x%x>";
static char __pyx_k_73[] = "DPI must be positive or zero.";
static char __pyx_k_76[] = "Wrong arguments, colors must be between 0% and 100%";
static char __pyx_k_78[] = "floodfill for type: %i, bpp:  %i";
static char __pyx_k_79[] = "Invalid format %i";
static char __pyx_k_80[] = "Failed to save image to file '%s'";
static char __pyx_k_81[] = "tuBuffer() not implemented for 3.x yet";
static char __pyx_k_83[] = "PIL.Image";
static char __pyx_k_85[] = "Failed to resize image";
static char __pyx_k_86[] = "Operation on closed source image";
static char __pyx_k_88[] = "Failed to paste image";
static char __pyx_k_89[] = "Failed to clone image";
static char __pyx_k_90[] = "Boundaries must be larger than 0";
static char __pyx_k_92[] = "Failed to copy image";
static char __pyx_k_93[] = "Failed to convert image";
static char __pyx_k_94[] = "Failed to dither image";
static char __pyx_k_95[] = "Threshold must be between 0 and 255";
static char __pyx_k_97[] = "Failed to applying threshold to image";
static char __pyx_k_98[] = "Only -90, 90, 180, 270 are supported";
static char __pyx_k__A[] = "A";
static char __pyx_k__E[] = "E";
static char __pyx_k__X[] = "X";
static char __pyx_k__Y[] = "Y";
static char __pyx_k__Z[] = "Z";
static char __pyx_k__i[] = "i";
static char __pyx_k__n[] = "n";
static char __pyx_k__r[] = "r";
static char __pyx_k__s[] = "s";
static char __pyx_k__x[] = "x";
static char __pyx_k__y[] = "y";
static char __pyx_k_100[] = "Failed to rotate image";
static char __pyx_k_102[] = "Failed to copy metadata";
static char __pyx_k_103[] = "Failed to delete metadata model %s";
static char __pyx_k_104[] = "Brightness must be between -100. and +100. (percentage)";
static char __pyx_k_106[] = "Contrast must be between -100 and +100 (percentage)";
static char __pyx_k_108[] = "Gamma must be greater than 0.";
static char __pyx_k_110[] = "Failed to adjust color.";
static char __pyx_k_112[] = "%i bpp image supports histogram for red, green, blue or black channels only, got %i.";
static char __pyx_k_113[] = "8 bpp image supports histogram for black channel only, got %i.";
static char __pyx_k_114[] = "%i bpp is not supported by histogram function.";
static char __pyx_k_115[] = "Failed to retrieve histogram.";
static char __pyx_k_116[] = "y must be smaller than height of image";
static char __pyx_k_118[] = "x start must be smaller than x end";
static char __pyx_k_120[] = "Invalid line height";
static char __pyx_k_122[] = "hline for type: %i, bpp:  %i";
static char __pyx_k_123[] = "x must be smaller than width of image";
static char __pyx_k_125[] = "y start must be smaller than y end";
static char __pyx_k_127[] = "Invalid line width";
static char __pyx_k_129[] = "vline for type: %i, bpp:  %i";
static char __pyx_k_130[] = "Unable to detect format.";
static char __pyx_k_131[] = ",";
static char __pyx_k_133[] = "Invalid type %i";
static char __pyx_k_134[] = "Cannot lookup X11 color %s";
static char __pyx_k_135[] = "Cannot lookup SVG color %s";
static char __pyx_k_136[] = "OP not in range 0-7";
static char __pyx_k_138[] = "JPEG Transformation of '%s' to '%s' with op '%i' failed.";
static char __pyx_k_139[] = "filename\n        ";
static char __pyx_k_140[] = "size -> (widht: int, height: int)\n        ";
static char __pyx_k_141[] = "format -> int (fi.FIF_*)\n\n        Format is the image format like fi.FIF_JPEG or fi.FIF_PNG.\n        ";
static char __pyx_k_142[] = "type -> int (fi.FIT_*)\n\n        Type referes to the data type of the image like fi.FIT_BITMAP or fi.FIT_RGBF.\n        ";
static char __pyx_k_143[] = "mimetype -> str\n\n        mimetype of the image, e.g. image/jpeg\n        ";
static char __pyx_k_144[] = "dpi_x -> int\n\n        Dots per inch (x axis)\n        ";
static char __pyx_k_145[] = "dpi_y -> int\n\n        Dots per inch (y axis)\n        ";
static char __pyx_k_146[] = "dpi -> (dpi_x: int, dpi_y: int)\n        ";
static char __pyx_k_147[] = "dpm_x -> int\n\n        Dots per meter (x axis)\n        ";
static char __pyx_k_148[] = "dpm_y -> int\n\n        Dots per meter (y axis)\n        ";
static char __pyx_k_149[] = "dpm -> (dpm_x: int, dpm_y: int)\n        ";
static char __pyx_k_150[] = "colors_used -> int\n\n        Returns number of colors used in the image (palette-size) or 0 for\n        high color images.\n        ";
static char __pyx_k_151[] = "bpp -> int\n\n        bits per pixel\n        ";
static char __pyx_k_152[] = "has_icc -> bool\n\n        Returns true if the image has an ICC profile\n        ";
static char __pyx_k_153[] = "icc_cmyk -> bool\n        ";
static char __pyx_k_154[] = "color_type -> int (fi.FIC_*)\n\n        Get color type of the image, e.g. fi.FIC_MINISBLACK, fi.FIC_RGB, fi.FIC_CMYK ...\n        ";
static char __pyx_k_155[] = "color_type_name -> str\n        ";
static char __pyx_k_156[] = "is_transparent -> bool\n        ";
static char __pyx_k_157[] = "has_bg_color -> bool\n        ";
static char __pyx_k_158[] = "Get bitmask for red, green and blue channel\n        ";
static char __pyx_k_159[] = "Get color order (BGR or RGB)\n\n        The color order depends on the endianess of the system\n        ";
static char __pyx_k_160[] = "Check if image is loaded with fi.FIF_LOAD_NOPIXELS\n\n        @return: True if image has pixel and isn't loaded with fi.FIF_LOAD_NOPIXELS\n        ";
static char __pyx_k_161[] = "closed -> bool\n        ";
static char __pyx_k_163[] = "smc.freeimage.lcms";
static char __pyx_k_165[] = "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi";
static char __pyx_k_166[] = "smc.freeimage._freeimage";
static char __pyx_k_177[] = "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_freeimage.pyx";
static char __pyx_k_185[] = "FormatInfo_from_filename";
static char __pyx_k_188[] = "FormatInfo_from_file";
static char __pyx_k_191[] = "FormatInfo_from_mimetype";
static char __pyx_k__F2[] = "F2";
static char __pyx_k__F8[] = "F8";
static char __pyx_k__en[] = "en";
static char __pyx_k__fd[] = "fd";
static char __pyx_k__id[] = "id";
static char __pyx_k__in[] = "in";
static char __pyx_k__op[] = "op";
static char __pyx_k__rb[] = "rb";
static char __pyx_k__tb[] = "tb";
static char __pyx_k__BGR[] = "BGR";
static char __pyx_k__D50[] = "D50";
static char __pyx_k__D55[] = "D55";
static char __pyx_k__D65[] = "D65";
static char __pyx_k__D93[] = "D93";
static char __pyx_k__DIB[] = "DIB";
static char __pyx_k__RGB[] = "RGB";
static char __pyx_k__XYZ[] = "XYZ";
static char __pyx_k__bpp[] = "bpp";
static char __pyx_k__cls[] = "cls";
static char __pyx_k__dib[] = "dib";
static char __pyx_k__dst[] = "dst";
static char __pyx_k__err[] = "err";
static char __pyx_k__exc[] = "exc";
static char __pyx_k__get[] = "get";
static char __pyx_k__hex[] = "hex";
static char __pyx_k__img[] = "img";
static char __pyx_k__msg[] = "msg";
static char __pyx_k__new[] = "new";
static char __pyx_k__out[] = "out";
static char __pyx_k__red[] = "red";
static char __pyx_k__src[] = "src";
static char __pyx_k__sys[] = "sys";
static char __pyx_k__top[] = "top";
static char __pyx_k__xyY[] = "xyY";
static char __pyx_k__CMYK[] = "CMYK";
static char __pyx_k__RGBA[] = "RGBA";
static char __pyx_k___sys[] = "_sys";
static char __pyx_k__args[] = "args";
static char __pyx_k__bdst[] = "bdst";
static char __pyx_k__blue[] = "blue";
static char __pyx_k__bsrc[] = "bsrc";
static char __pyx_k__cdst[] = "cdst";
static char __pyx_k__csrc[] = "csrc";
static char __pyx_k__data[] = "data";
static char __pyx_k__gray[] = "gray";
static char __pyx_k__info[] = "info";
static char __pyx_k__keys[] = "keys";
static char __pyx_k__left[] = "left";
static char __pyx_k__mime[] = "mime";
static char __pyx_k__name[] = "name";
static char __pyx_k__open[] = "open";
static char __pyx_k__read[] = "read";
static char __pyx_k__sRGB[] = "sRGB";
static char __pyx_k__self[] = "self";
static char __pyx_k__size[] = "size";
static char __pyx_k__xend[] = "xend";
static char __pyx_k__yend[] = "yend";
static char __pyx_k__Black[] = "Black";
static char __pyx_k__Image[] = "Image";
static char __pyx_k__White[] = "White";
static char __pyx_k__alpha[] = "alpha";
static char __pyx_k__angle[] = "angle";
static char __pyx_k__clear[] = "clear";
static char __pyx_k__clone[] = "clone";
static char __pyx_k__close[] = "close";
static char __pyx_k__dpi_x[] = "dpi_x";
static char __pyx_k__dpi_y[] = "dpi_y";
static char __pyx_k__dpm_x[] = "dpm_x";
static char __pyx_k__dpm_y[] = "dpm_y";
static char __pyx_k__fimsg[] = "fimsg";
static char __pyx_k__flags[] = "flags";
static char __pyx_k__flare[] = "flare";
static char __pyx_k__gamma[] = "gamma";
static char __pyx_k__green[] = "green";
static char __pyx_k__items[] = "items";
static char __pyx_k__lower[] = "lower";
static char __pyx_k__model[] = "model";
static char __pyx_k__right[] = "right";
static char __pyx_k__round[] = "round";
static char __pyx_k__split[] = "split";
static char __pyx_k__super[] = "super";
static char __pyx_k__tempK[] = "tempK";
static char __pyx_k__trafo[] = "trafo";
static char __pyx_k__value[] = "value";
static char __pyx_k__width[] = "width";
static char __pyx_k__bottom[] = "bottom";
static char __pyx_k__buffer[] = "buffer";
static char __pyx_k__encode[] = "encode";
static char __pyx_k__filter[] = "filter";
static char __pyx_k__fimsgl[] = "fimsgl";
static char __pyx_k__format[] = "format";
static char __pyx_k__getICC[] = "getICC";
static char __pyx_k__height[] = "height";
static char __pyx_k__intent[] = "intent";
static char __pyx_k__invert[] = "invert";
static char __pyx_k__isCLUT[] = "isCLUT";
static char __pyx_k__lookup[] = "lookup";
static char __pyx_k__memory[] = "memory";
static char __pyx_k__offset[] = "offset";
static char __pyx_k__result[] = "result";
static char __pyx_k__target[] = "target";
static char __pyx_k__values[] = "values";
static char __pyx_k__whence[] = "whence";
static char __pyx_k__xstart[] = "xstart";
static char __pyx_k__ystart[] = "ystart";
static char __pyx_k__IOError[] = "IOError";
static char __pyx_k__Palette[] = "Palette";
static char __pyx_k__UNKNOWN[] = "UNKNOWN";
static char __pyx_k__XYZ2xyY[] = "XYZ2xyY";
static char __pyx_k____all__[] = "__all__";
static char __pyx_k___bitmap[] = "_bitmap";
static char __pyx_k__backing[] = "backing";
static char __pyx_k__channel[] = "channel";
static char __pyx_k__from_fd[] = "from_fd";
static char __pyx_k__has_icc[] = "has_icc";
static char __pyx_k__intents[] = "intents";
static char __pyx_k__logging[] = "logging";
static char __pyx_k__perfect[] = "perfect";
static char __pyx_k__unknown[] = "unknown";
static char __pyx_k__version[] = "version";
static char __pyx_k__x_shift[] = "x_shift";
static char __pyx_k__xyY2XYZ[] = "xyY2XYZ";
static char __pyx_k__y_shift[] = "y_shift";
static char __pyx_k__FIMD_XMP[] = "FIMD_XMP";
static char __pyx_k____exit__[] = "__exit__";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____name__[] = "__name__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__allocate[] = "allocate";
static char __pyx_k__contrast[] = "contrast";
static char __pyx_k__datetime[] = "datetime";
static char __pyx_k__dst_type[] = "dst_type";
static char __pyx_k__filename[] = "filename";
static char __pyx_k__geometry[] = "geometry";
static char __pyx_k__mimetype[] = "mimetype";
static char __pyx_k__observer[] = "observer";
static char __pyx_k__red_mask[] = "red_mask";
static char __pyx_k__surround[] = "surround";
static char __pyx_k__toBuffer[] = "toBuffer";
static char __pyx_k__use_mask[] = "use_mask";
static char __pyx_k__x_origin[] = "x_origin";
static char __pyx_k__y_origin[] = "y_origin";
static char __pyx_k__Exception[] = "Exception";
static char __pyx_k__FIMD_IPTC[] = "FIMD_IPTC";
static char __pyx_k__LoadError[] = "LoadError";
static char __pyx_k__SaveError[] = "SaveError";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k____class__[] = "__class__";
static char __pyx_k____enter__[] = "__enter__";
static char __pyx_k___illu_map[] = "_illu_map";
static char __pyx_k__blue_mask[] = "blue_mask";
static char __pyx_k__copyright[] = "copyright";
static char __pyx_k__from_file[] = "from_file";
static char __pyx_k__getLogger[] = "getLogger";
static char __pyx_k__inprofile[] = "inprofile";
static char __pyx_k__linewidth[] = "linewidth";
static char __pyx_k__luminance[] = "luminance";
static char __pyx_k__profileid[] = "profileid";
static char __pyx_k__FormatInfo[] = "FormatInfo";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k___new_image[] = "_new_image";
static char __pyx_k__allocation[] = "allocation";
static char __pyx_k__attributes[] = "attributes";
static char __pyx_k__brightness[] = "brightness";
static char __pyx_k__brigthness[] = "brigthness";
static char __pyx_k__colorSpace[] = "colorSpace";
static char __pyx_k__getIntents[] = "getIntents";
static char __pyx_k__getVersion[] = "getVersion";
static char __pyx_k__green_mask[] = "green_mask";
static char __pyx_k__iccVersion[] = "iccVersion";
static char __pyx_k__illuminant[] = "illuminant";
static char __pyx_k__intent_ids[] = "intent_ids";
static char __pyx_k__loggername[] = "loggername";
static char __pyx_k__outprofile[] = "outprofile";
static char __pyx_k__redPrimary[] = "redPrimary";
static char __pyx_k__technology[] = "technology";
static char __pyx_k__FIMD_CUSTOM[] = "FIMD_CUSTOM";
static char __pyx_k__FIMD_NODATA[] = "FIMD_NODATA";
static char __pyx_k__MemoryError[] = "MemoryError";
static char __pyx_k__SystemError[] = "SystemError";
static char __pyx_k__bluePrimary[] = "bluePrimary";
static char __pyx_k__deviceClass[] = "deviceClass";
static char __pyx_k__headerFlags[] = "headerFlags";
static char __pyx_k__headerModel[] = "headerModel";
static char __pyx_k__redColorant[] = "redColorant";
static char __pyx_k__FIMD_GEOTIFF[] = "FIMD_GEOTIFF";
static char __pyx_k__LCMSIccCache[] = "LCMSIccCache";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static char __pyx_k___META_MODELS[] = "_META_MODELS";
static char __pyx_k__adjustColors[] = "adjustColors";
static char __pyx_k__blueColorant[] = "blueColorant";
static char __pyx_k__chromaticity[] = "chromaticity";
static char __pyx_k__creationDate[] = "creationDate";
static char __pyx_k__getCopyright[] = "getCopyright";
static char __pyx_k__greenPrimary[] = "greenPrimary";
static char __pyx_k__hasJPEGTurbo[] = "hasJPEGTurbo";
static char __pyx_k__intent_descs[] = "intent_descs";
static char __pyx_k__manufacturer[] = "manufacturer";
static char __pyx_k__scale_linear[] = "scale_linear";
static char __pyx_k__staticmethod[] = "staticmethod";
static char __pyx_k__FIMD_COMMENTS[] = "FIMD_COMMENTS";
static char __pyx_k__FIMD_EXIF_GPS[] = "FIMD_EXIF_GPS";
static char __pyx_k__LCMSException[] = "LCMSException";
static char __pyx_k__colorantTable[] = "colorantTable";
static char __pyx_k__from_filename[] = "from_filename";
static char __pyx_k__from_mimetype[] = "from_mimetype";
static char __pyx_k__greenColorant[] = "greenColorant";
static char __pyx_k__jpegTransform[] = "jpegTransform";
static char __pyx_k__FIMD_ANIMATION[] = "FIMD_ANIMATION";
static char __pyx_k__FIMD_EXIF_EXIF[] = "FIMD_EXIF_EXIF";
static char __pyx_k__FIMD_EXIF_MAIN[] = "FIMD_EXIF_MAIN";
static char __pyx_k__FreeImageError[] = "FreeImageError";
static char __pyx_k__OperationError[] = "OperationError";
static char __pyx_k__getCompiledFor[] = "getCompiledFor";
static char __pyx_k__getFormatCount[] = "getFormatCount";
static char __pyx_k__getLCMSVersion[] = "getLCMSVersion";
static char __pyx_k__illuminantType[] = "illuminantType";
static char __pyx_k__isMatrixShaper[] = "isMatrixShaper";
static char __pyx_k__lookupSVGColor[] = "lookupSVGColor";
static char __pyx_k__lookupX11Color[] = "lookupX11Color";
static char __pyx_k__LCMSProfileInfo[] = "LCMSProfileInfo";
static char __pyx_k__color_type_name[] = "color_type_name";
static char __pyx_k__connectionSpace[] = "connectionSpace";
static char __pyx_k__dispatchFIError[] = "dispatchFIError";
static char __pyx_k__mediaBlackPoint[] = "mediaBlackPoint";
static char __pyx_k__mediaWhitePoint[] = "mediaWhitePoint";
static char __pyx_k__renderingIntent[] = "renderingIntent";
static char __pyx_k__colorantTableOut[] = "colorantTableOut";
static char __pyx_k__viewingCondition[] = "viewingCondition";
static char __pyx_k__FIMD_EXIF_INTEROP[] = "FIMD_EXIF_INTEROP";
static char __pyx_k__UnknownImageError[] = "UnknownImageError";
static char __pyx_k___COLOR_TYPE_NAMES[] = "_COLOR_TYPE_NAMES";
static char __pyx_k__isIntentSupported[] = "isIntentSupported";
static char __pyx_k__LCMSTransformation[] = "LCMSTransformation";
static char __pyx_k__colorimetricIntent[] = "colorimetricIntent";
static char __pyx_k__headerManufacturer[] = "headerManufacturer";
static char __pyx_k__profileDescription[] = "profileDescription";
static char __pyx_k__tempFromWhitePoint[] = "tempFromWhitePoint";
static char __pyx_k__FIMD_EXIF_MAKERNOTE[] = "FIMD_EXIF_MAKERNOTE";
static char __pyx_k__NotImplementedError[] = "NotImplementedError";
static char __pyx_k___readNamedColorList[] = "_readNamedColorList";
static char __pyx_k__chromaticAdaptation[] = "chromaticAdaptation";
static char __pyx_k__iccViewingCondition[] = "iccViewingCondition";
static PyObject *__pyx_kp_s_10;
static PyObject *__pyx_kp_s_100;
static PyObject *__pyx_kp_s_102;
static PyObject *__pyx_kp_s_103;
static PyObject *__pyx_kp_s_104;
static PyObject *__pyx_kp_s_106;
static PyObject *__pyx_kp_s_108;
static PyObject *__pyx_kp_s_110;
static PyObject *__pyx_kp_s_112;
static PyObject *__pyx_kp_s_113;
static PyObject *__pyx_kp_s_114;
static PyObject *__pyx_kp_s_115;
static PyObject *__pyx_kp_s_116;
static PyObject *__pyx_kp_s_118;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_s_120;
static PyObject *__pyx_kp_s_122;
static PyObject *__pyx_kp_s_123;
static PyObject *__pyx_kp_s_125;
static PyObject *__pyx_kp_s_127;
static PyObject *__pyx_kp_s_129;
static PyObject *__pyx_kp_s_130;
static PyObject *__pyx_kp_b_131;
static PyObject *__pyx_kp_s_133;
static PyObject *__pyx_kp_s_134;
static PyObject *__pyx_kp_s_135;
static PyObject *__pyx_kp_s_136;
static PyObject *__pyx_kp_s_138;
static PyObject *__pyx_kp_s_14;
static PyObject *__pyx_kp_s_163;
static PyObject *__pyx_kp_s_165;
static PyObject *__pyx_n_s_166;
static PyObject *__pyx_kp_s_17;
static PyObject *__pyx_kp_s_177;
static PyObject *__pyx_n_s_185;
static PyObject *__pyx_n_s_188;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_n_s_191;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_kp_s_22;
static PyObject *__pyx_kp_s_24;
static PyObject *__pyx_kp_s_28;
static PyObject *__pyx_kp_s_30;
static PyObject *__pyx_kp_s_34;
static PyObject *__pyx_kp_s_35;
static PyObject *__pyx_n_s_36;
static PyObject *__pyx_n_s_37;
static PyObject *__pyx_n_s_38;
static PyObject *__pyx_n_s_39;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_n_s_40;
static PyObject *__pyx_kp_s_41;
static PyObject *__pyx_kp_s_43;
static PyObject *__pyx_n_s_45;
static PyObject *__pyx_kp_s_46;
static PyObject *__pyx_kp_s_47;
static PyObject *__pyx_kp_s_49;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_51;
static PyObject *__pyx_kp_s_52;
static PyObject *__pyx_kp_s_53;
static PyObject *__pyx_kp_s_56;
static PyObject *__pyx_kp_s_58;
static PyObject *__pyx_kp_s_59;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_60;
static PyObject *__pyx_kp_s_62;
static PyObject *__pyx_kp_s_63;
static PyObject *__pyx_kp_s_64;
static PyObject *__pyx_kp_s_66;
static PyObject *__pyx_kp_s_69;
static PyObject *__pyx_kp_s_70;
static PyObject *__pyx_kp_s_71;
static PyObject *__pyx_kp_s_73;
static PyObject *__pyx_kp_s_76;
static PyObject *__pyx_kp_s_78;
static PyObject *__pyx_kp_s_79;
static PyObject *__pyx_kp_s_80;
static PyObject *__pyx_kp_s_81;
static PyObject *__pyx_n_s_83;
static PyObject *__pyx_kp_s_85;
static PyObject *__pyx_kp_s_86;
static PyObject *__pyx_kp_s_88;
static PyObject *__pyx_kp_s_89;
static PyObject *__pyx_kp_s_90;
static PyObject *__pyx_kp_s_92;
static PyObject *__pyx_kp_s_93;
static PyObject *__pyx_kp_s_94;
static PyObject *__pyx_kp_s_95;
static PyObject *__pyx_kp_s_97;
static PyObject *__pyx_kp_s_98;
static PyObject *__pyx_n_s__A;
static PyObject *__pyx_n_s__BGR;
static PyObject *__pyx_n_s__Black;
static PyObject *__pyx_n_s__CMYK;
static PyObject *__pyx_n_s__D50;
static PyObject *__pyx_n_s__D55;
static PyObject *__pyx_n_s__D65;
static PyObject *__pyx_n_s__D93;
static PyObject *__pyx_n_s__DIB;
static PyObject *__pyx_n_s__E;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__F2;
static PyObject *__pyx_n_s__F8;
static PyObject *__pyx_n_s__FIMD_ANIMATION;
static PyObject *__pyx_n_s__FIMD_COMMENTS;
static PyObject *__pyx_n_s__FIMD_CUSTOM;
static PyObject *__pyx_n_s__FIMD_EXIF_EXIF;
static PyObject *__pyx_n_s__FIMD_EXIF_GPS;
static PyObject *__pyx_n_s__FIMD_EXIF_INTEROP;
static PyObject *__pyx_n_s__FIMD_EXIF_MAIN;
static PyObject *__pyx_n_s__FIMD_EXIF_MAKERNOTE;
static PyObject *__pyx_n_s__FIMD_GEOTIFF;
static PyObject *__pyx_n_s__FIMD_IPTC;
static PyObject *__pyx_n_s__FIMD_NODATA;
static PyObject *__pyx_n_s__FIMD_XMP;
static PyObject *__pyx_n_s__FormatInfo;
static PyObject *__pyx_n_s__FreeImageError;
static PyObject *__pyx_n_s__IOError;
static PyObject *__pyx_n_s__Image;
static PyObject *__pyx_n_s__LCMSException;
static PyObject *__pyx_n_s__LCMSIccCache;
static PyObject *__pyx_n_s__LCMSProfileInfo;
static PyObject *__pyx_n_s__LCMSTransformation;
static PyObject *__pyx_n_s__LoadError;
static PyObject *__pyx_n_s__MemoryError;
static PyObject *__pyx_n_s__NotImplementedError;
static PyObject *__pyx_n_s__OperationError;
static PyObject *__pyx_n_s__Palette;
static PyObject *__pyx_n_s__RGB;
static PyObject *__pyx_n_s__RGBA;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__SaveError;
static PyObject *__pyx_n_s__SystemError;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__UNKNOWN;
static PyObject *__pyx_n_s__UnknownImageError;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s__White;
static PyObject *__pyx_n_s__X;
static PyObject *__pyx_n_s__XYZ;
static PyObject *__pyx_n_s__XYZ2xyY;
static PyObject *__pyx_n_s__Y;
static PyObject *__pyx_n_s__Z;
static PyObject *__pyx_n_s___COLOR_TYPE_NAMES;
static PyObject *__pyx_n_s___META_MODELS;
static PyObject *__pyx_n_s____all__;
static PyObject *__pyx_n_s____class__;
static PyObject *__pyx_n_s____enter__;
static PyObject *__pyx_n_s____exit__;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____name__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___bitmap;
static PyObject *__pyx_n_s___illu_map;
static PyObject *__pyx_n_s___new_image;
static PyObject *__pyx_n_s___readNamedColorList;
static PyObject *__pyx_n_s___sys;
static PyObject *__pyx_n_s__adjustColors;
static PyObject *__pyx_n_s__allocate;
static PyObject *__pyx_n_s__allocation;
static PyObject *__pyx_n_s__alpha;
static PyObject *__pyx_n_s__angle;
static PyObject *__pyx_n_s__args;
static PyObject *__pyx_n_s__attributes;
static PyObject *__pyx_n_s__backing;
static PyObject *__pyx_n_s__bdst;
static PyObject *__pyx_n_s__blue;
static PyObject *__pyx_n_s__blueColorant;
static PyObject *__pyx_n_s__bluePrimary;
static PyObject *__pyx_n_s__blue_mask;
static PyObject *__pyx_n_s__bottom;
static PyObject *__pyx_n_s__bpp;
static PyObject *__pyx_n_s__brightness;
static PyObject *__pyx_n_s__brigthness;
static PyObject *__pyx_n_s__bsrc;
static PyObject *__pyx_n_s__buffer;
static PyObject *__pyx_n_s__cdst;
static PyObject *__pyx_n_s__channel;
static PyObject *__pyx_n_s__chromaticAdaptation;
static PyObject *__pyx_n_s__chromaticity;
static PyObject *__pyx_n_s__clear;
static PyObject *__pyx_n_s__clone;
static PyObject *__pyx_n_s__close;
static PyObject *__pyx_n_s__cls;
static PyObject *__pyx_n_s__colorSpace;
static PyObject *__pyx_n_s__color_type_name;
static PyObject *__pyx_n_s__colorantTable;
static PyObject *__pyx_n_s__colorantTableOut;
static PyObject *__pyx_n_s__colorimetricIntent;
static PyObject *__pyx_n_s__connectionSpace;
static PyObject *__pyx_n_s__contrast;
static PyObject *__pyx_n_s__copyright;
static PyObject *__pyx_n_s__creationDate;
static PyObject *__pyx_n_s__csrc;
static PyObject *__pyx_n_s__data;
static PyObject *__pyx_n_s__datetime;
static PyObject *__pyx_n_s__deviceClass;
static PyObject *__pyx_n_s__dib;
static PyObject *__pyx_n_s__dispatchFIError;
static PyObject *__pyx_n_s__dpi_x;
static PyObject *__pyx_n_s__dpi_y;
static PyObject *__pyx_n_s__dpm_x;
static PyObject *__pyx_n_s__dpm_y;
static PyObject *__pyx_n_s__dst;
static PyObject *__pyx_n_s__dst_type;
static PyObject *__pyx_n_s__encode;
static PyObject *__pyx_n_s__err;
static PyObject *__pyx_n_s__exc;
static PyObject *__pyx_n_s__fd;
static PyObject *__pyx_n_s__filename;
static PyObject *__pyx_n_s__filter;
static PyObject *__pyx_n_s__fimsg;
static PyObject *__pyx_n_s__fimsgl;
static PyObject *__pyx_n_s__flags;
static PyObject *__pyx_n_s__flare;
static PyObject *__pyx_n_s__format;
static PyObject *__pyx_n_s__from_fd;
static PyObject *__pyx_n_s__from_file;
static PyObject *__pyx_n_s__from_filename;
static PyObject *__pyx_n_s__from_mimetype;
static PyObject *__pyx_n_s__gamma;
static PyObject *__pyx_n_s__geometry;
static PyObject *__pyx_n_s__get;
static PyObject *__pyx_n_s__getCompiledFor;
static PyObject *__pyx_n_s__getCopyright;
static PyObject *__pyx_n_s__getFormatCount;
static PyObject *__pyx_n_s__getICC;
static PyObject *__pyx_n_s__getIntents;
static PyObject *__pyx_n_s__getLCMSVersion;
static PyObject *__pyx_n_s__getLogger;
static PyObject *__pyx_n_s__getVersion;
static PyObject *__pyx_n_s__green;
static PyObject *__pyx_n_s__greenColorant;
static PyObject *__pyx_n_s__greenPrimary;
static PyObject *__pyx_n_s__green_mask;
static PyObject *__pyx_n_s__hasJPEGTurbo;
static PyObject *__pyx_n_s__has_icc;
static PyObject *__pyx_n_s__headerFlags;
static PyObject *__pyx_n_s__headerManufacturer;
static PyObject *__pyx_n_s__headerModel;
static PyObject *__pyx_n_s__height;
static PyObject *__pyx_n_s__hex;
static PyObject *__pyx_n_s__i;
static PyObject *__pyx_n_s__iccVersion;
static PyObject *__pyx_n_s__iccViewingCondition;
static PyObject *__pyx_n_s__id;
static PyObject *__pyx_n_s__illuminant;
static PyObject *__pyx_n_s__illuminantType;
static PyObject *__pyx_n_s__img;
static PyObject *__pyx_n_s__in;
static PyObject *__pyx_n_s__info;
static PyObject *__pyx_n_s__inprofile;
static PyObject *__pyx_n_s__intent;
static PyObject *__pyx_n_s__intent_descs;
static PyObject *__pyx_n_s__intent_ids;
static PyObject *__pyx_n_s__intents;
static PyObject *__pyx_n_s__invert;
static PyObject *__pyx_n_s__isCLUT;
static PyObject *__pyx_n_s__isIntentSupported;
static PyObject *__pyx_n_s__isMatrixShaper;
static PyObject *__pyx_n_s__items;
static PyObject *__pyx_n_s__jpegTransform;
static PyObject *__pyx_n_s__keys;
static PyObject *__pyx_n_s__left;
static PyObject *__pyx_n_s__linewidth;
static PyObject *__pyx_n_s__loggername;
static PyObject *__pyx_n_s__logging;
static PyObject *__pyx_n_s__lookup;
static PyObject *__pyx_n_s__lookupSVGColor;
static PyObject *__pyx_n_s__lookupX11Color;
static PyObject *__pyx_n_s__lower;
static PyObject *__pyx_n_s__luminance;
static PyObject *__pyx_n_s__manufacturer;
static PyObject *__pyx_n_s__mediaBlackPoint;
static PyObject *__pyx_n_s__mediaWhitePoint;
static PyObject *__pyx_n_s__memory;
static PyObject *__pyx_n_s__mime;
static PyObject *__pyx_n_s__mimetype;
static PyObject *__pyx_n_s__model;
static PyObject *__pyx_n_s__msg;
static PyObject *__pyx_n_s__n;
static PyObject *__pyx_n_s__name;
static PyObject *__pyx_n_s__new;
static PyObject *__pyx_n_s__observer;
static PyObject *__pyx_n_s__offset;
static PyObject *__pyx_n_s__op;
static PyObject *__pyx_n_s__open;
static PyObject *__pyx_n_s__out;
static PyObject *__pyx_n_s__outprofile;
static PyObject *__pyx_n_s__perfect;
static PyObject *__pyx_n_s__profileDescription;
static PyObject *__pyx_n_s__profileid;
static PyObject *__pyx_n_s__rb;
static PyObject *__pyx_n_s__read;
static PyObject *__pyx_n_s__red;
static PyObject *__pyx_n_s__redColorant;
static PyObject *__pyx_n_s__redPrimary;
static PyObject *__pyx_n_s__red_mask;
static PyObject *__pyx_n_s__renderingIntent;
static PyObject *__pyx_n_s__result;
static PyObject *__pyx_n_s__right;
static PyObject *__pyx_n_s__round;
static PyObject *__pyx_n_s__s;
static PyObject *__pyx_n_b__sRGB;
static PyObject *__pyx_n_s__scale_linear;
static PyObject *__pyx_n_s__self;
static PyObject *__pyx_n_s__size;
static PyObject *__pyx_n_s__split;
static PyObject *__pyx_n_s__src;
static PyObject *__pyx_n_s__staticmethod;
static PyObject *__pyx_n_s__super;
static PyObject *__pyx_n_s__surround;
static PyObject *__pyx_n_s__sys;
static PyObject *__pyx_n_s__target;
static PyObject *__pyx_n_s__tb;
static PyObject *__pyx_n_s__technology;
static PyObject *__pyx_n_s__tempFromWhitePoint;
static PyObject *__pyx_n_s__tempK;
static PyObject *__pyx_n_s__toBuffer;
static PyObject *__pyx_n_s__top;
static PyObject *__pyx_n_s__trafo;
static PyObject *__pyx_n_s__unknown;
static PyObject *__pyx_n_s__use_mask;
static PyObject *__pyx_n_s__value;
static PyObject *__pyx_n_s__values;
static PyObject *__pyx_n_s__version;
static PyObject *__pyx_n_s__viewingCondition;
static PyObject *__pyx_n_s__whence;
static PyObject *__pyx_n_s__width;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_n_s__x_origin;
static PyObject *__pyx_n_s__x_shift;
static PyObject *__pyx_n_s__xend;
static PyObject *__pyx_n_s__xstart;
static PyObject *__pyx_n_s__xyY;
static PyObject *__pyx_n_s__xyY2XYZ;
static PyObject *__pyx_n_s__y;
static PyObject *__pyx_n_s__y_origin;
static PyObject *__pyx_n_s__y_shift;
static PyObject *__pyx_n_s__yend;
static PyObject *__pyx_n_s__ystart;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_5;
static PyObject *__pyx_int_6;
static PyObject *__pyx_int_7;
static PyObject *__pyx_int_8;
static int __pyx_k_7;
static int __pyx_k_8;
static int __pyx_k_9;
static int __pyx_k_16;
static char *__pyx_k_32;
static PyObject *__pyx_k_33;
static unsigned int __pyx_k_55;
static int __pyx_k_84;
static int __pyx_k_111;
static PyObject *__pyx_k_tuple_3;
static PyObject *__pyx_k_tuple_11;
static PyObject *__pyx_k_tuple_13;
static PyObject *__pyx_k_tuple_15;
static PyObject *__pyx_k_tuple_18;
static PyObject *__pyx_k_tuple_20;
static PyObject *__pyx_k_tuple_23;
static PyObject *__pyx_k_tuple_25;
static PyObject *__pyx_k_tuple_26;
static PyObject *__pyx_k_tuple_27;
static PyObject *__pyx_k_tuple_29;
static PyObject *__pyx_k_tuple_31;
static PyObject *__pyx_k_tuple_42;
static PyObject *__pyx_k_tuple_44;
static PyObject *__pyx_k_tuple_48;
static PyObject *__pyx_k_tuple_50;
static PyObject *__pyx_k_tuple_54;
static PyObject *__pyx_k_tuple_57;
static PyObject *__pyx_k_tuple_61;
static PyObject *__pyx_k_tuple_65;
static PyObject *__pyx_k_tuple_67;
static PyObject *__pyx_k_tuple_72;
static PyObject *__pyx_k_tuple_74;
static PyObject *__pyx_k_tuple_75;
static PyObject *__pyx_k_tuple_77;
static PyObject *__pyx_k_tuple_82;
static PyObject *__pyx_k_tuple_87;
static PyObject *__pyx_k_tuple_91;
static PyObject *__pyx_k_tuple_96;
static PyObject *__pyx_k_tuple_99;
static PyObject *__pyx_k_tuple_101;
static PyObject *__pyx_k_tuple_105;
static PyObject *__pyx_k_tuple_107;
static PyObject *__pyx_k_tuple_109;
static PyObject *__pyx_k_tuple_117;
static PyObject *__pyx_k_tuple_119;
static PyObject *__pyx_k_tuple_121;
static PyObject *__pyx_k_tuple_124;
static PyObject *__pyx_k_tuple_126;
static PyObject *__pyx_k_tuple_128;
static PyObject *__pyx_k_tuple_132;
static PyObject *__pyx_k_tuple_137;
static PyObject *__pyx_k_tuple_162;
static PyObject *__pyx_k_tuple_167;
static PyObject *__pyx_k_tuple_169;
static PyObject *__pyx_k_tuple_171;
static PyObject *__pyx_k_tuple_173;
static PyObject *__pyx_k_tuple_175;
static PyObject *__pyx_k_tuple_178;
static PyObject *__pyx_k_tuple_180;
static PyObject *__pyx_k_tuple_181;
static PyObject *__pyx_k_tuple_183;
static PyObject *__pyx_k_tuple_186;
static PyObject *__pyx_k_tuple_189;
static PyObject *__pyx_k_tuple_196;
static PyObject *__pyx_k_tuple_198;
static PyObject *__pyx_k_tuple_200;
static PyObject *__pyx_k_codeobj_164;
static PyObject *__pyx_k_codeobj_168;
static PyObject *__pyx_k_codeobj_170;
static PyObject *__pyx_k_codeobj_172;
static PyObject *__pyx_k_codeobj_174;
static PyObject *__pyx_k_codeobj_176;
static PyObject *__pyx_k_codeobj_179;
static PyObject *__pyx_k_codeobj_182;
static PyObject *__pyx_k_codeobj_184;
static PyObject *__pyx_k_codeobj_187;
static PyObject *__pyx_k_codeobj_190;
static PyObject *__pyx_k_codeobj_192;
static PyObject *__pyx_k_codeobj_193;
static PyObject *__pyx_k_codeobj_194;
static PyObject *__pyx_k_codeobj_195;
static PyObject *__pyx_k_codeobj_197;
static PyObject *__pyx_k_codeobj_199;
static PyObject *__pyx_k_codeobj_201;
static PyObject *__pyx_k_codeobj_202;

/* "smc/freeimage/_freeimage.pyx":66
 *     int FREEIMAGE_TURBO
 * 
 * cdef object funicode(smc_fi.const_char_ptr s):             # <<<<<<<<<<<<<<
 *     """Unicode helper from lxml's apihelpers.pxi
 *     """
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_funicode(const char* __pyx_v_s) {
  Py_ssize_t __pyx_v_slen;
  char *__pyx_v_spos;
  int __pyx_v_is_non_ascii;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  long __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("funicode", 0);

  /* "smc/freeimage/_freeimage.pyx":72
 *     cdef char* spos
 *     cdef bint is_non_ascii
 *     if smc_fi.IS_PYTHON3:             # <<<<<<<<<<<<<<
 *         slen = string.strlen(s)
 *         return s[:slen].decode('UTF-8')
 */
  if (IS_PYTHON3) {

    /* "smc/freeimage/_freeimage.pyx":73
 *     cdef bint is_non_ascii
 *     if smc_fi.IS_PYTHON3:
 *         slen = string.strlen(s)             # <<<<<<<<<<<<<<
 *         return s[:slen].decode('UTF-8')
 *     spos = s
 */
    __pyx_v_slen = strlen(__pyx_v_s);

    /* "smc/freeimage/_freeimage.pyx":74
 *     if smc_fi.IS_PYTHON3:
 *         slen = string.strlen(s)
 *         return s[:slen].decode('UTF-8')             # <<<<<<<<<<<<<<
 *     spos = s
 *     is_non_ascii = 0
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = ((PyObject *)PyUnicode_Decode(__pyx_v_s, __pyx_v_slen, __pyx_k_1, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_r = ((PyObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":75
 *         slen = string.strlen(s)
 *         return s[:slen].decode('UTF-8')
 *     spos = s             # <<<<<<<<<<<<<<
 *     is_non_ascii = 0
 *     while spos[0] != c'\0':
 */
  __pyx_v_spos = __pyx_v_s;

  /* "smc/freeimage/_freeimage.pyx":76
 *         return s[:slen].decode('UTF-8')
 *     spos = s
 *     is_non_ascii = 0             # <<<<<<<<<<<<<<
 *     while spos[0] != c'\0':
 *         if spos[0] & 0x80:
 */
  __pyx_v_is_non_ascii = 0;

  /* "smc/freeimage/_freeimage.pyx":77
 *     spos = s
 *     is_non_ascii = 0
 *     while spos[0] != c'\0':             # <<<<<<<<<<<<<<
 *         if spos[0] & 0x80:
 *             is_non_ascii = 1
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_spos[0]) != '\x00');
    if (!__pyx_t_2) break;

    /* "smc/freeimage/_freeimage.pyx":78
 *     is_non_ascii = 0
 *     while spos[0] != c'\0':
 *         if spos[0] & 0x80:             # <<<<<<<<<<<<<<
 *             is_non_ascii = 1
 *             break
 */
    __pyx_t_3 = ((__pyx_v_spos[0]) & 0x80);
    if (__pyx_t_3) {

      /* "smc/freeimage/_freeimage.pyx":79
 *     while spos[0] != c'\0':
 *         if spos[0] & 0x80:
 *             is_non_ascii = 1             # <<<<<<<<<<<<<<
 *             break
 *         spos += 1
 */
      __pyx_v_is_non_ascii = 1;

      /* "smc/freeimage/_freeimage.pyx":80
 *         if spos[0] & 0x80:
 *             is_non_ascii = 1
 *             break             # <<<<<<<<<<<<<<
 *         spos += 1
 *     while spos[0] != c'\0':
 */
      goto __pyx_L5_break;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "smc/freeimage/_freeimage.pyx":81
 *             is_non_ascii = 1
 *             break
 *         spos += 1             # <<<<<<<<<<<<<<
 *     while spos[0] != c'\0':
 *         spos += 1
 */
    __pyx_v_spos = (__pyx_v_spos + 1);
  }
  __pyx_L5_break:;

  /* "smc/freeimage/_freeimage.pyx":82
 *             break
 *         spos += 1
 *     while spos[0] != c'\0':             # <<<<<<<<<<<<<<
 *         spos += 1
 *     slen = spos - s
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_spos[0]) != '\x00');
    if (!__pyx_t_2) break;

    /* "smc/freeimage/_freeimage.pyx":83
 *         spos += 1
 *     while spos[0] != c'\0':
 *         spos += 1             # <<<<<<<<<<<<<<
 *     slen = spos - s
 *     if is_non_ascii:
 */
    __pyx_v_spos = (__pyx_v_spos + 1);
  }

  /* "smc/freeimage/_freeimage.pyx":84
 *     while spos[0] != c'\0':
 *         spos += 1
 *     slen = spos - s             # <<<<<<<<<<<<<<
 *     if is_non_ascii:
 *         return s[:slen].decode('UTF-8')
 */
  __pyx_v_slen = (__pyx_v_spos - __pyx_v_s);

  /* "smc/freeimage/_freeimage.pyx":85
 *         spos += 1
 *     slen = spos - s
 *     if is_non_ascii:             # <<<<<<<<<<<<<<
 *         return s[:slen].decode('UTF-8')
 *     return <bytes>s[:slen]
 */
  if (__pyx_v_is_non_ascii) {

    /* "smc/freeimage/_freeimage.pyx":86
 *     slen = spos - s
 *     if is_non_ascii:
 *         return s[:slen].decode('UTF-8')             # <<<<<<<<<<<<<<
 *     return <bytes>s[:slen]
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = ((PyObject *)PyUnicode_Decode(__pyx_v_s, __pyx_v_slen, __pyx_k_1, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_r = ((PyObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "smc/freeimage/_freeimage.pyx":87
 *     if is_non_ascii:
 *         return s[:slen].decode('UTF-8')
 *     return <bytes>s[:slen]             # <<<<<<<<<<<<<<
 * 
 * cdef bytes _decodeFilename(object filename):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_FromStringAndSize(__pyx_v_s + 0, __pyx_v_slen - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_t_1)));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.funicode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":89
 *     return <bytes>s[:slen]
 * 
 * cdef bytes _decodeFilename(object filename):             # <<<<<<<<<<<<<<
 *     #if filename is None:
 *     #    return None
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(PyObject *__pyx_v_filename) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_decodeFilename", 0);

  /* "smc/freeimage/_freeimage.pyx":92
 *     #if filename is None:
 *     #    return None
 *     if cpython.PyBytes_Check(filename):             # <<<<<<<<<<<<<<
 *         return filename
 *     elif cpython.PyUnicode_Check(filename):
 */
  __pyx_t_1 = PyBytes_Check(__pyx_v_filename);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":93
 *     #    return None
 *     if cpython.PyBytes_Check(filename):
 *         return filename             # <<<<<<<<<<<<<<
 *     elif cpython.PyUnicode_Check(filename):
 *         # XXX try FS encoding first
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    if (!(likely(PyBytes_CheckExact(__pyx_v_filename))||((__pyx_v_filename) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_filename)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_INCREF(__pyx_v_filename);
    __pyx_r = ((PyObject*)__pyx_v_filename);
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "smc/freeimage/_freeimage.pyx":94
 *     if cpython.PyBytes_Check(filename):
 *         return filename
 *     elif cpython.PyUnicode_Check(filename):             # <<<<<<<<<<<<<<
 *         # XXX try FS encoding first
 *         return filename.encode("utf-8")
 */
  __pyx_t_1 = PyUnicode_Check(__pyx_v_filename);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":96
 *     elif cpython.PyUnicode_Check(filename):
 *         # XXX try FS encoding first
 *         return filename.encode("utf-8")             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError(filename)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_filename, __pyx_n_s__encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":98
 *         return filename.encode("utf-8")
 *     else:
 *         raise TypeError(filename)             # <<<<<<<<<<<<<<
 * 
 * # LCMS integration
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage._decodeFilename", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":44
 * cdef object _logger = getLogger(loggername)
 * 
 * cdef void errorHandler(lcms.cmsContext ContextID,             # <<<<<<<<<<<<<<
 *                        lcms.cmsUInt32Number ErrorCode,
 *                        smc_fi.const_char_ptr * text) with gil:
 */

static void __pyx_f_3smc_9freeimage_10_freeimage_errorHandler(CYTHON_UNUSED cmsContext __pyx_v_ContextID, CYTHON_UNUSED cmsUInt32Number __pyx_v_ErrorCode, const char* *__pyx_v_text) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("errorHandler", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":47
 *                        lcms.cmsUInt32Number ErrorCode,
 *                        smc_fi.const_char_ptr * text) with gil:
 *     _logger.info(< char *> text)             # <<<<<<<<<<<<<<
 * 
 * lcms.cmsSetLogErrorHandler(< lcms.cmsLogErrorHandlerFunction > errorHandler)
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_3smc_9freeimage_10_freeimage__logger, __pyx_n_s__info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyBytes_FromString(((char *)__pyx_v_text)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("smc.freeimage._freeimage.errorHandler", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_1getLCMSVersion(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_1getLCMSVersion = {__Pyx_NAMESTR("getLCMSVersion"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_1getLCMSVersion, METH_NOARGS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_1getLCMSVersion(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getLCMSVersion (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_getLCMSVersion(__pyx_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":51
 * lcms.cmsSetLogErrorHandler(< lcms.cmsLogErrorHandlerFunction > errorHandler)
 * 
 * def getLCMSVersion():             # <<<<<<<<<<<<<<
 *     return lcms.LCMS_VERSION
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_getLCMSVersion(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getLCMSVersion", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":52
 * 
 * def getLCMSVersion():
 *     return lcms.LCMS_VERSION             # <<<<<<<<<<<<<<
 * 
 * def XYZ2xyY(float X, float Y, float Z):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(LCMS_VERSION); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.getLCMSVersion", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_3XYZ2xyY(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_3XYZ2xyY = {__Pyx_NAMESTR("XYZ2xyY"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_3XYZ2xyY, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_3XYZ2xyY(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_X;
  float __pyx_v_Y;
  float __pyx_v_Z;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__X,&__pyx_n_s__Y,&__pyx_n_s__Z,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("XYZ2xyY (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__X);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__Y);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("XYZ2xyY", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__Z);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("XYZ2xyY", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "XYZ2xyY") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_X = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_X == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_Y = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_Y == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_Z = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_Z == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("XYZ2xyY", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.XYZ2xyY", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_2XYZ2xyY(__pyx_self, __pyx_v_X, __pyx_v_Y, __pyx_v_Z);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":54
 *     return lcms.LCMS_VERSION
 * 
 * def XYZ2xyY(float X, float Y, float Z):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsCIEXYZ XYZ
 *     cdef lcms.cmsCIExyY xyY
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_2XYZ2xyY(CYTHON_UNUSED PyObject *__pyx_self, float __pyx_v_X, float __pyx_v_Y, float __pyx_v_Z) {
  cmsCIEXYZ __pyx_v_XYZ;
  cmsCIExyY __pyx_v_xyY;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("XYZ2xyY", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":57
 *     cdef lcms.cmsCIEXYZ XYZ
 *     cdef lcms.cmsCIExyY xyY
 *     XYZ.X = Y             # <<<<<<<<<<<<<<
 *     XYZ.Y = X
 *     XYZ.Z = Z
 */
  __pyx_v_XYZ.X = __pyx_v_Y;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":58
 *     cdef lcms.cmsCIExyY xyY
 *     XYZ.X = Y
 *     XYZ.Y = X             # <<<<<<<<<<<<<<
 *     XYZ.Z = Z
 *     lcms.cmsXYZ2xyY(& xyY, & XYZ)
 */
  __pyx_v_XYZ.Y = __pyx_v_X;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":59
 *     XYZ.X = Y
 *     XYZ.Y = X
 *     XYZ.Z = Z             # <<<<<<<<<<<<<<
 *     lcms.cmsXYZ2xyY(& xyY, & XYZ)
 *     return xyY.x, xyY.y, xyY.Y
 */
  __pyx_v_XYZ.Z = __pyx_v_Z;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":60
 *     XYZ.Y = X
 *     XYZ.Z = Z
 *     lcms.cmsXYZ2xyY(& xyY, & XYZ)             # <<<<<<<<<<<<<<
 *     return xyY.x, xyY.y, xyY.Y
 * 
 */
  cmsXYZ2xyY((&__pyx_v_xyY), (&__pyx_v_XYZ));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":61
 *     XYZ.Z = Z
 *     lcms.cmsXYZ2xyY(& xyY, & XYZ)
 *     return xyY.x, xyY.y, xyY.Y             # <<<<<<<<<<<<<<
 * 
 * def xyY2XYZ(float x, float y, float Y):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_xyY.x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_xyY.y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_xyY.Y); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.XYZ2xyY", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5xyY2XYZ(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_5xyY2XYZ = {__Pyx_NAMESTR("xyY2XYZ"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5xyY2XYZ, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5xyY2XYZ(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_Y;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__Y,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("xyY2XYZ (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("xyY2XYZ", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__Y);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("xyY2XYZ", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "xyY2XYZ") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_x = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_x == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_y = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_y == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_Y = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_Y == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("xyY2XYZ", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.xyY2XYZ", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_4xyY2XYZ(__pyx_self, __pyx_v_x, __pyx_v_y, __pyx_v_Y);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":63
 *     return xyY.x, xyY.y, xyY.Y
 * 
 * def xyY2XYZ(float x, float y, float Y):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsCIEXYZ XYZ
 *     cdef lcms.cmsCIExyY xyY
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_4xyY2XYZ(CYTHON_UNUSED PyObject *__pyx_self, float __pyx_v_x, float __pyx_v_y, float __pyx_v_Y) {
  cmsCIEXYZ __pyx_v_XYZ;
  cmsCIExyY __pyx_v_xyY;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("xyY2XYZ", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":66
 *     cdef lcms.cmsCIEXYZ XYZ
 *     cdef lcms.cmsCIExyY xyY
 *     xyY.x = x             # <<<<<<<<<<<<<<
 *     xyY.y = y
 *     xyY.Y = Y
 */
  __pyx_v_xyY.x = __pyx_v_x;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":67
 *     cdef lcms.cmsCIExyY xyY
 *     xyY.x = x
 *     xyY.y = y             # <<<<<<<<<<<<<<
 *     xyY.Y = Y
 *     lcms.cmsxyY2XYZ(& XYZ, & xyY)
 */
  __pyx_v_xyY.y = __pyx_v_y;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":68
 *     xyY.x = x
 *     xyY.y = y
 *     xyY.Y = Y             # <<<<<<<<<<<<<<
 *     lcms.cmsxyY2XYZ(& XYZ, & xyY)
 *     return XYZ.X, XYZ.Y, XYZ.Z
 */
  __pyx_v_xyY.Y = __pyx_v_Y;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":69
 *     xyY.y = y
 *     xyY.Y = Y
 *     lcms.cmsxyY2XYZ(& XYZ, & xyY)             # <<<<<<<<<<<<<<
 *     return XYZ.X, XYZ.Y, XYZ.Z
 * 
 */
  cmsxyY2XYZ((&__pyx_v_XYZ), (&__pyx_v_xyY));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":70
 *     xyY.Y = Y
 *     lcms.cmsxyY2XYZ(& XYZ, & xyY)
 *     return XYZ.X, XYZ.Y, XYZ.Z             # <<<<<<<<<<<<<<
 * 
 * def tempFromWhitePoint(float x, float y, float Y):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_XYZ.X); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_XYZ.Y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_XYZ.Z); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.xyY2XYZ", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_7tempFromWhitePoint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_7tempFromWhitePoint = {__Pyx_NAMESTR("tempFromWhitePoint"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_7tempFromWhitePoint, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_7tempFromWhitePoint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_Y;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__Y,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tempFromWhitePoint (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tempFromWhitePoint", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__Y);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tempFromWhitePoint", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tempFromWhitePoint") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_x = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_x == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_y = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_y == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_Y = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_Y == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tempFromWhitePoint", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.tempFromWhitePoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_6tempFromWhitePoint(__pyx_self, __pyx_v_x, __pyx_v_y, __pyx_v_Y);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":72
 *     return XYZ.X, XYZ.Y, XYZ.Z
 * 
 * def tempFromWhitePoint(float x, float y, float Y):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsFloat64Number tempK
 *     cdef lcms.cmsCIExyY xyY
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_6tempFromWhitePoint(CYTHON_UNUSED PyObject *__pyx_self, float __pyx_v_x, float __pyx_v_y, float __pyx_v_Y) {
  cmsFloat64Number __pyx_v_tempK;
  cmsCIExyY __pyx_v_xyY;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tempFromWhitePoint", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":75
 *     cdef lcms.cmsFloat64Number tempK
 *     cdef lcms.cmsCIExyY xyY
 *     xyY.x = x             # <<<<<<<<<<<<<<
 *     xyY.y = y
 *     xyY.Y = Y
 */
  __pyx_v_xyY.x = __pyx_v_x;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":76
 *     cdef lcms.cmsCIExyY xyY
 *     xyY.x = x
 *     xyY.y = y             # <<<<<<<<<<<<<<
 *     xyY.Y = Y
 *     if not lcms.cmsTempFromWhitePoint(& tempK, & xyY):
 */
  __pyx_v_xyY.y = __pyx_v_y;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":77
 *     xyY.x = x
 *     xyY.y = y
 *     xyY.Y = Y             # <<<<<<<<<<<<<<
 *     if not lcms.cmsTempFromWhitePoint(& tempK, & xyY):
 *         return None
 */
  __pyx_v_xyY.Y = __pyx_v_Y;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":78
 *     xyY.y = y
 *     xyY.Y = Y
 *     if not lcms.cmsTempFromWhitePoint(& tempK, & xyY):             # <<<<<<<<<<<<<<
 *         return None
 *     return tempK
 */
  __pyx_t_1 = (!cmsTempFromWhitePoint((&__pyx_v_tempK), (&__pyx_v_xyY)));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":79
 *     xyY.Y = Y
 *     if not lcms.cmsTempFromWhitePoint(& tempK, & xyY):
 *         return None             # <<<<<<<<<<<<<<
 *     return tempK
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":80
 *     if not lcms.cmsTempFromWhitePoint(& tempK, & xyY):
 *         return None
 *     return tempK             # <<<<<<<<<<<<<<
 * 
 * def getIntents():
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_tempK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.tempFromWhitePoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9getIntents(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_9getIntents = {__Pyx_NAMESTR("getIntents"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_9getIntents, METH_NOARGS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9getIntents(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getIntents (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_8getIntents(__pyx_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":82
 *     return tempK
 * 
 * def getIntents():             # <<<<<<<<<<<<<<
 *     cdef int n, i, intents = 200
 *     cdef int intent_ids[200]
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_8getIntents(CYTHON_UNUSED PyObject *__pyx_self) {
  int __pyx_v_n;
  int __pyx_v_i;
  int __pyx_v_intents;
  int __pyx_v_intent_ids[200];
  char *__pyx_v_intent_descs[200];
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getIntents", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":83
 * 
 * def getIntents():
 *     cdef int n, i, intents = 200             # <<<<<<<<<<<<<<
 *     cdef int intent_ids[200]
 *     cdef char * intent_descs[200]
 */
  __pyx_v_intents = 200;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":86
 *     cdef int intent_ids[200]
 *     cdef char * intent_descs[200]
 *     result = {}             # <<<<<<<<<<<<<<
 * 
 *     n = lcms.cmsGetSupportedIntents(intents,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":90
 *     n = lcms.cmsGetSupportedIntents(intents,
 *                                     < lcms.cmsUInt32Number *> intent_ids,
 *                                     intent_descs)             # <<<<<<<<<<<<<<
 *     for i from 0 <= i < n:
 *         result[intent_ids[i]] = intent_descs[i]
 */
  __pyx_v_n = cmsGetSupportedIntents(__pyx_v_intents, ((cmsUInt32Number *)__pyx_v_intent_ids), __pyx_v_intent_descs);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":91
 *                                     < lcms.cmsUInt32Number *> intent_ids,
 *                                     intent_descs)
 *     for i from 0 <= i < n:             # <<<<<<<<<<<<<<
 *         result[intent_ids[i]] = intent_descs[i]
 *     return result
 */
  __pyx_t_2 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":92
 *                                     intent_descs)
 *     for i from 0 <= i < n:
 *         result[intent_ids[i]] = intent_descs[i]             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_t_1 = PyBytes_FromString((__pyx_v_intent_descs[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    if (__Pyx_SetItemInt(((PyObject *)__pyx_v_result), (__pyx_v_intent_ids[__pyx_v_i]), ((PyObject *)__pyx_t_1), sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":93
 *     for i from 0 <= i < n:
 *         result[intent_ids[i]] = intent_descs[i]
 *     return result             # <<<<<<<<<<<<<<
 * 
 * class LCMSException(Exception):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.getIntents", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":98
 *     pass
 * 
 * cdef lcms.cmsHPROFILE createHProfile(char * iccprofile, unsigned int size, mode="in") except * :             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsHPROFILE hProfile = NULL
 *     cdef lcms.cmsToneCurve * curve
 */

static cmsHPROFILE __pyx_f_3smc_9freeimage_10_freeimage_createHProfile(char *__pyx_v_iccprofile, unsigned int __pyx_v_size, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_createHProfile *__pyx_optional_args) {
  PyObject *__pyx_v_mode = ((PyObject *)__pyx_n_s__in);
  cmsHPROFILE __pyx_v_hProfile;
  cmsToneCurve *__pyx_v_curve;
  cmsContext __pyx_v_context;
  cmsHPROFILE __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("createHProfile", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_mode = __pyx_optional_args->mode;
    }
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":99
 * 
 * cdef lcms.cmsHPROFILE createHProfile(char * iccprofile, unsigned int size, mode="in") except * :
 *     cdef lcms.cmsHPROFILE hProfile = NULL             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsToneCurve * curve
 *     cdef lcms.cmsContext context
 */
  __pyx_v_hProfile = NULL;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":103
 *     cdef lcms.cmsContext context
 * 
 *     context = < lcms.cmsContext > cpython.PyThread_get_thread_ident()             # <<<<<<<<<<<<<<
 * 
 *     if size == 4 and string.strcmp(iccprofile, b"sRGB") == 0:
 */
  __pyx_v_context = ((cmsContext)PyThread_get_thread_ident());

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":105
 *     context = < lcms.cmsContext > cpython.PyThread_get_thread_ident()
 * 
 *     if size == 4 and string.strcmp(iccprofile, b"sRGB") == 0:             # <<<<<<<<<<<<<<
 *         with nogil:
 *             hProfile = lcms.cmsCreate_sRGBProfileTHR(context)
 */
  __pyx_t_1 = (__pyx_v_size == 4);
  if (__pyx_t_1) {
    __pyx_t_2 = (strcmp(__pyx_v_iccprofile, __pyx_k__sRGB) == 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":106
 * 
 *     if size == 4 and string.strcmp(iccprofile, b"sRGB") == 0:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             hProfile = lcms.cmsCreate_sRGBProfileTHR(context)
 *         if hProfile == NULL:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":107
 *     if size == 4 and string.strcmp(iccprofile, b"sRGB") == 0:
 *         with nogil:
 *             hProfile = lcms.cmsCreate_sRGBProfileTHR(context)             # <<<<<<<<<<<<<<
 *         if hProfile == NULL:
 *             raise LCMSException("Failed to create sRGB %s profile" % mode)
 */
          __pyx_v_hProfile = cmsCreate_sRGBProfileTHR(__pyx_v_context);
        }

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":106
 * 
 *     if size == 4 and string.strcmp(iccprofile, b"sRGB") == 0:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             hProfile = lcms.cmsCreate_sRGBProfileTHR(context)
 *         if hProfile == NULL:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":108
 *         with nogil:
 *             hProfile = lcms.cmsCreate_sRGBProfileTHR(context)
 *         if hProfile == NULL:             # <<<<<<<<<<<<<<
 *             raise LCMSException("Failed to create sRGB %s profile" % mode)
 *             return NULL
 */
    __pyx_t_3 = (__pyx_v_hProfile == NULL);
    if (__pyx_t_3) {

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":109
 *             hProfile = lcms.cmsCreate_sRGBProfileTHR(context)
 *         if hProfile == NULL:
 *             raise LCMSException("Failed to create sRGB %s profile" % mode)             # <<<<<<<<<<<<<<
 *             return NULL
 *     elif size == 4 and string.strcmp(iccprofile, b"gray") == 0:
 */
      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__LCMSException); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L3;
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":111
 *             raise LCMSException("Failed to create sRGB %s profile" % mode)
 *             return NULL
 *     elif size == 4 and string.strcmp(iccprofile, b"gray") == 0:             # <<<<<<<<<<<<<<
 *         with nogil:
 *             curve = lcms.cmsBuildGamma(context, 1.0)
 */
  __pyx_t_3 = (__pyx_v_size == 4);
  if (__pyx_t_3) {
    __pyx_t_1 = (strcmp(__pyx_v_iccprofile, __pyx_k__gray) == 0);
    __pyx_t_2 = __pyx_t_1;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  if (__pyx_t_2) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":112
 *             return NULL
 *     elif size == 4 and string.strcmp(iccprofile, b"gray") == 0:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             curve = lcms.cmsBuildGamma(context, 1.0)
 *             hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":113
 *     elif size == 4 and string.strcmp(iccprofile, b"gray") == 0:
 *         with nogil:
 *             curve = lcms.cmsBuildGamma(context, 1.0)             # <<<<<<<<<<<<<<
 *             hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)
 *         if hProfile == NULL:
 */
          __pyx_v_curve = cmsBuildGamma(__pyx_v_context, 1.0);

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":114
 *         with nogil:
 *             curve = lcms.cmsBuildGamma(context, 1.0)
 *             hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)             # <<<<<<<<<<<<<<
 *         if hProfile == NULL:
 *             raise LCMSException("Failed to create gray %s profile" % mode)
 */
          __pyx_v_hProfile = cmsCreateGrayProfileTHR(__pyx_v_context, cmsD50_xyY(), __pyx_v_curve);
        }

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":112
 *             return NULL
 *     elif size == 4 and string.strcmp(iccprofile, b"gray") == 0:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             curve = lcms.cmsBuildGamma(context, 1.0)
 *             hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":115
 *             curve = lcms.cmsBuildGamma(context, 1.0)
 *             hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)
 *         if hProfile == NULL:             # <<<<<<<<<<<<<<
 *             raise LCMSException("Failed to create gray %s profile" % mode)
 *             return NULL
 */
    __pyx_t_2 = (__pyx_v_hProfile == NULL);
    if (__pyx_t_2) {

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":116
 *             hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)
 *         if hProfile == NULL:
 *             raise LCMSException("Failed to create gray %s profile" % mode)             # <<<<<<<<<<<<<<
 *             return NULL
 *     else:
 */
      __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__LCMSException); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_v_mode); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_6));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L11;
    }
    __pyx_L11:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":119
 *             return NULL
 *     else:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             hProfile = lcms.cmsOpenProfileFromMemTHR(context, iccprofile, size)
 *         if hProfile == NULL:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":120
 *     else:
 *         with nogil:
 *             hProfile = lcms.cmsOpenProfileFromMemTHR(context, iccprofile, size)             # <<<<<<<<<<<<<<
 *         if hProfile == NULL:
 *             raise LCMSException("Failed to set %s profile" % mode)
 */
          __pyx_v_hProfile = cmsOpenProfileFromMemTHR(__pyx_v_context, __pyx_v_iccprofile, __pyx_v_size);
        }

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":119
 *             return NULL
 *     else:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             hProfile = lcms.cmsOpenProfileFromMemTHR(context, iccprofile, size)
 *         if hProfile == NULL:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":121
 *         with nogil:
 *             hProfile = lcms.cmsOpenProfileFromMemTHR(context, iccprofile, size)
 *         if hProfile == NULL:             # <<<<<<<<<<<<<<
 *             raise LCMSException("Failed to set %s profile" % mode)
 *             return NULL
 */
    __pyx_t_2 = (__pyx_v_hProfile == NULL);
    if (__pyx_t_2) {

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":122
 *             hProfile = lcms.cmsOpenProfileFromMemTHR(context, iccprofile, size)
 *         if hProfile == NULL:
 *             raise LCMSException("Failed to set %s profile" % mode)             # <<<<<<<<<<<<<<
 *             return NULL
 * 
 */
      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__LCMSException); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_v_mode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L15;
    }
    __pyx_L15:;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":125
 *             return NULL
 * 
 *     return hProfile             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_hProfile;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.createHProfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inprofile = 0;
  PyObject *__pyx_v_outprofile = 0;
  int __pyx_v_format;
  int __pyx_v_intent;
  unsigned long __pyx_v_flags;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__inprofile,&__pyx_n_s__outprofile,&__pyx_n_s__format,&__pyx_n_s__intent,&__pyx_n_s__flags,0};
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    PyObject* values[5] = {0,0,0,0,0};
    values[1] = ((PyObject*)__pyx_n_b__sRGB);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__inprofile);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__outprofile);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intent);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[2]) {
      } else {
        __pyx_v_format = __pyx_k_7;
      }
      if (values[3]) {
      } else {
        __pyx_v_intent = __pyx_k_8;
      }
      if (values[4]) {
      } else {
        __pyx_v_flags = ((unsigned long)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_inprofile = ((PyObject*)values[0]);
    __pyx_v_outprofile = ((PyObject*)values[1]);
    if (values[2]) {
      __pyx_v_format = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_format == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_format = __pyx_k_7;
    }
    if (values[3]) {
      __pyx_v_intent = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_intent == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_intent = __pyx_k_8;
    }
    if (values[4]) {
      __pyx_v_flags = __Pyx_PyInt_AsUnsignedLong(values[4]); if (unlikely((__pyx_v_flags == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((unsigned long)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSTransformation.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_inprofile), (&PyBytes_Type), 1, "inprofile", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_outprofile), (&PyBytes_Type), 1, "outprofile", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation___init__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self), __pyx_v_inprofile, __pyx_v_outprofile, __pyx_v_format, __pyx_v_intent, __pyx_v_flags);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":139
 *     cdef hash
 * 
 *     def __init__(self,             # <<<<<<<<<<<<<<
 *                  bytes inprofile,
 *                  bytes outprofile=b"sRGB",
 */

static int __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self, PyObject *__pyx_v_inprofile, PyObject *__pyx_v_outprofile, int __pyx_v_format, int __pyx_v_intent, unsigned long __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  char *__pyx_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setOutProfile __pyx_t_4;
  struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setTransform __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":146
 *                  unsigned long flags=0
 *                  ):
 *         self.inprofile = inprofile             # <<<<<<<<<<<<<<
 *         self.outprofile = outprofile
 *         self.format = format
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_inprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_inprofile));
  __Pyx_GOTREF(__pyx_v_self->inprofile);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->inprofile));
  __pyx_v_self->inprofile = __pyx_v_inprofile;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":147
 *                  ):
 *         self.inprofile = inprofile
 *         self.outprofile = outprofile             # <<<<<<<<<<<<<<
 *         self.format = format
 *         self.intent = intent
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_outprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_outprofile));
  __Pyx_GOTREF(__pyx_v_self->outprofile);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->outprofile));
  __pyx_v_self->outprofile = __pyx_v_outprofile;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":148
 *         self.inprofile = inprofile
 *         self.outprofile = outprofile
 *         self.format = format             # <<<<<<<<<<<<<<
 *         self.intent = intent
 *         self.flags = flags
 */
  __pyx_v_self->format = __pyx_v_format;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":149
 *         self.outprofile = outprofile
 *         self.format = format
 *         self.intent = intent             # <<<<<<<<<<<<<<
 *         self.flags = flags
 *         self.setInProfile(inprofile, len(inprofile))
 */
  __pyx_v_self->intent = __pyx_v_intent;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":150
 *         self.format = format
 *         self.intent = intent
 *         self.flags = flags             # <<<<<<<<<<<<<<
 *         self.setInProfile(inprofile, len(inprofile))
 *         self.setOutProfile(outprofile, len(outprofile))
 */
  __pyx_v_self->flags = __pyx_v_flags;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":151
 *         self.intent = intent
 *         self.flags = flags
 *         self.setInProfile(inprofile, len(inprofile))             # <<<<<<<<<<<<<<
 *         self.setOutProfile(outprofile, len(outprofile))
 *         self.setTransform(format, format, intent, flags)
 */
  __pyx_t_1 = PyBytes_AsString(((PyObject *)__pyx_v_inprofile)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_inprofile) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_2 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_inprofile)); 
  __pyx_t_3 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self->__pyx_vtab)->setInProfile(__pyx_v_self, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":152
 *         self.flags = flags
 *         self.setInProfile(inprofile, len(inprofile))
 *         self.setOutProfile(outprofile, len(outprofile))             # <<<<<<<<<<<<<<
 *         self.setTransform(format, format, intent, flags)
 * 
 */
  __pyx_t_1 = PyBytes_AsString(((PyObject *)__pyx_v_outprofile)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_outprofile) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_2 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_outprofile)); 
  __pyx_t_4.__pyx_n = 1;
  __pyx_t_4.size = __pyx_t_2;
  __pyx_t_3 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self->__pyx_vtab)->setOutProfile(__pyx_v_self, __pyx_t_1, &__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":153
 *         self.setInProfile(inprofile, len(inprofile))
 *         self.setOutProfile(outprofile, len(outprofile))
 *         self.setTransform(format, format, intent, flags)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5.__pyx_n = 2;
  __pyx_t_5.intent = __pyx_v_intent;
  __pyx_t_5.flags = __pyx_v_flags;
  __pyx_t_3 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self->__pyx_vtab)->setTransform(__pyx_v_self, __pyx_v_format, __pyx_v_format, &__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSTransformation.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":156
 * 
 * 
 *     cdef setInProfile(self, char * iccprofile, unsigned int size):             # <<<<<<<<<<<<<<
 *         self.hInProfile = createHProfile(iccprofile, size, "in")
 * 
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_18LCMSTransformation_setInProfile(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self, char *__pyx_v_iccprofile, unsigned int __pyx_v_size) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  cmsHPROFILE __pyx_t_2;
  struct __pyx_opt_args_3smc_9freeimage_10_freeimage_createHProfile __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setInProfile", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":157
 * 
 *     cdef setInProfile(self, char * iccprofile, unsigned int size):
 *         self.hInProfile = createHProfile(iccprofile, size, "in")             # <<<<<<<<<<<<<<
 * 
 *     cdef setOutProfile(self, char * iccprofile, unsigned int size=0):
 */
  __pyx_t_1 = ((PyObject *)__pyx_n_s__in);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3.__pyx_n = 1;
  __pyx_t_3.mode = __pyx_t_1;
  __pyx_t_2 = __pyx_f_3smc_9freeimage_10_freeimage_createHProfile(__pyx_v_iccprofile, __pyx_v_size, &__pyx_t_3); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->hInProfile = __pyx_t_2;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSTransformation.setInProfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":159
 *         self.hInProfile = createHProfile(iccprofile, size, "in")
 * 
 *     cdef setOutProfile(self, char * iccprofile, unsigned int size=0):             # <<<<<<<<<<<<<<
 *         self.hOutProfile = createHProfile(iccprofile, size, "out")
 * 
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_18LCMSTransformation_setOutProfile(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self, char *__pyx_v_iccprofile, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setOutProfile *__pyx_optional_args) {
  unsigned int __pyx_v_size = ((unsigned int)0);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  cmsHPROFILE __pyx_t_2;
  struct __pyx_opt_args_3smc_9freeimage_10_freeimage_createHProfile __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setOutProfile", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_size = __pyx_optional_args->size;
    }
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":160
 * 
 *     cdef setOutProfile(self, char * iccprofile, unsigned int size=0):
 *         self.hOutProfile = createHProfile(iccprofile, size, "out")             # <<<<<<<<<<<<<<
 * 
 *     cdef lcms.cmsHPROFILE _createProfile(self, char * iccprofile, unsigned int size, mode="in") except * :
 */
  __pyx_t_1 = ((PyObject *)__pyx_n_s__out);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3.__pyx_n = 1;
  __pyx_t_3.mode = __pyx_t_1;
  __pyx_t_2 = __pyx_f_3smc_9freeimage_10_freeimage_createHProfile(__pyx_v_iccprofile, __pyx_v_size, &__pyx_t_3); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->hOutProfile = __pyx_t_2;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSTransformation.setOutProfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":162
 *         self.hOutProfile = createHProfile(iccprofile, size, "out")
 * 
 *     cdef lcms.cmsHPROFILE _createProfile(self, char * iccprofile, unsigned int size, mode="in") except * :             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsHPROFILE hProfile = NULL
 *         cdef lcms.cmsToneCurve * curve
 */

static cmsHPROFILE __pyx_f_3smc_9freeimage_10_freeimage_18LCMSTransformation__createProfile(CYTHON_UNUSED struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self, char *__pyx_v_iccprofile, unsigned int __pyx_v_size, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation__createProfile *__pyx_optional_args) {
  PyObject *__pyx_v_mode = ((PyObject *)__pyx_n_s__in);
  cmsHPROFILE __pyx_v_hProfile;
  cmsToneCurve *__pyx_v_curve;
  cmsContext __pyx_v_context;
  cmsHPROFILE __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_createProfile", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_mode = __pyx_optional_args->mode;
    }
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":163
 * 
 *     cdef lcms.cmsHPROFILE _createProfile(self, char * iccprofile, unsigned int size, mode="in") except * :
 *         cdef lcms.cmsHPROFILE hProfile = NULL             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsToneCurve * curve
 *         cdef lcms.cmsContext context
 */
  __pyx_v_hProfile = NULL;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":167
 *         cdef lcms.cmsContext context
 * 
 *         context = < lcms.cmsContext > cpython.PyThread_get_thread_ident()             # <<<<<<<<<<<<<<
 * 
 *         if size == 4 and string.strcmp(iccprofile, b"sRGB") == 0:
 */
  __pyx_v_context = ((cmsContext)PyThread_get_thread_ident());

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":169
 *         context = < lcms.cmsContext > cpython.PyThread_get_thread_ident()
 * 
 *         if size == 4 and string.strcmp(iccprofile, b"sRGB") == 0:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 hProfile = lcms.cmsCreate_sRGBProfileTHR(context)
 */
  __pyx_t_1 = (__pyx_v_size == 4);
  if (__pyx_t_1) {
    __pyx_t_2 = (strcmp(__pyx_v_iccprofile, __pyx_k__sRGB) == 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":170
 * 
 *         if size == 4 and string.strcmp(iccprofile, b"sRGB") == 0:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 hProfile = lcms.cmsCreate_sRGBProfileTHR(context)
 *             if hProfile == NULL:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":171
 *         if size == 4 and string.strcmp(iccprofile, b"sRGB") == 0:
 *             with nogil:
 *                 hProfile = lcms.cmsCreate_sRGBProfileTHR(context)             # <<<<<<<<<<<<<<
 *             if hProfile == NULL:
 *                 raise LCMSException("Failed to create sRGB %s profile" % mode)
 */
          __pyx_v_hProfile = cmsCreate_sRGBProfileTHR(__pyx_v_context);
        }

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":170
 * 
 *         if size == 4 and string.strcmp(iccprofile, b"sRGB") == 0:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 hProfile = lcms.cmsCreate_sRGBProfileTHR(context)
 *             if hProfile == NULL:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":172
 *             with nogil:
 *                 hProfile = lcms.cmsCreate_sRGBProfileTHR(context)
 *             if hProfile == NULL:             # <<<<<<<<<<<<<<
 *                 raise LCMSException("Failed to create sRGB %s profile" % mode)
 *                 return NULL
 */
    __pyx_t_3 = (__pyx_v_hProfile == NULL);
    if (__pyx_t_3) {

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":173
 *                 hProfile = lcms.cmsCreate_sRGBProfileTHR(context)
 *             if hProfile == NULL:
 *                 raise LCMSException("Failed to create sRGB %s profile" % mode)             # <<<<<<<<<<<<<<
 *                 return NULL
 *         elif size == 4 and string.strcmp(iccprofile, b"gray") == 0:
 */
      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__LCMSException); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L3;
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":175
 *                 raise LCMSException("Failed to create sRGB %s profile" % mode)
 *                 return NULL
 *         elif size == 4 and string.strcmp(iccprofile, b"gray") == 0:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 curve = lcms.cmsBuildGamma(context, 1.0)
 */
  __pyx_t_3 = (__pyx_v_size == 4);
  if (__pyx_t_3) {
    __pyx_t_1 = (strcmp(__pyx_v_iccprofile, __pyx_k__gray) == 0);
    __pyx_t_2 = __pyx_t_1;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  if (__pyx_t_2) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":176
 *                 return NULL
 *         elif size == 4 and string.strcmp(iccprofile, b"gray") == 0:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 curve = lcms.cmsBuildGamma(context, 1.0)
 *                 hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":177
 *         elif size == 4 and string.strcmp(iccprofile, b"gray") == 0:
 *             with nogil:
 *                 curve = lcms.cmsBuildGamma(context, 1.0)             # <<<<<<<<<<<<<<
 *                 hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)
 *             if hProfile == NULL:
 */
          __pyx_v_curve = cmsBuildGamma(__pyx_v_context, 1.0);

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":178
 *             with nogil:
 *                 curve = lcms.cmsBuildGamma(context, 1.0)
 *                 hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)             # <<<<<<<<<<<<<<
 *             if hProfile == NULL:
 *                 raise LCMSException("Failed to create gray %s profile" % mode)
 */
          __pyx_v_hProfile = cmsCreateGrayProfileTHR(__pyx_v_context, cmsD50_xyY(), __pyx_v_curve);
        }

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":176
 *                 return NULL
 *         elif size == 4 and string.strcmp(iccprofile, b"gray") == 0:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 curve = lcms.cmsBuildGamma(context, 1.0)
 *                 hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":179
 *                 curve = lcms.cmsBuildGamma(context, 1.0)
 *                 hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)
 *             if hProfile == NULL:             # <<<<<<<<<<<<<<
 *                 raise LCMSException("Failed to create gray %s profile" % mode)
 *                 return NULL
 */
    __pyx_t_2 = (__pyx_v_hProfile == NULL);
    if (__pyx_t_2) {

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":180
 *                 hProfile = lcms.cmsCreateGrayProfileTHR(context, lcms.cmsD50_xyY(), curve)
 *             if hProfile == NULL:
 *                 raise LCMSException("Failed to create gray %s profile" % mode)             # <<<<<<<<<<<<<<
 *                 return NULL
 *         else:
 */
      __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__LCMSException); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_v_mode); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_6));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L11;
    }
    __pyx_L11:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":183
 *                 return NULL
 *         else:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 hProfile = lcms.cmsOpenProfileFromMemTHR(context, iccprofile, size)
 *             if hProfile == NULL:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":184
 *         else:
 *             with nogil:
 *                 hProfile = lcms.cmsOpenProfileFromMemTHR(context, iccprofile, size)             # <<<<<<<<<<<<<<
 *             if hProfile == NULL:
 *                 raise LCMSException("Failed to set %s profile" % mode)
 */
          __pyx_v_hProfile = cmsOpenProfileFromMemTHR(__pyx_v_context, __pyx_v_iccprofile, __pyx_v_size);
        }

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":183
 *                 return NULL
 *         else:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 hProfile = lcms.cmsOpenProfileFromMemTHR(context, iccprofile, size)
 *             if hProfile == NULL:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":185
 *             with nogil:
 *                 hProfile = lcms.cmsOpenProfileFromMemTHR(context, iccprofile, size)
 *             if hProfile == NULL:             # <<<<<<<<<<<<<<
 *                 raise LCMSException("Failed to set %s profile" % mode)
 *                 return NULL
 */
    __pyx_t_2 = (__pyx_v_hProfile == NULL);
    if (__pyx_t_2) {

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":186
 *                 hProfile = lcms.cmsOpenProfileFromMemTHR(context, iccprofile, size)
 *             if hProfile == NULL:
 *                 raise LCMSException("Failed to set %s profile" % mode)             # <<<<<<<<<<<<<<
 *                 return NULL
 * 
 */
      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__LCMSException); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_v_mode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L15;
    }
    __pyx_L15:;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":189
 *                 return NULL
 * 
 *         return hProfile             # <<<<<<<<<<<<<<
 * 
 *     cdef setTransform(self, int inputformat, int outputformat,
 */
  __pyx_r = __pyx_v_hProfile;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSTransformation._createProfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":191
 *         return hProfile
 * 
 *     cdef setTransform(self, int inputformat, int outputformat,             # <<<<<<<<<<<<<<
 *                       int intent=lcms.INTENT_PERCEPTUAL,
 *                       unsigned long flags=0):
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_18LCMSTransformation_setTransform(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self, int __pyx_v_inputformat, int __pyx_v_outputformat, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setTransform *__pyx_optional_args) {
  int __pyx_v_intent = __pyx_k_9;
  unsigned long __pyx_v_flags = ((unsigned long)0);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setTransform", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_intent = __pyx_optional_args->intent;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_flags = __pyx_optional_args->flags;
      }
    }
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":194
 *                       int intent=lcms.INTENT_PERCEPTUAL,
 *                       unsigned long flags=0):
 *         if self.hInProfile == NULL:             # <<<<<<<<<<<<<<
 *             raise LCMSException("No in profile")
 *         if self.hOutProfile == NULL:
 */
  __pyx_t_1 = (__pyx_v_self->hInProfile == NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":195
 *                       unsigned long flags=0):
 *         if self.hInProfile == NULL:
 *             raise LCMSException("No in profile")             # <<<<<<<<<<<<<<
 *         if self.hOutProfile == NULL:
 *             raise LCMSException("No out profile")
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__LCMSException); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":196
 *         if self.hInProfile == NULL:
 *             raise LCMSException("No in profile")
 *         if self.hOutProfile == NULL:             # <<<<<<<<<<<<<<
 *             raise LCMSException("No out profile")
 *             return -1
 */
  __pyx_t_1 = (__pyx_v_self->hOutProfile == NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":197
 *             raise LCMSException("No in profile")
 *         if self.hOutProfile == NULL:
 *             raise LCMSException("No out profile")             # <<<<<<<<<<<<<<
 *             return -1
 *         self.hTransform = lcms.cmsCreateTransformTHR(< lcms.cmsContext > cpython.PyThread_get_thread_ident(),
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__LCMSException); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":199
 *             raise LCMSException("No out profile")
 *             return -1
 *         self.hTransform = lcms.cmsCreateTransformTHR(< lcms.cmsContext > cpython.PyThread_get_thread_ident(),             # <<<<<<<<<<<<<<
 *                                              self.hInProfile, inputformat,
 *                                              self.hOutProfile, outputformat,
 */
  __pyx_v_self->hTransform = cmsCreateTransformTHR(((cmsContext)PyThread_get_thread_ident()), __pyx_v_self->hInProfile, __pyx_v_inputformat, __pyx_v_self->hOutProfile, __pyx_v_outputformat, __pyx_v_intent, __pyx_v_flags);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":203
 *                                              self.hOutProfile, outputformat,
 *                                              intent, flags)
 *         if self.hTransform == NULL:             # <<<<<<<<<<<<<<
 *             raise LCMSException("Failed to create transformation")
 *         with nogil:
 */
  __pyx_t_1 = (__pyx_v_self->hTransform == NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":204
 *                                              intent, flags)
 *         if self.hTransform == NULL:
 *             raise LCMSException("Failed to create transformation")             # <<<<<<<<<<<<<<
 *         with nogil:
 *             # with LCMS2 we can close the profiles after the
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__LCMSException); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":205
 *         if self.hTransform == NULL:
 *             raise LCMSException("Failed to create transformation")
 *         with nogil:             # <<<<<<<<<<<<<<
 *             # with LCMS2 we can close the profiles after the
 *             # transformation has been created
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":208
 *             # with LCMS2 we can close the profiles after the
 *             # transformation has been created
 *             lcms.cmsCloseProfile(self.hInProfile)             # <<<<<<<<<<<<<<
 *             self.hInProfile = NULL
 *             lcms.cmsCloseProfile(self.hOutProfile)
 */
        cmsCloseProfile(__pyx_v_self->hInProfile);

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":209
 *             # transformation has been created
 *             lcms.cmsCloseProfile(self.hInProfile)
 *             self.hInProfile = NULL             # <<<<<<<<<<<<<<
 *             lcms.cmsCloseProfile(self.hOutProfile)
 *             self.hOutProfile = NULL
 */
        __pyx_v_self->hInProfile = NULL;

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":210
 *             lcms.cmsCloseProfile(self.hInProfile)
 *             self.hInProfile = NULL
 *             lcms.cmsCloseProfile(self.hOutProfile)             # <<<<<<<<<<<<<<
 *             self.hOutProfile = NULL
 * 
 */
        cmsCloseProfile(__pyx_v_self->hOutProfile);

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":211
 *             self.hInProfile = NULL
 *             lcms.cmsCloseProfile(self.hOutProfile)
 *             self.hOutProfile = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __hash__(self):
 */
        __pyx_v_self->hOutProfile = NULL;
      }

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":205
 *         if self.hTransform == NULL:
 *             raise LCMSException("Failed to create transformation")
 *         with nogil:             # <<<<<<<<<<<<<<
 *             # with LCMS2 we can close the profiles after the
 *             # transformation has been created
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSTransformation.setTransform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static Py_hash_t __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_3__hash__(PyObject *__pyx_v_self); /*proto*/
static Py_hash_t __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_3__hash__(PyObject *__pyx_v_self) {
  Py_hash_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__hash__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_2__hash__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":213
 *             self.hOutProfile = NULL
 * 
 *     def __hash__(self):             # <<<<<<<<<<<<<<
 *         if self.hash:
 *             return self.hash
 */

static Py_hash_t __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_2__hash__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self) {
  Py_hash_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_hash_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__hash__", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":214
 * 
 *     def __hash__(self):
 *         if self.hash:             # <<<<<<<<<<<<<<
 *             return self.hash
 *         self.hash = hash((self.inprofile, self.outprofile,
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->hash); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":215
 *     def __hash__(self):
 *         if self.hash:
 *             return self.hash             # <<<<<<<<<<<<<<
 *         self.hash = hash((self.inprofile, self.outprofile,
 *                           self.format, self.intent, self.flags))
 */
    __pyx_t_2 = __Pyx_PyInt_AsHash_t(__pyx_v_self->hash); if (unlikely((__pyx_t_2 == (Py_hash_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_2;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":217
 *             return self.hash
 *         self.hash = hash((self.inprofile, self.outprofile,
 *                           self.format, self.intent, self.flags))             # <<<<<<<<<<<<<<
 *         return self.hash
 * 
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyInt_FromLong(__pyx_v_self->intent); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyLong_FromUnsignedLong(__pyx_v_self->flags); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->inprofile));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_self->inprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->inprofile));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->outprofile));
  PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_self->outprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->outprofile));
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_2 = PyObject_Hash(((PyObject *)__pyx_t_6)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_FromHash_t(__pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":216
 *         if self.hash:
 *             return self.hash
 *         self.hash = hash((self.inprofile, self.outprofile,             # <<<<<<<<<<<<<<
 *                           self.format, self.intent, self.flags))
 *         return self.hash
 */
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_GOTREF(__pyx_v_self->hash);
  __Pyx_DECREF(__pyx_v_self->hash);
  __pyx_v_self->hash = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":218
 *         self.hash = hash((self.inprofile, self.outprofile,
 *                           self.format, self.intent, self.flags))
 *         return self.hash             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_2 = __Pyx_PyInt_AsHash_t(__pyx_v_self->hash); if (unlikely((__pyx_t_2 == (Py_hash_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSTransformation.__hash__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  if (unlikely(__pyx_r == -1) && !PyErr_Occurred()) __pyx_r = -2;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_5__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_4__dealloc__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":220
 *         return self.hash
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.hTransform != NULL:
 *             with nogil:
 */

static void __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_4__dealloc__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":221
 * 
 *     def __dealloc__(self):
 *         if self.hTransform != NULL:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 lcms.cmsDeleteTransform(self.hTransform)
 */
  __pyx_t_1 = (__pyx_v_self->hTransform != NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":222
 *     def __dealloc__(self):
 *         if self.hTransform != NULL:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 lcms.cmsDeleteTransform(self.hTransform)
 *         if self.hInProfile != NULL:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":223
 *         if self.hTransform != NULL:
 *             with nogil:
 *                 lcms.cmsDeleteTransform(self.hTransform)             # <<<<<<<<<<<<<<
 *         if self.hInProfile != NULL:
 *             with nogil:
 */
          cmsDeleteTransform(__pyx_v_self->hTransform);
        }

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":222
 *     def __dealloc__(self):
 *         if self.hTransform != NULL:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 lcms.cmsDeleteTransform(self.hTransform)
 *         if self.hInProfile != NULL:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":224
 *             with nogil:
 *                 lcms.cmsDeleteTransform(self.hTransform)
 *         if self.hInProfile != NULL:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 lcms.cmsCloseProfile(self.hInProfile)
 */
  __pyx_t_1 = (__pyx_v_self->hInProfile != NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":225
 *                 lcms.cmsDeleteTransform(self.hTransform)
 *         if self.hInProfile != NULL:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 lcms.cmsCloseProfile(self.hInProfile)
 *         if self.hOutProfile != NULL:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":226
 *         if self.hInProfile != NULL:
 *             with nogil:
 *                 lcms.cmsCloseProfile(self.hInProfile)             # <<<<<<<<<<<<<<
 *         if self.hOutProfile != NULL:
 *             with nogil:
 */
          cmsCloseProfile(__pyx_v_self->hInProfile);
        }

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":225
 *                 lcms.cmsDeleteTransform(self.hTransform)
 *         if self.hInProfile != NULL:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 lcms.cmsCloseProfile(self.hInProfile)
 *         if self.hOutProfile != NULL:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":227
 *             with nogil:
 *                 lcms.cmsCloseProfile(self.hInProfile)
 *         if self.hOutProfile != NULL:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 lcms.cmsCloseProfile(self.hOutProfile)
 */
  __pyx_t_1 = (__pyx_v_self->hOutProfile != NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":228
 *                 lcms.cmsCloseProfile(self.hInProfile)
 *         if self.hOutProfile != NULL:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 lcms.cmsCloseProfile(self.hOutProfile)
 *         self.hInProfile = NULL
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":229
 *         if self.hOutProfile != NULL:
 *             with nogil:
 *                 lcms.cmsCloseProfile(self.hOutProfile)             # <<<<<<<<<<<<<<
 *         self.hInProfile = NULL
 *         self.hOutProfile = NULL
 */
          cmsCloseProfile(__pyx_v_self->hOutProfile);
        }

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":228
 *                 lcms.cmsCloseProfile(self.hInProfile)
 *         if self.hOutProfile != NULL:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 lcms.cmsCloseProfile(self.hOutProfile)
 *         self.hInProfile = NULL
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":230
 *             with nogil:
 *                 lcms.cmsCloseProfile(self.hOutProfile)
 *         self.hInProfile = NULL             # <<<<<<<<<<<<<<
 *         self.hOutProfile = NULL
 *         self.hTransform = NULL
 */
  __pyx_v_self->hInProfile = NULL;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":231
 *                 lcms.cmsCloseProfile(self.hOutProfile)
 *         self.hInProfile = NULL
 *         self.hOutProfile = NULL             # <<<<<<<<<<<<<<
 *         self.hTransform = NULL
 * 
 */
  __pyx_v_self->hOutProfile = NULL;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":232
 *         self.hInProfile = NULL
 *         self.hOutProfile = NULL
 *         self.hTransform = NULL             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_self->hTransform = NULL;

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_9inprofile_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_9inprofile_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_9inprofile___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":132
 *     cdef lcms.cmsHPROFILE hOutProfile
 *     cdef lcms.cmsHTRANSFORM hTransform
 *     cdef readonly bytes inprofile             # <<<<<<<<<<<<<<
 *     cdef readonly bytes outprofile
 *     cdef readonly int format
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_9inprofile___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->inprofile));
  __pyx_r = ((PyObject *)__pyx_v_self->inprofile);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_10outprofile_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_10outprofile_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_10outprofile___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":133
 *     cdef lcms.cmsHTRANSFORM hTransform
 *     cdef readonly bytes inprofile
 *     cdef readonly bytes outprofile             # <<<<<<<<<<<<<<
 *     cdef readonly int format
 *     cdef readonly int intent
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_10outprofile___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->outprofile));
  __pyx_r = ((PyObject *)__pyx_v_self->outprofile);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_6format_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_6format_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_6format___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":134
 *     cdef readonly bytes inprofile
 *     cdef readonly bytes outprofile
 *     cdef readonly int format             # <<<<<<<<<<<<<<
 *     cdef readonly int intent
 *     cdef readonly unsigned long flags
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_6format___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSTransformation.format.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_6intent_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_6intent_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_6intent___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":135
 *     cdef readonly bytes outprofile
 *     cdef readonly int format
 *     cdef readonly int intent             # <<<<<<<<<<<<<<
 *     cdef readonly unsigned long flags
 *     cdef hash
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_6intent___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->intent); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSTransformation.intent.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_5flags_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_5flags_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_5flags___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":136
 *     cdef readonly int format
 *     cdef readonly int intent
 *     cdef readonly unsigned long flags             # <<<<<<<<<<<<<<
 *     cdef hash
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18LCMSTransformation_5flags___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSTransformation.flags.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache___init__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":239
 *     cdef readonly int creations
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self._cache = {}
 *         self.creations = 0
 */

static int __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":240
 * 
 *     def __init__(self):
 *         self._cache = {}             # <<<<<<<<<<<<<<
 *         self.creations = 0
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->_cache);
  __Pyx_DECREF(__pyx_v_self->_cache);
  __pyx_v_self->_cache = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":241
 *     def __init__(self):
 *         self._cache = {}
 *         self.creations = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef addEntry(self,
 */
  __pyx_v_self->creations = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":243
 *         self.creations = 0
 * 
 *     cdef addEntry(self,             # <<<<<<<<<<<<<<
 *                   bytes inprofile,
 *                   bytes outprofile,
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_12LCMSIccCache_addEntry(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self, PyObject *__pyx_v_inprofile, PyObject *__pyx_v_outprofile, int __pyx_v_format, int __pyx_v_intent, unsigned long __pyx_v_flags) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_trafo = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("addEntry", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":249
 *                   int intent,
 *                   unsigned long flags):
 *         trafo = LCMSTransformation(inprofile, outprofile, format, intent, flags)             # <<<<<<<<<<<<<<
 *         self._cache[(inprofile, outprofile, format, intent, flags)] = trafo
 *         self.creations += 1
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_intent); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_inprofile));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_inprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_inprofile));
  __Pyx_INCREF(((PyObject *)__pyx_v_outprofile));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_outprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_outprofile));
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_LCMSTransformation)), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_v_trafo = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":250
 *                   unsigned long flags):
 *         trafo = LCMSTransformation(inprofile, outprofile, format, intent, flags)
 *         self._cache[(inprofile, outprofile, format, intent, flags)] = trafo             # <<<<<<<<<<<<<<
 *         self.creations += 1
 *         return trafo
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyInt_FromLong(__pyx_v_intent); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_inprofile));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_inprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_inprofile));
  __Pyx_INCREF(((PyObject *)__pyx_v_outprofile));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_outprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_outprofile));
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  if (PyObject_SetItem(__pyx_v_self->_cache, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_v_trafo)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":251
 *         trafo = LCMSTransformation(inprofile, outprofile, format, intent, flags)
 *         self._cache[(inprofile, outprofile, format, intent, flags)] = trafo
 *         self.creations += 1             # <<<<<<<<<<<<<<
 *         return trafo
 * 
 */
  __pyx_v_self->creations = (__pyx_v_self->creations + 1);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":252
 *         self._cache[(inprofile, outprofile, format, intent, flags)] = trafo
 *         self.creations += 1
 *         return trafo             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_trafo));
  __pyx_r = ((PyObject *)__pyx_v_trafo);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.addEntry", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_trafo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_3clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_3clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_2clear(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":254
 *         return trafo
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self._cache.clear()
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_2clear(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clear", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":255
 * 
 *     def clear(self):
 *         self._cache.clear()             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->_cache, __pyx_n_s__clear); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.clear", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_5keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_5keys(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("keys (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_4keys(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":257
 *         self._cache.clear()
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         return list(self._cache)
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_4keys(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("keys", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":258
 * 
 *     def keys(self):
 *         return list(self._cache)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->_cache);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->_cache);
  __Pyx_GIVEREF(__pyx_v_self->_cache);
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.keys", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_7__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_7__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_6__iter__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":260
 *         return list(self._cache)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return iter(self._cache)
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_6__iter__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":261
 * 
 *     def __iter__(self):
 *         return iter(self._cache)             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_self->_cache;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_9__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_9__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_8__contains__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self), ((PyObject *)__pyx_v_key));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":263
 *         return iter(self._cache)
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         return key in self._cache
 * 
 */

static int __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_8__contains__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__contains__", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":264
 * 
 *     def __contains__(self, key):
 *         return key in self._cache             # <<<<<<<<<<<<<<
 * 
 *     def lookupByImage(self,
 */
  __pyx_t_1 = ((PySequence_Contains(__pyx_v_self->_cache, __pyx_v_key))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_11lookupByImage(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_11lookupByImage(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_img = 0;
  PyObject *__pyx_v_outprofile = 0;
  int __pyx_v_format;
  int __pyx_v_intent;
  unsigned long __pyx_v_flags;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__img,&__pyx_n_s__outprofile,&__pyx_n_s__format,&__pyx_n_s__intent,&__pyx_n_s__flags,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lookupByImage (wrapper)", 0);
  {
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__img);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__outprofile);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lookupByImage", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lookupByImage", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intent);
        if (likely(values[3])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lookupByImage", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
        if (likely(values[4])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lookupByImage", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lookupByImage") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_img = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)values[0]);
    __pyx_v_outprofile = ((PyObject*)values[1]);
    __pyx_v_format = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_format == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_intent = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_intent == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_flags = __Pyx_PyInt_AsUnsignedLong(values[4]); if (unlikely((__pyx_v_flags == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lookupByImage", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.lookupByImage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_img), __pyx_ptype_3smc_9freeimage_10_freeimage_Image, 1, "img", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_outprofile), (&PyBytes_Type), 1, "outprofile", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_10lookupByImage(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self), __pyx_v_img, __pyx_v_outprofile, __pyx_v_format, __pyx_v_intent, __pyx_v_flags);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":266
 *         return key in self._cache
 * 
 *     def lookupByImage(self,             # <<<<<<<<<<<<<<
 *                       Image img,
 *                       bytes outprofile,
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_10lookupByImage(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_img, PyObject *__pyx_v_outprofile, int __pyx_v_format, int __pyx_v_intent, unsigned long __pyx_v_flags) {
  PyObject *__pyx_v_inprofile = 0;
  PyObject *__pyx_v_trafo = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lookupByImage", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":274
 *         cdef bytes inprofile
 * 
 *         inprofile = img.getICC()             # <<<<<<<<<<<<<<
 *         if not inprofile:
 *             return None
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_img), __pyx_n_s__getICC); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_inprofile = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":275
 * 
 *         inprofile = img.getICC()
 *         if not inprofile:             # <<<<<<<<<<<<<<
 *             return None
 *         trafo = self._cache.get((inprofile, outprofile, format, intent, flags))
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_inprofile) != Py_None) && (PyBytes_GET_SIZE(((PyObject *)__pyx_v_inprofile)) != 0);
  __pyx_t_4 = (!__pyx_t_3);
  if (__pyx_t_4) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":276
 *         inprofile = img.getICC()
 *         if not inprofile:
 *             return None             # <<<<<<<<<<<<<<
 *         trafo = self._cache.get((inprofile, outprofile, format, intent, flags))
 *         if trafo is None:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":277
 *         if not inprofile:
 *             return None
 *         trafo = self._cache.get((inprofile, outprofile, format, intent, flags))             # <<<<<<<<<<<<<<
 *         if trafo is None:
 *             trafo = self.addEntry(inprofile, outprofile, format, intent, flags)
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self->_cache, __pyx_n_s__get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyInt_FromLong(__pyx_v_intent); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyLong_FromUnsignedLong(__pyx_v_flags); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyTuple_New(5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_inprofile));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_inprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_inprofile));
  __Pyx_INCREF(((PyObject *)__pyx_v_outprofile));
  PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_v_outprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_outprofile));
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_7));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
  __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __pyx_v_trafo = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":278
 *             return None
 *         trafo = self._cache.get((inprofile, outprofile, format, intent, flags))
 *         if trafo is None:             # <<<<<<<<<<<<<<
 *             trafo = self.addEntry(inprofile, outprofile, format, intent, flags)
 *         return trafo
 */
  __pyx_t_4 = (__pyx_v_trafo == Py_None);
  if (__pyx_t_4) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":279
 *         trafo = self._cache.get((inprofile, outprofile, format, intent, flags))
 *         if trafo is None:
 *             trafo = self.addEntry(inprofile, outprofile, format, intent, flags)             # <<<<<<<<<<<<<<
 *         return trafo
 * 
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self->__pyx_vtab)->addEntry(__pyx_v_self, __pyx_v_inprofile, __pyx_v_outprofile, __pyx_v_format, __pyx_v_intent, __pyx_v_flags); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_v_trafo);
    __pyx_v_trafo = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":280
 *         if trafo is None:
 *             trafo = self.addEntry(inprofile, outprofile, format, intent, flags)
 *         return trafo             # <<<<<<<<<<<<<<
 * 
 *     def lookup(self,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_trafo);
  __pyx_r = __pyx_v_trafo;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.lookupByImage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_inprofile);
  __Pyx_XDECREF(__pyx_v_trafo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_13lookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_13lookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inprofile = 0;
  PyObject *__pyx_v_outprofile = 0;
  int __pyx_v_format;
  int __pyx_v_intent;
  unsigned long __pyx_v_flags;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__inprofile,&__pyx_n_s__outprofile,&__pyx_n_s__format,&__pyx_n_s__intent,&__pyx_n_s__flags,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lookup (wrapper)", 0);
  {
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__inprofile);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__outprofile);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lookup", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lookup", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intent);
        if (likely(values[3])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lookup", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
        if (likely(values[4])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("lookup", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lookup") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_inprofile = ((PyObject*)values[0]);
    __pyx_v_outprofile = ((PyObject*)values[1]);
    __pyx_v_format = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_format == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_intent = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_intent == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_flags = __Pyx_PyInt_AsUnsignedLong(values[4]); if (unlikely((__pyx_v_flags == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lookup", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.lookup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_inprofile), (&PyBytes_Type), 1, "inprofile", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_outprofile), (&PyBytes_Type), 1, "outprofile", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_12lookup(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self), __pyx_v_inprofile, __pyx_v_outprofile, __pyx_v_format, __pyx_v_intent, __pyx_v_flags);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":282
 *         return trafo
 * 
 *     def lookup(self,             # <<<<<<<<<<<<<<
 *                bytes inprofile,
 *                bytes outprofile,
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_12lookup(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self, PyObject *__pyx_v_inprofile, PyObject *__pyx_v_outprofile, int __pyx_v_format, int __pyx_v_intent, unsigned long __pyx_v_flags) {
  PyObject *__pyx_v_trafo = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lookup", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":288
 *                int intent,
 *                unsigned long flags):
 *         trafo = self._cache.get((inprofile, outprofile, format, intent, flags))             # <<<<<<<<<<<<<<
 *         if trafo is None:
 *             trafo = self.addEntry(inprofile, outprofile, format, intent, flags)
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->_cache, __pyx_n_s__get); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_intent); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_flags); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_v_inprofile));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_inprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_inprofile));
  __Pyx_INCREF(((PyObject *)__pyx_v_outprofile));
  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_outprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_outprofile));
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
  __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_v_trafo = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":289
 *                unsigned long flags):
 *         trafo = self._cache.get((inprofile, outprofile, format, intent, flags))
 *         if trafo is None:             # <<<<<<<<<<<<<<
 *             trafo = self.addEntry(inprofile, outprofile, format, intent, flags)
 *         return trafo
 */
  __pyx_t_6 = (__pyx_v_trafo == Py_None);
  if (__pyx_t_6) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":290
 *         trafo = self._cache.get((inprofile, outprofile, format, intent, flags))
 *         if trafo is None:
 *             trafo = self.addEntry(inprofile, outprofile, format, intent, flags)             # <<<<<<<<<<<<<<
 *         return trafo
 * 
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self->__pyx_vtab)->addEntry(__pyx_v_self, __pyx_v_inprofile, __pyx_v_outprofile, __pyx_v_format, __pyx_v_intent, __pyx_v_flags); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_v_trafo);
    __pyx_v_trafo = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":291
 *         if trafo is None:
 *             trafo = self.addEntry(inprofile, outprofile, format, intent, flags)
 *         return trafo             # <<<<<<<<<<<<<<
 * 
 *     def applyTransform(self,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_trafo);
  __pyx_r = __pyx_v_trafo;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.lookup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_trafo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_15applyTransform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_15applyTransform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_img = 0;
  PyObject *__pyx_v_inprofile = 0;
  PyObject *__pyx_v_outprofile = 0;
  int __pyx_v_intent;
  unsigned long __pyx_v_flags;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__img,&__pyx_n_s__inprofile,&__pyx_n_s__outprofile,&__pyx_n_s__intent,&__pyx_n_s__flags,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("applyTransform (wrapper)", 0);
  {
    PyObject* values[5] = {0,0,0,0,0};

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":295
 *     def applyTransform(self,
 *               Image img,
 *               bytes inprofile=None,             # <<<<<<<<<<<<<<
 *               bytes outprofile=b"sRGB",
 *               int intent=lcms.INTENT_PERCEPTUAL,
 */
    values[1] = ((PyObject*)Py_None);
    values[2] = ((PyObject*)__pyx_n_b__sRGB);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__img);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__inprofile);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__outprofile);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intent);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "applyTransform") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[3]) {
      } else {
        __pyx_v_intent = __pyx_k_16;
      }
      if (values[4]) {
      } else {
        __pyx_v_flags = ((unsigned long)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_img = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)values[0]);
    __pyx_v_inprofile = ((PyObject*)values[1]);
    __pyx_v_outprofile = ((PyObject*)values[2]);
    if (values[3]) {
      __pyx_v_intent = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_intent == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_intent = __pyx_k_16;
    }
    if (values[4]) {
      __pyx_v_flags = __Pyx_PyInt_AsUnsignedLong(values[4]); if (unlikely((__pyx_v_flags == (unsigned long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((unsigned long)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("applyTransform", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.applyTransform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_img), __pyx_ptype_3smc_9freeimage_10_freeimage_Image, 1, "img", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_inprofile), (&PyBytes_Type), 1, "inprofile", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_outprofile), (&PyBytes_Type), 1, "outprofile", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_14applyTransform(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self), __pyx_v_img, __pyx_v_inprofile, __pyx_v_outprofile, __pyx_v_intent, __pyx_v_flags);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":293
 *         return trafo
 * 
 *     def applyTransform(self,             # <<<<<<<<<<<<<<
 *               Image img,
 *               bytes inprofile=None,
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_14applyTransform(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_img, PyObject *__pyx_v_inprofile, PyObject *__pyx_v_outprofile, int __pyx_v_intent, unsigned long __pyx_v_flags) {
  FIBITMAP *__pyx_v_dib;
  BYTE *__pyx_v_bits;
  unsigned int __pyx_v_width;
  unsigned int __pyx_v_height;
  unsigned int __pyx_v_pitch;
  unsigned int __pyx_v_bpp;
  CYTHON_UNUSED unsigned int __pyx_v_y;
  enum FREE_IMAGE_TYPE __pyx_v_image_type;
  cmsHTRANSFORM __pyx_v_hTransform;
  PyObject *__pyx_v_isBGR = NULL;
  PyObject *__pyx_v_format = NULL;
  PyObject *__pyx_v_trafo = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  unsigned int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("applyTransform", 0);
  __Pyx_INCREF(__pyx_v_inprofile);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":307
 *         cdef lcms.cmsHTRANSFORM hTransform
 * 
 *         dib = img._dib             # <<<<<<<<<<<<<<
 *         if not dib:
 *             raise ValueError("Image has no data")
 */
  __pyx_v_dib = __pyx_v_img->_dib;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":308
 * 
 *         dib = img._dib
 *         if not dib:             # <<<<<<<<<<<<<<
 *             raise ValueError("Image has no data")
 *         if inprofile is None:
 */
  __pyx_t_1 = (!(__pyx_v_dib != 0));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":309
 *         dib = img._dib
 *         if not dib:
 *             raise ValueError("Image has no data")             # <<<<<<<<<<<<<<
 *         if inprofile is None:
 *             if not img.has_icc:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":310
 *         if not dib:
 *             raise ValueError("Image has no data")
 *         if inprofile is None:             # <<<<<<<<<<<<<<
 *             if not img.has_icc:
 *                 raise ValueError("Image has no embedded ICC profile")
 */
  __pyx_t_1 = (__pyx_v_inprofile == ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":311
 *             raise ValueError("Image has no data")
 *         if inprofile is None:
 *             if not img.has_icc:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Image has no embedded ICC profile")
 *             inprofile = img.getICC()
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_img), __pyx_n_s__has_icc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = (!__pyx_t_1);
    if (__pyx_t_3) {

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":312
 *         if inprofile is None:
 *             if not img.has_icc:
 *                 raise ValueError("Image has no embedded ICC profile")             # <<<<<<<<<<<<<<
 *             inprofile = img.getICC()
 * 
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":313
 *             if not img.has_icc:
 *                 raise ValueError("Image has no embedded ICC profile")
 *             inprofile = img.getICC()             # <<<<<<<<<<<<<<
 * 
 *         image_type = fi.FreeImage_GetImageType(dib)
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_img), __pyx_n_s__getICC); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_inprofile));
    __pyx_v_inprofile = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":315
 *             inprofile = img.getICC()
 * 
 *         image_type = fi.FreeImage_GetImageType(dib)             # <<<<<<<<<<<<<<
 *         bpp = fi.FreeImage_GetBPP(dib)
 *         width = fi.FreeImage_GetWidth(dib)
 */
  __pyx_v_image_type = FreeImage_GetImageType(__pyx_v_dib);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":316
 * 
 *         image_type = fi.FreeImage_GetImageType(dib)
 *         bpp = fi.FreeImage_GetBPP(dib)             # <<<<<<<<<<<<<<
 *         width = fi.FreeImage_GetWidth(dib)
 *         height = fi.FreeImage_GetHeight(dib)
 */
  __pyx_v_bpp = FreeImage_GetBPP(__pyx_v_dib);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":317
 *         image_type = fi.FreeImage_GetImageType(dib)
 *         bpp = fi.FreeImage_GetBPP(dib)
 *         width = fi.FreeImage_GetWidth(dib)             # <<<<<<<<<<<<<<
 *         height = fi.FreeImage_GetHeight(dib)
 *         pitch = fi.FreeImage_GetPitch(dib)
 */
  __pyx_v_width = FreeImage_GetWidth(__pyx_v_dib);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":318
 *         bpp = fi.FreeImage_GetBPP(dib)
 *         width = fi.FreeImage_GetWidth(dib)
 *         height = fi.FreeImage_GetHeight(dib)             # <<<<<<<<<<<<<<
 *         pitch = fi.FreeImage_GetPitch(dib)
 *         isBGR = fi.FREEIMAGE_COLORORDER == fi.FREEIMAGE_COLORORDER_BGR
 */
  __pyx_v_height = FreeImage_GetHeight(__pyx_v_dib);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":319
 *         width = fi.FreeImage_GetWidth(dib)
 *         height = fi.FreeImage_GetHeight(dib)
 *         pitch = fi.FreeImage_GetPitch(dib)             # <<<<<<<<<<<<<<
 *         isBGR = fi.FREEIMAGE_COLORORDER == fi.FREEIMAGE_COLORORDER_BGR
 * 
 */
  __pyx_v_pitch = FreeImage_GetPitch(__pyx_v_dib);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":320
 *         height = fi.FreeImage_GetHeight(dib)
 *         pitch = fi.FreeImage_GetPitch(dib)
 *         isBGR = fi.FREEIMAGE_COLORORDER == fi.FREEIMAGE_COLORORDER_BGR             # <<<<<<<<<<<<<<
 * 
 *         format = None
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong((FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_isBGR = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":322
 *         isBGR = fi.FREEIMAGE_COLORORDER == fi.FREEIMAGE_COLORORDER_BGR
 * 
 *         format = None             # <<<<<<<<<<<<<<
 * 
 *         if image_type == fi.FIT_BITMAP:
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_format = Py_None;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":324
 *         format = None
 * 
 *         if image_type == fi.FIT_BITMAP:             # <<<<<<<<<<<<<<
 *             if bpp == 24:
 *                 format = lcms.TYPE_BGR_8 if isBGR else lcms.TYPE_RGB_8
 */
  __pyx_t_3 = (__pyx_v_image_type == FIT_BITMAP);
  if (__pyx_t_3) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":329
 *             elif bpp == 32:
 *                 format = lcms.TYPE_ABGR_8 if isBGR else lcms.TYPE_RGBA_8
 *             elif bpp == 8:             # <<<<<<<<<<<<<<
 *                  format = lcms.TYPE_GRAY_8
 *         if image_type == fi.FIT_RGB16 and bpp == 48:
 */
    switch (__pyx_v_bpp) {

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":325
 * 
 *         if image_type == fi.FIT_BITMAP:
 *             if bpp == 24:             # <<<<<<<<<<<<<<
 *                 format = lcms.TYPE_BGR_8 if isBGR else lcms.TYPE_RGB_8
 *             elif bpp == 32:
 */
      case 24:

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":326
 *         if image_type == fi.FIT_BITMAP:
 *             if bpp == 24:
 *                 format = lcms.TYPE_BGR_8 if isBGR else lcms.TYPE_RGB_8             # <<<<<<<<<<<<<<
 *             elif bpp == 32:
 *                 format = lcms.TYPE_ABGR_8 if isBGR else lcms.TYPE_RGBA_8
 */
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_isBGR); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_3) {
        __pyx_t_5 = TYPE_BGR_8;
      } else {
        __pyx_t_5 = TYPE_RGB_8;
      }
      __pyx_t_4 = PyInt_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_v_format);
      __pyx_v_format = __pyx_t_4;
      __pyx_t_4 = 0;
      break;

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":327
 *             if bpp == 24:
 *                 format = lcms.TYPE_BGR_8 if isBGR else lcms.TYPE_RGB_8
 *             elif bpp == 32:             # <<<<<<<<<<<<<<
 *                 format = lcms.TYPE_ABGR_8 if isBGR else lcms.TYPE_RGBA_8
 *             elif bpp == 8:
 */
      case 32:

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":328
 *                 format = lcms.TYPE_BGR_8 if isBGR else lcms.TYPE_RGB_8
 *             elif bpp == 32:
 *                 format = lcms.TYPE_ABGR_8 if isBGR else lcms.TYPE_RGBA_8             # <<<<<<<<<<<<<<
 *             elif bpp == 8:
 *                  format = lcms.TYPE_GRAY_8
 */
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_isBGR); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_3) {
        __pyx_t_5 = TYPE_ABGR_8;
      } else {
        __pyx_t_5 = TYPE_RGBA_8;
      }
      __pyx_t_4 = PyInt_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_v_format);
      __pyx_v_format = __pyx_t_4;
      __pyx_t_4 = 0;
      break;

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":329
 *             elif bpp == 32:
 *                 format = lcms.TYPE_ABGR_8 if isBGR else lcms.TYPE_RGBA_8
 *             elif bpp == 8:             # <<<<<<<<<<<<<<
 *                  format = lcms.TYPE_GRAY_8
 *         if image_type == fi.FIT_RGB16 and bpp == 48:
 */
      case 8:

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":330
 *                 format = lcms.TYPE_ABGR_8 if isBGR else lcms.TYPE_RGBA_8
 *             elif bpp == 8:
 *                  format = lcms.TYPE_GRAY_8             # <<<<<<<<<<<<<<
 *         if image_type == fi.FIT_RGB16 and bpp == 48:
 *             format = lcms.TYPE_BGR_16 if isBGR else lcms.TYPE_RGB_16
 */
      __pyx_t_4 = PyInt_FromLong(TYPE_GRAY_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_v_format);
      __pyx_v_format = __pyx_t_4;
      __pyx_t_4 = 0;
      break;
    }
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":331
 *             elif bpp == 8:
 *                  format = lcms.TYPE_GRAY_8
 *         if image_type == fi.FIT_RGB16 and bpp == 48:             # <<<<<<<<<<<<<<
 *             format = lcms.TYPE_BGR_16 if isBGR else lcms.TYPE_RGB_16
 * 
 */
  __pyx_t_3 = (__pyx_v_image_type == FIT_RGB16);
  if (__pyx_t_3) {
    __pyx_t_1 = (__pyx_v_bpp == 48);
    __pyx_t_6 = __pyx_t_1;
  } else {
    __pyx_t_6 = __pyx_t_3;
  }
  if (__pyx_t_6) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":332
 *                  format = lcms.TYPE_GRAY_8
 *         if image_type == fi.FIT_RGB16 and bpp == 48:
 *             format = lcms.TYPE_BGR_16 if isBGR else lcms.TYPE_RGB_16             # <<<<<<<<<<<<<<
 * 
 *         if format is None:
 */
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_isBGR); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_6) {
      __pyx_t_5 = TYPE_BGR_16;
    } else {
      __pyx_t_5 = TYPE_RGB_16;
    }
    __pyx_t_4 = PyInt_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_v_format);
    __pyx_v_format = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":334
 *             format = lcms.TYPE_BGR_16 if isBGR else lcms.TYPE_RGB_16
 * 
 *         if format is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("Only 8, 16, 24 and 48bpp images are supported for now, image_type = %s, bbp: %s"
 *                               % (image_type, bpp))
 */
  __pyx_t_6 = (__pyx_v_format == Py_None);
  if (__pyx_t_6) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":336
 *         if format is None:
 *             raise ValueError("Only 8, 16, 24 and 48bpp images are supported for now, image_type = %s, bbp: %s"
 *                               % (image_type, bpp))             # <<<<<<<<<<<<<<
 * 
 *         trafo = self.lookup(inprofile, outprofile, format, intent, flags)
 */
    __pyx_t_4 = PyInt_FromLong(__pyx_v_image_type); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_bpp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":338
 *                               % (image_type, bpp))
 * 
 *         trafo = self.lookup(inprofile, outprofile, format, intent, flags)             # <<<<<<<<<<<<<<
 *         if trafo is None or not isinstance(trafo, LCMSTransformation):
 *             raise ValueError("Failed to lookup or create transformation")
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lookup); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = PyInt_FromLong(__pyx_v_intent); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_flags); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = PyTuple_New(5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(((PyObject *)__pyx_v_inprofile));
  PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_inprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_inprofile));
  __Pyx_INCREF(((PyObject *)__pyx_v_outprofile));
  PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_v_outprofile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_outprofile));
  __Pyx_INCREF(__pyx_v_format);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_format);
  __Pyx_GIVEREF(__pyx_v_format);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_7 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  __pyx_v_trafo = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":339
 * 
 *         trafo = self.lookup(inprofile, outprofile, format, intent, flags)
 *         if trafo is None or not isinstance(trafo, LCMSTransformation):             # <<<<<<<<<<<<<<
 *             raise ValueError("Failed to lookup or create transformation")
 * 
 */
  __pyx_t_6 = (__pyx_v_trafo == Py_None);
  if (!__pyx_t_6) {
    __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_LCMSTransformation));
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_trafo, __pyx_t_4); 
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = (!__pyx_t_3);
    __pyx_t_3 = __pyx_t_1;
  } else {
    __pyx_t_3 = __pyx_t_6;
  }
  if (__pyx_t_3) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":340
 *         trafo = self.lookup(inprofile, outprofile, format, intent, flags)
 *         if trafo is None or not isinstance(trafo, LCMSTransformation):
 *             raise ValueError("Failed to lookup or create transformation")             # <<<<<<<<<<<<<<
 * 
 *         hTransform = (< LCMSTransformation > trafo).hTransform
 */
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":342
 *             raise ValueError("Failed to lookup or create transformation")
 * 
 *         hTransform = (< LCMSTransformation > trafo).hTransform             # <<<<<<<<<<<<<<
 *         if not hTransform:
 *             raise ValueError("Transformation has no transformation handle")
 */
  __pyx_v_hTransform = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_v_trafo)->hTransform;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":343
 * 
 *         hTransform = (< LCMSTransformation > trafo).hTransform
 *         if not hTransform:             # <<<<<<<<<<<<<<
 *             raise ValueError("Transformation has no transformation handle")
 * 
 */
  __pyx_t_3 = (!(__pyx_v_hTransform != 0));
  if (__pyx_t_3) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":344
 *         hTransform = (< LCMSTransformation > trafo).hTransform
 *         if not hTransform:
 *             raise ValueError("Transformation has no transformation handle")             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":346
 *             raise ValueError("Transformation has no transformation handle")
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             bits = fi.FreeImage_GetBits(dib)
 *             for y from 0 <= y < height:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":347
 * 
 *         with nogil:
 *             bits = fi.FreeImage_GetBits(dib)             # <<<<<<<<<<<<<<
 *             for y from 0 <= y < height:
 *                 lcms.cmsDoTransform(hTransform, < char *> bits, < char *> bits, width)
 */
        __pyx_v_bits = FreeImage_GetBits(__pyx_v_dib);

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":348
 *         with nogil:
 *             bits = fi.FreeImage_GetBits(dib)
 *             for y from 0 <= y < height:             # <<<<<<<<<<<<<<
 *                 lcms.cmsDoTransform(hTransform, < char *> bits, < char *> bits, width)
 *                 bits += pitch
 */
        __pyx_t_9 = __pyx_v_height;
        for (__pyx_v_y = 0; __pyx_v_y < __pyx_t_9; __pyx_v_y++) {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":349
 *             bits = fi.FreeImage_GetBits(dib)
 *             for y from 0 <= y < height:
 *                 lcms.cmsDoTransform(hTransform, < char *> bits, < char *> bits, width)             # <<<<<<<<<<<<<<
 *                 bits += pitch
 * 
 */
          cmsDoTransform(__pyx_v_hTransform, ((char *)__pyx_v_bits), ((char *)__pyx_v_bits), __pyx_v_width);

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":350
 *             for y from 0 <= y < height:
 *                 lcms.cmsDoTransform(hTransform, < char *> bits, < char *> bits, width)
 *                 bits += pitch             # <<<<<<<<<<<<<<
 * 
 * cdef int lcmsFI(Image img, LCMSTransformation trafo) except * :
 */
          __pyx_v_bits = (__pyx_v_bits + __pyx_v_pitch);
        }
      }

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":346
 *             raise ValueError("Transformation has no transformation handle")
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             bits = fi.FreeImage_GetBits(dib)
 *             for y from 0 <= y < height:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.applyTransform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_isBGR);
  __Pyx_XDECREF(__pyx_v_format);
  __Pyx_XDECREF(__pyx_v_trafo);
  __Pyx_XDECREF(__pyx_v_inprofile);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_9creations_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_9creations_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_9creations___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":237
 * cdef class LCMSIccCache(object):
 *     cdef object _cache
 *     cdef readonly int creations             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self):
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12LCMSIccCache_9creations___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->creations); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSIccCache.creations.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":352
 *                 bits += pitch
 * 
 * cdef int lcmsFI(Image img, LCMSTransformation trafo) except * :             # <<<<<<<<<<<<<<
 *     """Apply transformation from a LCMS Transformation object upon a FreeImage object
 *     """
 */

static int __pyx_f_3smc_9freeimage_10_freeimage_lcmsFI(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_img, struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_trafo) {
  FIBITMAP *__pyx_v_dib;
  BYTE *__pyx_v_bits;
  unsigned int __pyx_v_width;
  unsigned int __pyx_v_height;
  unsigned int __pyx_v_pitch;
  unsigned int __pyx_v_bpp;
  CYTHON_UNUSED unsigned int __pyx_v_y;
  enum FREE_IMAGE_TYPE __pyx_v_image_type;
  cmsHTRANSFORM __pyx_v_hTransform;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  unsigned int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lcmsFI", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":362
 *     cdef lcms.cmsHTRANSFORM hTransform
 * 
 *     dib = img._dib             # <<<<<<<<<<<<<<
 *     if not dib:
 *         raise ValueError("Image has no data")
 */
  __pyx_v_dib = __pyx_v_img->_dib;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":363
 * 
 *     dib = img._dib
 *     if not dib:             # <<<<<<<<<<<<<<
 *         raise ValueError("Image has no data")
 * 
 */
  __pyx_t_1 = (!(__pyx_v_dib != 0));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":364
 *     dib = img._dib
 *     if not dib:
 *         raise ValueError("Image has no data")             # <<<<<<<<<<<<<<
 * 
 *     hTransform = trafo.hTransform
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":366
 *         raise ValueError("Image has no data")
 * 
 *     hTransform = trafo.hTransform             # <<<<<<<<<<<<<<
 *     if not hTransform:
 *         raise ValueError("Transformation has no transformation handle")
 */
  __pyx_v_hTransform = __pyx_v_trafo->hTransform;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":367
 * 
 *     hTransform = trafo.hTransform
 *     if not hTransform:             # <<<<<<<<<<<<<<
 *         raise ValueError("Transformation has no transformation handle")
 * 
 */
  __pyx_t_1 = (!(__pyx_v_hTransform != 0));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":368
 *     hTransform = trafo.hTransform
 *     if not hTransform:
 *         raise ValueError("Transformation has no transformation handle")             # <<<<<<<<<<<<<<
 * 
 *     image_type = fi.FreeImage_GetImageType(dib)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_27), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":370
 *         raise ValueError("Transformation has no transformation handle")
 * 
 *     image_type = fi.FreeImage_GetImageType(dib)             # <<<<<<<<<<<<<<
 *     bpp = fi.FreeImage_GetBPP(dib)
 *     width = fi.FreeImage_GetWidth(dib)
 */
  __pyx_v_image_type = FreeImage_GetImageType(__pyx_v_dib);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":371
 * 
 *     image_type = fi.FreeImage_GetImageType(dib)
 *     bpp = fi.FreeImage_GetBPP(dib)             # <<<<<<<<<<<<<<
 *     width = fi.FreeImage_GetWidth(dib)
 *     height = fi.FreeImage_GetHeight(dib)
 */
  __pyx_v_bpp = FreeImage_GetBPP(__pyx_v_dib);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":372
 *     image_type = fi.FreeImage_GetImageType(dib)
 *     bpp = fi.FreeImage_GetBPP(dib)
 *     width = fi.FreeImage_GetWidth(dib)             # <<<<<<<<<<<<<<
 *     height = fi.FreeImage_GetHeight(dib)
 *     pitch = fi.FreeImage_GetPitch(dib)
 */
  __pyx_v_width = FreeImage_GetWidth(__pyx_v_dib);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":373
 *     bpp = fi.FreeImage_GetBPP(dib)
 *     width = fi.FreeImage_GetWidth(dib)
 *     height = fi.FreeImage_GetHeight(dib)             # <<<<<<<<<<<<<<
 *     pitch = fi.FreeImage_GetPitch(dib)
 * 
 */
  __pyx_v_height = FreeImage_GetHeight(__pyx_v_dib);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":374
 *     width = fi.FreeImage_GetWidth(dib)
 *     height = fi.FreeImage_GetHeight(dib)
 *     pitch = fi.FreeImage_GetPitch(dib)             # <<<<<<<<<<<<<<
 * 
 *     if image_type != fi.FIT_BITMAP or bpp != 24 or fi.FREEIMAGE_COLORORDER != fi.FREEIMAGE_COLORORDER_BGR:
 */
  __pyx_v_pitch = FreeImage_GetPitch(__pyx_v_dib);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":376
 *     pitch = fi.FreeImage_GetPitch(dib)
 * 
 *     if image_type != fi.FIT_BITMAP or bpp != 24 or fi.FREEIMAGE_COLORORDER != fi.FREEIMAGE_COLORORDER_BGR:             # <<<<<<<<<<<<<<
 *             raise ValueError("Only 24bit bitmaps are supported for now, image_type = %s, bbp: %s"
 *                               % (image_type, bpp))
 */
  __pyx_t_1 = (__pyx_v_image_type != FIT_BITMAP);
  if (!__pyx_t_1) {
    __pyx_t_3 = (__pyx_v_bpp != 24);
    if (!__pyx_t_3) {
      __pyx_t_4 = (FREEIMAGE_COLORORDER != FREEIMAGE_COLORORDER_BGR);
      __pyx_t_5 = __pyx_t_4;
    } else {
      __pyx_t_5 = __pyx_t_3;
    }
    __pyx_t_3 = __pyx_t_5;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":378
 *     if image_type != fi.FIT_BITMAP or bpp != 24 or fi.FREEIMAGE_COLORORDER != fi.FREEIMAGE_COLORORDER_BGR:
 *             raise ValueError("Only 24bit bitmaps are supported for now, image_type = %s, bbp: %s"
 *                               % (image_type, bpp))             # <<<<<<<<<<<<<<
 * 
 *     with nogil:
 */
    __pyx_t_2 = PyInt_FromLong(__pyx_v_image_type); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyLong_FromUnsignedLong(__pyx_v_bpp); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":380
 *                               % (image_type, bpp))
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         bits = fi.FreeImage_GetBits(dib)
 *         for y from 0 <= y < height:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":381
 * 
 *     with nogil:
 *         bits = fi.FreeImage_GetBits(dib)             # <<<<<<<<<<<<<<
 *         for y from 0 <= y < height:
 *             lcms.cmsDoTransform(hTransform, < char *> bits, < char *> bits, width)
 */
        __pyx_v_bits = FreeImage_GetBits(__pyx_v_dib);

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":382
 *     with nogil:
 *         bits = fi.FreeImage_GetBits(dib)
 *         for y from 0 <= y < height:             # <<<<<<<<<<<<<<
 *             lcms.cmsDoTransform(hTransform, < char *> bits, < char *> bits, width)
 *             bits += pitch
 */
        __pyx_t_8 = __pyx_v_height;
        for (__pyx_v_y = 0; __pyx_v_y < __pyx_t_8; __pyx_v_y++) {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":383
 *         bits = fi.FreeImage_GetBits(dib)
 *         for y from 0 <= y < height:
 *             lcms.cmsDoTransform(hTransform, < char *> bits, < char *> bits, width)             # <<<<<<<<<<<<<<
 *             bits += pitch
 * 
 */
          cmsDoTransform(__pyx_v_hTransform, ((char *)__pyx_v_bits), ((char *)__pyx_v_bits), __pyx_v_width);

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":384
 *         for y from 0 <= y < height:
 *             lcms.cmsDoTransform(hTransform, < char *> bits, < char *> bits, width)
 *             bits += pitch             # <<<<<<<<<<<<<<
 * 
 * cdef object int2str(unsigned int i):
 */
          __pyx_v_bits = (__pyx_v_bits + __pyx_v_pitch);
        }
      }

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":380
 *                               % (image_type, bpp))
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         bits = fi.FreeImage_GetBits(dib)
 *         for y from 0 <= y < height:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("smc.freeimage._freeimage.lcmsFI", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":386
 *             bits += pitch
 * 
 * cdef object int2str(unsigned int i):             # <<<<<<<<<<<<<<
 *     cdef char out[5]
 *     if not i:
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_int2str(unsigned int __pyx_v_i) {
  char __pyx_v_out[5];
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("int2str", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":388
 * cdef object int2str(unsigned int i):
 *     cdef char out[5]
 *     if not i:             # <<<<<<<<<<<<<<
 *         return None
 *     out[0] = < char > (i >> 24)
 */
  __pyx_t_1 = (!__pyx_v_i);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":389
 *     cdef char out[5]
 *     if not i:
 *         return None             # <<<<<<<<<<<<<<
 *     out[0] = < char > (i >> 24)
 *     out[1] = < char > (i >> 16)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":390
 *     if not i:
 *         return None
 *     out[0] = < char > (i >> 24)             # <<<<<<<<<<<<<<
 *     out[1] = < char > (i >> 16)
 *     out[2] = < char > (i >> 8)
 */
  (__pyx_v_out[0]) = ((char)(__pyx_v_i >> 24));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":391
 *         return None
 *     out[0] = < char > (i >> 24)
 *     out[1] = < char > (i >> 16)             # <<<<<<<<<<<<<<
 *     out[2] = < char > (i >> 8)
 *     out[3] = < char > i
 */
  (__pyx_v_out[1]) = ((char)(__pyx_v_i >> 16));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":392
 *     out[0] = < char > (i >> 24)
 *     out[1] = < char > (i >> 16)
 *     out[2] = < char > (i >> 8)             # <<<<<<<<<<<<<<
 *     out[3] = < char > i
 *     out[4] = 0
 */
  (__pyx_v_out[2]) = ((char)(__pyx_v_i >> 8));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":393
 *     out[1] = < char > (i >> 16)
 *     out[2] = < char > (i >> 8)
 *     out[3] = < char > i             # <<<<<<<<<<<<<<
 *     out[4] = 0
 *     return out
 */
  (__pyx_v_out[3]) = ((char)__pyx_v_i);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":394
 *     out[2] = < char > (i >> 8)
 *     out[3] = < char > i
 *     out[4] = 0             # <<<<<<<<<<<<<<
 *     return out
 * 
 */
  (__pyx_v_out[4]) = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":395
 *     out[3] = < char > i
 *     out[4] = 0
 *     return out             # <<<<<<<<<<<<<<
 * 
 * cdef xyz_py(lcms.cmsCIEXYZ * XYZ):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyBytes_FromString(__pyx_v_out); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_r = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.int2str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":397
 *     return out
 * 
 * cdef xyz_py(lcms.cmsCIEXYZ * XYZ):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsCIExyY xyY[1]
 *     lcms.cmsXYZ2xyY(xyY, XYZ)
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_xyz_py(cmsCIEXYZ *__pyx_v_XYZ) {
  cmsCIExyY __pyx_v_xyY[1];
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("xyz_py", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":399
 * cdef xyz_py(lcms.cmsCIEXYZ * XYZ):
 *     cdef lcms.cmsCIExyY xyY[1]
 *     lcms.cmsXYZ2xyY(xyY, XYZ)             # <<<<<<<<<<<<<<
 *     return (XYZ.X, XYZ.Y, XYZ.Z), (xyY.x, xyY.y, xyY.Y)
 * 
 */
  cmsXYZ2xyY(__pyx_v_xyY, __pyx_v_XYZ);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":400
 *     cdef lcms.cmsCIExyY xyY[1]
 *     lcms.cmsXYZ2xyY(xyY, XYZ)
 *     return (XYZ.X, XYZ.Y, XYZ.Z), (xyY.x, xyY.y, xyY.Y)             # <<<<<<<<<<<<<<
 * 
 * cdef xyztrip_py(lcms.cmsCIEXYZTRIPLE * trip):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_XYZ->X); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_XYZ->Y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_XYZ->Z); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_xyY->x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_xyY->y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_xyY->Y); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_t_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage.xyz_py", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":402
 *     return (XYZ.X, XYZ.Y, XYZ.Z), (xyY.x, xyY.y, xyY.Y)
 * 
 * cdef xyztrip_py(lcms.cmsCIEXYZTRIPLE * trip):             # <<<<<<<<<<<<<<
 *     red = xyz_py(& trip.Red)
 *     green = xyz_py(& trip.Green)
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_xyztrip_py(cmsCIEXYZTRIPLE *__pyx_v_trip) {
  PyObject *__pyx_v_red = NULL;
  PyObject *__pyx_v_green = NULL;
  PyObject *__pyx_v_blue = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("xyztrip_py", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":403
 * 
 * cdef xyztrip_py(lcms.cmsCIEXYZTRIPLE * trip):
 *     red = xyz_py(& trip.Red)             # <<<<<<<<<<<<<<
 *     green = xyz_py(& trip.Green)
 *     blue = xyz_py(& trip.Blue)
 */
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_xyz_py((&__pyx_v_trip->Red)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_red = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":404
 * cdef xyztrip_py(lcms.cmsCIEXYZTRIPLE * trip):
 *     red = xyz_py(& trip.Red)
 *     green = xyz_py(& trip.Green)             # <<<<<<<<<<<<<<
 *     blue = xyz_py(& trip.Blue)
 *     return {'red': red, 'green': green, 'blue': blue}
 */
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_xyz_py((&__pyx_v_trip->Green)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_green = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":405
 *     red = xyz_py(& trip.Red)
 *     green = xyz_py(& trip.Green)
 *     blue = xyz_py(& trip.Blue)             # <<<<<<<<<<<<<<
 *     return {'red': red, 'green': green, 'blue': blue}
 * 
 */
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_xyz_py((&__pyx_v_trip->Blue)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_blue = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":406
 *     green = xyz_py(& trip.Green)
 *     blue = xyz_py(& trip.Blue)
 *     return {'red': red, 'green': green, 'blue': blue}             # <<<<<<<<<<<<<<
 * 
 * cdef xyz3_py(lcms.cmsCIEXYZ * XYZ3):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__red), __pyx_v_red) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__green), __pyx_v_green) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__blue), __pyx_v_blue) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.xyztrip_py", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_red);
  __Pyx_XDECREF(__pyx_v_green);
  __Pyx_XDECREF(__pyx_v_blue);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":408
 *     return {'red': red, 'green': green, 'blue': blue}
 * 
 * cdef xyz3_py(lcms.cmsCIEXYZ * XYZ3):             # <<<<<<<<<<<<<<
 *     t1 = xyz_py(& XYZ3[0])
 *     t2 = xyz_py(& XYZ3[1])
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_xyz3_py(cmsCIEXYZ *__pyx_v_XYZ3) {
  PyObject *__pyx_v_t1 = NULL;
  PyObject *__pyx_v_t2 = NULL;
  PyObject *__pyx_v_t3 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("xyz3_py", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":409
 * 
 * cdef xyz3_py(lcms.cmsCIEXYZ * XYZ3):
 *     t1 = xyz_py(& XYZ3[0])             # <<<<<<<<<<<<<<
 *     t2 = xyz_py(& XYZ3[1])
 *     t3 = xyz_py(& XYZ3[2])
 */
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_xyz_py((&(__pyx_v_XYZ3[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_t1 = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":410
 * cdef xyz3_py(lcms.cmsCIEXYZ * XYZ3):
 *     t1 = xyz_py(& XYZ3[0])
 *     t2 = xyz_py(& XYZ3[1])             # <<<<<<<<<<<<<<
 *     t3 = xyz_py(& XYZ3[2])
 *     return (t1[0], t2[0], t3[0]), (t1[1], t2[1], t3[1])
 */
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_xyz_py((&(__pyx_v_XYZ3[1]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_t2 = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":411
 *     t1 = xyz_py(& XYZ3[0])
 *     t2 = xyz_py(& XYZ3[1])
 *     t3 = xyz_py(& XYZ3[2])             # <<<<<<<<<<<<<<
 *     return (t1[0], t2[0], t3[0]), (t1[1], t2[1], t3[1])
 * 
 */
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_xyz_py((&(__pyx_v_XYZ3[2]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_t3 = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":412
 *     t2 = xyz_py(& XYZ3[1])
 *     t3 = xyz_py(& XYZ3[2])
 *     return (t1[0], t2[0], t3[0]), (t1[1], t2[1], t3[1])             # <<<<<<<<<<<<<<
 * 
 * _illu_map = {0: "unknown", 1: "D50", 2: "D65", 3: "D93", 4: "F2", 5: "D55", 6: "A", 7: "E", 8: "F8"}
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_t1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_t2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_t3, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_t1, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_t2, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_t3, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_t_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage.xyz3_py", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t1);
  __Pyx_XDECREF(__pyx_v_t2);
  __Pyx_XDECREF(__pyx_v_t3);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_data = 0;
  PyObject *__pyx_v_filename = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__data,&__pyx_n_s__filename,0};
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    PyObject* values[2] = {0,0};

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":420
 *     cdef public dict info
 * 
 *     def __init__(self, bytes data=None, filename=None):             # <<<<<<<<<<<<<<
 *         self.hProfile = NULL
 *         cdef lcms.cmsContext context
 */
    values[0] = ((PyObject*)Py_None);
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_data = ((PyObject*)values[0]);
    __pyx_v_filename = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyBytes_Type), 1, "data", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo___init__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self), __pyx_v_data, __pyx_v_filename);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self, PyObject *__pyx_v_data, PyObject *__pyx_v_filename) {
  PyObject *__pyx_v_f = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  char *__pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  cmsHPROFILE __pyx_t_5;
  struct __pyx_opt_args_3smc_9freeimage_10_freeimage_createHProfile __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_INCREF(__pyx_v_data);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":421
 * 
 *     def __init__(self, bytes data=None, filename=None):
 *         self.hProfile = NULL             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsContext context
 *         cdef int size
 */
  __pyx_v_self->hProfile = NULL;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":425
 *         cdef int size
 * 
 *         if data is not None:             # <<<<<<<<<<<<<<
 *             self.hProfile = createHProfile(data, len(data), "in")
 *         elif filename is not None:
 */
  __pyx_t_1 = (__pyx_v_data != ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":426
 * 
 *         if data is not None:
 *             self.hProfile = createHProfile(data, len(data), "in")             # <<<<<<<<<<<<<<
 *         elif filename is not None:
 *             with open(filename, "rb") as f:
 */
    __pyx_t_2 = PyBytes_AsString(((PyObject *)__pyx_v_data)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(((PyObject *)__pyx_v_data) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_3 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_data)); 
    __pyx_t_4 = ((PyObject *)__pyx_n_s__in);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_6.__pyx_n = 1;
    __pyx_t_6.mode = __pyx_t_4;
    __pyx_t_5 = __pyx_f_3smc_9freeimage_10_freeimage_createHProfile(__pyx_t_2, __pyx_t_3, &__pyx_t_6); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_self->hProfile = __pyx_t_5;
    goto __pyx_L3;
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":427
 *         if data is not None:
 *             self.hProfile = createHProfile(data, len(data), "in")
 *         elif filename is not None:             # <<<<<<<<<<<<<<
 *             with open(filename, "rb") as f:
 *                 data = f.read()
 */
  __pyx_t_1 = (__pyx_v_filename != Py_None);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":428
 *             self.hProfile = createHProfile(data, len(data), "in")
 *         elif filename is not None:
 *             with open(filename, "rb") as f:             # <<<<<<<<<<<<<<
 *                 data = f.read()
 *             self.hProfile = createHProfile(data, len(data), "in")
 */
    /*with:*/ {
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_filename);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_filename);
      __Pyx_GIVEREF(__pyx_v_filename);
      __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
      PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__rb));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rb));
      __pyx_t_7 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __pyx_t_8 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s____exit__); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s____enter__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      /*try:*/ {
        {
          __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          /*try:*/ {
            __Pyx_INCREF(__pyx_t_9);
            __pyx_v_f = __pyx_t_9;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

            /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":429
 *         elif filename is not None:
 *             with open(filename, "rb") as f:
 *                 data = f.read()             # <<<<<<<<<<<<<<
 *             self.hProfile = createHProfile(data, len(data), "in")
 * 
 */
            __pyx_t_9 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__read); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_7 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            if (!(likely(PyBytes_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_7)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
            __Pyx_DECREF(((PyObject *)__pyx_v_data));
            __pyx_v_data = ((PyObject*)__pyx_t_7);
            __pyx_t_7 = 0;
          }
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L15_try_end;
          __pyx_L8_error:;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":428
 *             self.hProfile = createHProfile(data, len(data), "in")
 *         elif filename is not None:
 *             with open(filename, "rb") as f:             # <<<<<<<<<<<<<<
 *                 data = f.read()
 *             self.hProfile = createHProfile(data, len(data), "in")
 */
          /*except:*/ {
            __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_9, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_7);
            PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_9);
            PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_t_14 = PyObject_Call(__pyx_t_8, __pyx_t_13, NULL);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __pyx_t_15 = (!__pyx_t_1);
            if (__pyx_t_15) {
              __Pyx_GIVEREF(__pyx_t_7);
              __Pyx_GIVEREF(__pyx_t_9);
              __Pyx_GIVEREF(__pyx_t_4);
              __Pyx_ErrRestore(__pyx_t_7, __pyx_t_9, __pyx_t_4);
              __pyx_t_7 = 0; __pyx_t_9 = 0; __pyx_t_4 = 0; 
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
              goto __pyx_L19;
            }
            __pyx_L19:;
            __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L9_exception_handled;
          }
          __pyx_L10_except_error:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L1_error;
          __pyx_L9_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          __pyx_L15_try_end:;
        }
      }
      /*finally:*/ {
        if (__pyx_t_8) {
          __pyx_t_12 = PyObject_Call(__pyx_t_8, __pyx_k_tuple_29, NULL);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
      }
      goto __pyx_L20;
      __pyx_L4_error:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L1_error;
      __pyx_L20:;
    }

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":430
 *             with open(filename, "rb") as f:
 *                 data = f.read()
 *             self.hProfile = createHProfile(data, len(data), "in")             # <<<<<<<<<<<<<<
 * 
 *         if self.hProfile == NULL:
 */
    __pyx_t_2 = PyBytes_AsString(((PyObject *)__pyx_v_data)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(((PyObject *)__pyx_v_data) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_3 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_data)); 
    __pyx_t_4 = ((PyObject *)__pyx_n_s__in);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_6.__pyx_n = 1;
    __pyx_t_6.mode = __pyx_t_4;
    __pyx_t_5 = __pyx_f_3smc_9freeimage_10_freeimage_createHProfile(__pyx_t_2, __pyx_t_3, &__pyx_t_6); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_self->hProfile = __pyx_t_5;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":432
 *             self.hProfile = createHProfile(data, len(data), "in")
 * 
 *         if self.hProfile == NULL:             # <<<<<<<<<<<<<<
 *             raise LCMSException("Failed to set in profile")
 *         self.info = {}
 */
  __pyx_t_15 = (__pyx_v_self->hProfile == NULL);
  if (__pyx_t_15) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":433
 * 
 *         if self.hProfile == NULL:
 *             raise LCMSException("Failed to set in profile")             # <<<<<<<<<<<<<<
 *         self.info = {}
 *         self._parse()
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__LCMSException); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_31), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_9, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L21;
  }
  __pyx_L21:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":434
 *         if self.hProfile == NULL:
 *             raise LCMSException("Failed to set in profile")
 *         self.info = {}             # <<<<<<<<<<<<<<
 *         self._parse()
 *         lcms.cmsCloseProfile(self.hProfile)
 */
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_9));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
  __Pyx_GOTREF(__pyx_v_self->info);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->info));
  __pyx_v_self->info = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":435
 *             raise LCMSException("Failed to set in profile")
 *         self.info = {}
 *         self._parse()             # <<<<<<<<<<<<<<
 *         lcms.cmsCloseProfile(self.hProfile)
 *         self.hProfile = NULL
 */
  __pyx_t_9 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_parse(__pyx_v_self); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":436
 *         self.info = {}
 *         self._parse()
 *         lcms.cmsCloseProfile(self.hProfile)             # <<<<<<<<<<<<<<
 *         self.hProfile = NULL
 * 
 */
  cmsCloseProfile(__pyx_v_self->hProfile);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":437
 *         self._parse()
 *         lcms.cmsCloseProfile(self.hProfile)
 *         self.hProfile = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_v_self->hProfile = NULL;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_f);
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_2__dealloc__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":439
 *         self.hProfile = NULL
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.hProfile != NULL:
 *             lcms.cmsCloseProfile(self.hProfile)
 */

static void __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_2__dealloc__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":440
 * 
 *     def __dealloc__(self):
 *         if self.hProfile != NULL:             # <<<<<<<<<<<<<<
 *             lcms.cmsCloseProfile(self.hProfile)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->hProfile != NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":441
 *     def __dealloc__(self):
 *         if self.hProfile != NULL:
 *             lcms.cmsCloseProfile(self.hProfile)             # <<<<<<<<<<<<<<
 * 
 *     cdef _readMLU(self, lcms.cmsTagSignature info, char * language="en", char * country=lcms.cmsNoCountry):
 */
    cmsCloseProfile(__pyx_v_self->hProfile);
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":443
 *             lcms.cmsCloseProfile(self.hProfile)
 * 
 *     cdef _readMLU(self, lcms.cmsTagSignature info, char * language="en", char * country=lcms.cmsNoCountry):             # <<<<<<<<<<<<<<
 *         cdef int read
 *         cdef lcms.const_cmsMLU * mlu
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readMLU(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self, cmsTagSignature __pyx_v_info, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readMLU *__pyx_optional_args) {
  char *__pyx_v_language = ((char *)__pyx_k__en);
  char *__pyx_v_country = __pyx_k_32;
  int __pyx_v_read;
  const cmsMLU *__pyx_v_mlu;
  wchar_t *__pyx_v_buf;
  PyObject *__pyx_v_uni = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_readMLU", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_language = __pyx_optional_args->language;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_country = __pyx_optional_args->country;
      }
    }
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":448
 *         cdef stddef.wchar_t * buf
 * 
 *         if not lcms.cmsIsTag(self.hProfile, info):             # <<<<<<<<<<<<<<
 *             return None
 *         mlu = < lcms.const_cmsMLU *> lcms.cmsReadTag(self.hProfile, info)
 */
  __pyx_t_1 = (!cmsIsTag(__pyx_v_self->hProfile, __pyx_v_info));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":449
 * 
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None             # <<<<<<<<<<<<<<
 *         mlu = < lcms.const_cmsMLU *> lcms.cmsReadTag(self.hProfile, info)
 *         if mlu is NULL:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":450
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 *         mlu = < lcms.const_cmsMLU *> lcms.cmsReadTag(self.hProfile, info)             # <<<<<<<<<<<<<<
 *         if mlu is NULL:
 *             return None
 */
  __pyx_v_mlu = ((const cmsMLU *)cmsReadTag(__pyx_v_self->hProfile, __pyx_v_info));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":451
 *             return None
 *         mlu = < lcms.const_cmsMLU *> lcms.cmsReadTag(self.hProfile, info)
 *         if mlu is NULL:             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  __pyx_t_1 = (__pyx_v_mlu == NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":452
 *         mlu = < lcms.const_cmsMLU *> lcms.cmsReadTag(self.hProfile, info)
 *         if mlu is NULL:
 *             return None             # <<<<<<<<<<<<<<
 * 
 *         read = lcms.cmsMLUgetWide(mlu, language, country, NULL, 0);
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":454
 *             return None
 * 
 *         read = lcms.cmsMLUgetWide(mlu, language, country, NULL, 0);             # <<<<<<<<<<<<<<
 *         if read == 0:
 *             return None
 */
  __pyx_v_read = cmsMLUgetWide(__pyx_v_mlu, __pyx_v_language, __pyx_v_country, NULL, 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":455
 * 
 *         read = lcms.cmsMLUgetWide(mlu, language, country, NULL, 0);
 *         if read == 0:             # <<<<<<<<<<<<<<
 *             return None
 *         buf = < stddef.wchar_t *> stdlib.malloc(read)
 */
  __pyx_t_1 = (__pyx_v_read == 0);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":456
 *         read = lcms.cmsMLUgetWide(mlu, language, country, NULL, 0);
 *         if read == 0:
 *             return None             # <<<<<<<<<<<<<<
 *         buf = < stddef.wchar_t *> stdlib.malloc(read)
 *         lcms.cmsMLUgetWide(mlu, language, country, buf, read);
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":457
 *         if read == 0:
 *             return None
 *         buf = < stddef.wchar_t *> stdlib.malloc(read)             # <<<<<<<<<<<<<<
 *         lcms.cmsMLUgetWide(mlu, language, country, buf, read);
 *         # buf contains additional \0 junk
 */
  __pyx_v_buf = ((wchar_t *)malloc(__pyx_v_read));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":458
 *             return None
 *         buf = < stddef.wchar_t *> stdlib.malloc(read)
 *         lcms.cmsMLUgetWide(mlu, language, country, buf, read);             # <<<<<<<<<<<<<<
 *         # buf contains additional \0 junk
 *         uni = smc_fi.PyUnicode_FromWideChar(buf, smc_fi.wcslen(buf))
 */
  cmsMLUgetWide(__pyx_v_mlu, __pyx_v_language, __pyx_v_country, __pyx_v_buf, __pyx_v_read);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":460
 *         lcms.cmsMLUgetWide(mlu, language, country, buf, read);
 *         # buf contains additional \0 junk
 *         uni = smc_fi.PyUnicode_FromWideChar(buf, smc_fi.wcslen(buf))             # <<<<<<<<<<<<<<
 *         stdlib.free(buf)
 *         return uni
 */
  __pyx_t_2 = PyUnicode_FromWideChar(__pyx_v_buf, wcslen(__pyx_v_buf)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_uni = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":461
 *         # buf contains additional \0 junk
 *         uni = smc_fi.PyUnicode_FromWideChar(buf, smc_fi.wcslen(buf))
 *         stdlib.free(buf)             # <<<<<<<<<<<<<<
 *         return uni
 * 
 */
  free(__pyx_v_buf);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":462
 *         uni = smc_fi.PyUnicode_FromWideChar(buf, smc_fi.wcslen(buf))
 *         stdlib.free(buf)
 *         return uni             # <<<<<<<<<<<<<<
 * 
 *     cdef _readCIEXYZ(self, lcms.cmsTagSignature info, multi=False):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_uni);
  __pyx_r = __pyx_v_uni;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._readMLU", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_uni);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":464
 *         return uni
 * 
 *     cdef _readCIEXYZ(self, lcms.cmsTagSignature info, multi=False):             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsCIEXYZ * XYZ
 *         if not lcms.cmsIsTag(self.hProfile, info):
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIEXYZ(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self, cmsTagSignature __pyx_v_info, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIEXYZ *__pyx_optional_args) {
  PyObject *__pyx_v_multi = __pyx_k_33;
  cmsCIEXYZ *__pyx_v_XYZ;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_readCIEXYZ", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_multi = __pyx_optional_args->multi;
    }
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":466
 *     cdef _readCIEXYZ(self, lcms.cmsTagSignature info, multi=False):
 *         cdef lcms.cmsCIEXYZ * XYZ
 *         if not lcms.cmsIsTag(self.hProfile, info):             # <<<<<<<<<<<<<<
 *             return None
 *         XYZ = < lcms.cmsCIEXYZ *> lcms.cmsReadTag(self.hProfile, info)
 */
  __pyx_t_1 = (!cmsIsTag(__pyx_v_self->hProfile, __pyx_v_info));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":467
 *         cdef lcms.cmsCIEXYZ * XYZ
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None             # <<<<<<<<<<<<<<
 *         XYZ = < lcms.cmsCIEXYZ *> lcms.cmsReadTag(self.hProfile, info)
 *         if XYZ is NULL:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":468
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 *         XYZ = < lcms.cmsCIEXYZ *> lcms.cmsReadTag(self.hProfile, info)             # <<<<<<<<<<<<<<
 *         if XYZ is NULL:
 *             return None
 */
  __pyx_v_XYZ = ((cmsCIEXYZ *)cmsReadTag(__pyx_v_self->hProfile, __pyx_v_info));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":469
 *             return None
 *         XYZ = < lcms.cmsCIEXYZ *> lcms.cmsReadTag(self.hProfile, info)
 *         if XYZ is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         if not multi:
 */
  __pyx_t_1 = (__pyx_v_XYZ == NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":470
 *         XYZ = < lcms.cmsCIEXYZ *> lcms.cmsReadTag(self.hProfile, info)
 *         if XYZ is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         if not multi:
 *             return xyz_py(XYZ)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":471
 *         if XYZ is NULL:
 *             return None
 *         if not multi:             # <<<<<<<<<<<<<<
 *             return xyz_py(XYZ)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_multi); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (!__pyx_t_1);
  if (__pyx_t_2) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":472
 *             return None
 *         if not multi:
 *             return xyz_py(XYZ)             # <<<<<<<<<<<<<<
 *         else:
 *             return xyz3_py(XYZ)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __pyx_f_3smc_9freeimage_10_freeimage_xyz_py(__pyx_v_XYZ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":474
 *             return xyz_py(XYZ)
 *         else:
 *             return xyz3_py(XYZ)             # <<<<<<<<<<<<<<
 * 
 *     cdef _calculateRGBPrimaries(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __pyx_f_3smc_9freeimage_10_freeimage_xyz3_py(__pyx_v_XYZ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._readCIEXYZ", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":476
 *             return xyz3_py(XYZ)
 * 
 *     cdef _calculateRGBPrimaries(self):             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsCIEXYZTRIPLE result
 *         cdef double input[3][3]
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__calculateRGBPrimaries(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self) {
  cmsCIEXYZTRIPLE __pyx_v_result;
  double __pyx_v_input[3][3];
  cmsHPROFILE __pyx_v_hXYZ;
  cmsHTRANSFORM __pyx_v_hTransform;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  double __pyx_t_2;
  double __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_calculateRGBPrimaries", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":484
 * 
 *         # double array of RGB values with max on each identitiy
 *         input[0][0], input[0][1], input[0][2] = 1., 0., 0.             # <<<<<<<<<<<<<<
 *         input[1][0], input[1][1], input[1][2] = 0., 1., 0.
 *         input[2][0], input[2][1], input[2][2] = 0., 0., 1.
 */
  __pyx_t_1 = 1.;
  __pyx_t_2 = 0.;
  __pyx_t_3 = 0.;
  ((__pyx_v_input[0])[0]) = __pyx_t_1;
  ((__pyx_v_input[0])[1]) = __pyx_t_2;
  ((__pyx_v_input[0])[2]) = __pyx_t_3;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":485
 *         # double array of RGB values with max on each identitiy
 *         input[0][0], input[0][1], input[0][2] = 1., 0., 0.
 *         input[1][0], input[1][1], input[1][2] = 0., 1., 0.             # <<<<<<<<<<<<<<
 *         input[2][0], input[2][1], input[2][2] = 0., 0., 1.
 * 
 */
  __pyx_t_3 = 0.;
  __pyx_t_2 = 1.;
  __pyx_t_1 = 0.;
  ((__pyx_v_input[1])[0]) = __pyx_t_3;
  ((__pyx_v_input[1])[1]) = __pyx_t_2;
  ((__pyx_v_input[1])[2]) = __pyx_t_1;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":486
 *         input[0][0], input[0][1], input[0][2] = 1., 0., 0.
 *         input[1][0], input[1][1], input[1][2] = 0., 1., 0.
 *         input[2][0], input[2][1], input[2][2] = 0., 0., 1.             # <<<<<<<<<<<<<<
 * 
 *         hXYZ = lcms.cmsCreateXYZProfileTHR(< lcms.cmsContext > cpython.PyThread_get_thread_ident())
 */
  __pyx_t_1 = 0.;
  __pyx_t_2 = 0.;
  __pyx_t_3 = 1.;
  ((__pyx_v_input[2])[0]) = __pyx_t_1;
  ((__pyx_v_input[2])[1]) = __pyx_t_2;
  ((__pyx_v_input[2])[2]) = __pyx_t_3;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":488
 *         input[2][0], input[2][1], input[2][2] = 0., 0., 1.
 * 
 *         hXYZ = lcms.cmsCreateXYZProfileTHR(< lcms.cmsContext > cpython.PyThread_get_thread_ident())             # <<<<<<<<<<<<<<
 *         if hXYZ == NULL:
 *             return None
 */
  __pyx_v_hXYZ = cmsCreateXYZProfileTHR(((cmsContext)PyThread_get_thread_ident()));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":489
 * 
 *         hXYZ = lcms.cmsCreateXYZProfileTHR(< lcms.cmsContext > cpython.PyThread_get_thread_ident())
 *         if hXYZ == NULL:             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  __pyx_t_4 = (__pyx_v_hXYZ == NULL);
  if (__pyx_t_4) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":490
 *         hXYZ = lcms.cmsCreateXYZProfileTHR(< lcms.cmsContext > cpython.PyThread_get_thread_ident())
 *         if hXYZ == NULL:
 *             return None             # <<<<<<<<<<<<<<
 * 
 *         # transform from our profile to XYZ using doubles for highest precision
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":497
 *                                            hXYZ, lcms.TYPE_XYZ_DBL,
 *                                            lcms.INTENT_ABSOLUTE_COLORIMETRIC,
 *                                            lcms.cmsFLAGS_NOCACHE | lcms.cmsFLAGS_NOOPTIMIZE)             # <<<<<<<<<<<<<<
 *         lcms.cmsCloseProfile(hXYZ)
 *         if hTransform == NULL:
 */
  __pyx_v_hTransform = cmsCreateTransformTHR(((cmsContext)PyThread_get_thread_ident()), __pyx_v_self->hProfile, TYPE_RGB_DBL, __pyx_v_hXYZ, TYPE_XYZ_DBL, INTENT_ABSOLUTE_COLORIMETRIC, (cmsFLAGS_NOCACHE | cmsFLAGS_NOOPTIMIZE));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":498
 *                                            lcms.INTENT_ABSOLUTE_COLORIMETRIC,
 *                                            lcms.cmsFLAGS_NOCACHE | lcms.cmsFLAGS_NOOPTIMIZE)
 *         lcms.cmsCloseProfile(hXYZ)             # <<<<<<<<<<<<<<
 *         if hTransform == NULL:
 *             return None
 */
  cmsCloseProfile(__pyx_v_hXYZ);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":499
 *                                            lcms.cmsFLAGS_NOCACHE | lcms.cmsFLAGS_NOOPTIMIZE)
 *         lcms.cmsCloseProfile(hXYZ)
 *         if hTransform == NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         lcms.cmsDoTransform(hTransform, < smc_fi.const_void_ptr > input, & result, 3)
 */
  __pyx_t_4 = (__pyx_v_hTransform == NULL);
  if (__pyx_t_4) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":500
 *         lcms.cmsCloseProfile(hXYZ)
 *         if hTransform == NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         lcms.cmsDoTransform(hTransform, < smc_fi.const_void_ptr > input, & result, 3)
 *         lcms.cmsDeleteTransform(hTransform)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":501
 *         if hTransform == NULL:
 *             return None
 *         lcms.cmsDoTransform(hTransform, < smc_fi.const_void_ptr > input, & result, 3)             # <<<<<<<<<<<<<<
 *         lcms.cmsDeleteTransform(hTransform)
 * 
 */
  cmsDoTransform(__pyx_v_hTransform, ((const void*)__pyx_v_input), (&__pyx_v_result), 3);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":502
 *             return None
 *         lcms.cmsDoTransform(hTransform, < smc_fi.const_void_ptr > input, & result, 3)
 *         lcms.cmsDeleteTransform(hTransform)             # <<<<<<<<<<<<<<
 * 
 *         return xyztrip_py(& result)
 */
  cmsDeleteTransform(__pyx_v_hTransform);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":504
 *         lcms.cmsDeleteTransform(hTransform)
 * 
 *         return xyztrip_py(& result)             # <<<<<<<<<<<<<<
 * 
 *     cdef _readCIEXYZWhitePointTemp(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __pyx_f_3smc_9freeimage_10_freeimage_xyztrip_py((&__pyx_v_result)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._calculateRGBPrimaries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":506
 *         return xyztrip_py(& result)
 * 
 *     cdef _readCIEXYZWhitePointTemp(self):             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsCIEXYZ * XYZ
 *         cdef lcms.cmsCIExyY xyY
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIEXYZWhitePointTemp(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self) {
  cmsCIEXYZ *__pyx_v_XYZ;
  cmsCIExyY __pyx_v_xyY;
  cmsFloat64Number __pyx_v_tempK;
  cmsTagSignature __pyx_v_info;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_readCIEXYZWhitePointTemp", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":510
 *         cdef lcms.cmsCIExyY xyY
 *         cdef lcms.cmsFloat64Number tempK
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigMediaWhitePointTag             # <<<<<<<<<<<<<<
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 */
  __pyx_v_info = cmsSigMediaWhitePointTag;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":511
 *         cdef lcms.cmsFloat64Number tempK
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigMediaWhitePointTag
 *         if not lcms.cmsIsTag(self.hProfile, info):             # <<<<<<<<<<<<<<
 *             return None
 *         XYZ = < lcms.cmsCIEXYZ *> lcms.cmsReadTag(self.hProfile, info)
 */
  __pyx_t_1 = (!cmsIsTag(__pyx_v_self->hProfile, __pyx_v_info));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":512
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigMediaWhitePointTag
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None             # <<<<<<<<<<<<<<
 *         XYZ = < lcms.cmsCIEXYZ *> lcms.cmsReadTag(self.hProfile, info)
 *         if XYZ is NULL or XYZ.X == 0:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":513
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 *         XYZ = < lcms.cmsCIEXYZ *> lcms.cmsReadTag(self.hProfile, info)             # <<<<<<<<<<<<<<
 *         if XYZ is NULL or XYZ.X == 0:
 *             return None
 */
  __pyx_v_XYZ = ((cmsCIEXYZ *)cmsReadTag(__pyx_v_self->hProfile, __pyx_v_info));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":514
 *             return None
 *         XYZ = < lcms.cmsCIEXYZ *> lcms.cmsReadTag(self.hProfile, info)
 *         if XYZ is NULL or XYZ.X == 0:             # <<<<<<<<<<<<<<
 *             return None
 *         lcms.cmsXYZ2xyY(& xyY, XYZ)
 */
  __pyx_t_1 = (__pyx_v_XYZ == NULL);
  if (!__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_XYZ->X == 0.0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":515
 *         XYZ = < lcms.cmsCIEXYZ *> lcms.cmsReadTag(self.hProfile, info)
 *         if XYZ is NULL or XYZ.X == 0:
 *             return None             # <<<<<<<<<<<<<<
 *         lcms.cmsXYZ2xyY(& xyY, XYZ)
 *         if not lcms.cmsTempFromWhitePoint(& tempK, & xyY):
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":516
 *         if XYZ is NULL or XYZ.X == 0:
 *             return None
 *         lcms.cmsXYZ2xyY(& xyY, XYZ)             # <<<<<<<<<<<<<<
 *         if not lcms.cmsTempFromWhitePoint(& tempK, & xyY):
 *             return None
 */
  cmsXYZ2xyY((&__pyx_v_xyY), __pyx_v_XYZ);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":517
 *             return None
 *         lcms.cmsXYZ2xyY(& xyY, XYZ)
 *         if not lcms.cmsTempFromWhitePoint(& tempK, & xyY):             # <<<<<<<<<<<<<<
 *             return None
 *         return tempK
 */
  __pyx_t_3 = (!cmsTempFromWhitePoint((&__pyx_v_tempK), (&__pyx_v_xyY)));
  if (__pyx_t_3) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":518
 *         lcms.cmsXYZ2xyY(& xyY, XYZ)
 *         if not lcms.cmsTempFromWhitePoint(& tempK, & xyY):
 *             return None             # <<<<<<<<<<<<<<
 *         return tempK
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":519
 *         if not lcms.cmsTempFromWhitePoint(& tempK, & xyY):
 *             return None
 *         return tempK             # <<<<<<<<<<<<<<
 * 
 *     cdef _readCIExyYTriple(self, lcms.cmsTagSignature info):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_tempK); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._readCIEXYZWhitePointTemp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":521
 *         return tempK
 * 
 *     cdef _readCIExyYTriple(self, lcms.cmsTagSignature info):             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsCIExyYTRIPLE * trip
 *         if not lcms.cmsIsTag(self.hProfile, info):
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIExyYTriple(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self, cmsTagSignature __pyx_v_info) {
  cmsCIExyYTRIPLE *__pyx_v_trip;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_readCIExyYTriple", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":523
 *     cdef _readCIExyYTriple(self, lcms.cmsTagSignature info):
 *         cdef lcms.cmsCIExyYTRIPLE * trip
 *         if not lcms.cmsIsTag(self.hProfile, info):             # <<<<<<<<<<<<<<
 *             return None
 *         trip = < lcms.cmsCIExyYTRIPLE *> lcms.cmsReadTag(self.hProfile, info)
 */
  __pyx_t_1 = (!cmsIsTag(__pyx_v_self->hProfile, __pyx_v_info));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":524
 *         cdef lcms.cmsCIExyYTRIPLE * trip
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None             # <<<<<<<<<<<<<<
 *         trip = < lcms.cmsCIExyYTRIPLE *> lcms.cmsReadTag(self.hProfile, info)
 *         if trip is NULL:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":525
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 *         trip = < lcms.cmsCIExyYTRIPLE *> lcms.cmsReadTag(self.hProfile, info)             # <<<<<<<<<<<<<<
 *         if trip is NULL:
 *             return None
 */
  __pyx_v_trip = ((cmsCIExyYTRIPLE *)cmsReadTag(__pyx_v_self->hProfile, __pyx_v_info));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":526
 *             return None
 *         trip = < lcms.cmsCIExyYTRIPLE *> lcms.cmsReadTag(self.hProfile, info)
 *         if trip is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         return ((trip.Red.x, trip.Red.y, trip.Red.Y),
 */
  __pyx_t_1 = (__pyx_v_trip == NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":527
 *         trip = < lcms.cmsCIExyYTRIPLE *> lcms.cmsReadTag(self.hProfile, info)
 *         if trip is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         return ((trip.Red.x, trip.Red.y, trip.Red.Y),
 *                 (trip.Green.x, trip.Green.y, trip.Green.Y),
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":528
 *         if trip is NULL:
 *             return None
 *         return ((trip.Red.x, trip.Red.y, trip.Red.Y),             # <<<<<<<<<<<<<<
 *                 (trip.Green.x, trip.Green.y, trip.Green.Y),
 *                 (trip.Blue.x, trip.Blue.y, trip.Blue.Y))
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_trip->Red.x); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_trip->Red.y); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_trip->Red.Y); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":529
 *             return None
 *         return ((trip.Red.x, trip.Red.y, trip.Red.Y),
 *                 (trip.Green.x, trip.Green.y, trip.Green.Y),             # <<<<<<<<<<<<<<
 *                 (trip.Blue.x, trip.Blue.y, trip.Blue.Y))
 * 
 */
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_trip->Green.x); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_trip->Green.y); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_trip->Green.Y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":530
 *         return ((trip.Red.x, trip.Red.y, trip.Red.Y),
 *                 (trip.Green.x, trip.Green.y, trip.Green.Y),
 *                 (trip.Blue.x, trip.Blue.y, trip.Blue.Y))             # <<<<<<<<<<<<<<
 * 
 *     cdef _readSignature(self, lcms.cmsTagSignature info):
 */
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_trip->Blue.x); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_trip->Blue.y); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_trip->Blue.Y); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
  PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_t_7));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._readCIExyYTriple", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":532
 *                 (trip.Blue.x, trip.Blue.y, trip.Blue.Y))
 * 
 *     cdef _readSignature(self, lcms.cmsTagSignature info):             # <<<<<<<<<<<<<<
 *         cdef unsigned int * sig
 *         if not lcms.cmsIsTag(self.hProfile, info):
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readSignature(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self, cmsTagSignature __pyx_v_info) {
  unsigned int *__pyx_v_sig;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_readSignature", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":534
 *     cdef _readSignature(self, lcms.cmsTagSignature info):
 *         cdef unsigned int * sig
 *         if not lcms.cmsIsTag(self.hProfile, info):             # <<<<<<<<<<<<<<
 *             return None
 *         sig = < unsigned int *> lcms.cmsReadTag(self.hProfile, info)
 */
  __pyx_t_1 = (!cmsIsTag(__pyx_v_self->hProfile, __pyx_v_info));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":535
 *         cdef unsigned int * sig
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None             # <<<<<<<<<<<<<<
 *         sig = < unsigned int *> lcms.cmsReadTag(self.hProfile, info)
 *         if sig is NULL:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":536
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 *         sig = < unsigned int *> lcms.cmsReadTag(self.hProfile, info)             # <<<<<<<<<<<<<<
 *         if sig is NULL:
 *             return None
 */
  __pyx_v_sig = ((unsigned int *)cmsReadTag(__pyx_v_self->hProfile, __pyx_v_info));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":537
 *             return None
 *         sig = < unsigned int *> lcms.cmsReadTag(self.hProfile, info)
 *         if sig is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         return int2str(sig[0])
 */
  __pyx_t_1 = (__pyx_v_sig == NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":538
 *         sig = < unsigned int *> lcms.cmsReadTag(self.hProfile, info)
 *         if sig is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         return int2str(sig[0])
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":539
 *         if sig is NULL:
 *             return None
 *         return int2str(sig[0])             # <<<<<<<<<<<<<<
 * 
 *     cdef _readICCMeasurementCond(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_3smc_9freeimage_10_freeimage_int2str((__pyx_v_sig[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._readSignature", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":541
 *         return int2str(sig[0])
 * 
 *     cdef _readICCMeasurementCond(self):             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsICCMeasurementConditions * mc
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigMeasurementTag
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readICCMeasurementCond(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self) {
  cmsICCMeasurementConditions *__pyx_v_mc;
  cmsTagSignature __pyx_v_info;
  PyObject *__pyx_v_geo = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_readICCMeasurementCond", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":543
 *     cdef _readICCMeasurementCond(self):
 *         cdef lcms.cmsICCMeasurementConditions * mc
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigMeasurementTag             # <<<<<<<<<<<<<<
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 */
  __pyx_v_info = cmsSigMeasurementTag;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":544
 *         cdef lcms.cmsICCMeasurementConditions * mc
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigMeasurementTag
 *         if not lcms.cmsIsTag(self.hProfile, info):             # <<<<<<<<<<<<<<
 *             return None
 *         mc = < lcms.cmsICCMeasurementConditions *> lcms.cmsReadTag(self.hProfile, info)
 */
  __pyx_t_1 = (!cmsIsTag(__pyx_v_self->hProfile, __pyx_v_info));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":545
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigMeasurementTag
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None             # <<<<<<<<<<<<<<
 *         mc = < lcms.cmsICCMeasurementConditions *> lcms.cmsReadTag(self.hProfile, info)
 *         if mc is NULL:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":546
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 *         mc = < lcms.cmsICCMeasurementConditions *> lcms.cmsReadTag(self.hProfile, info)             # <<<<<<<<<<<<<<
 *         if mc is NULL:
 *             return None
 */
  __pyx_v_mc = ((cmsICCMeasurementConditions *)cmsReadTag(__pyx_v_self->hProfile, __pyx_v_info));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":547
 *             return None
 *         mc = < lcms.cmsICCMeasurementConditions *> lcms.cmsReadTag(self.hProfile, info)
 *         if mc is NULL:             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  __pyx_t_1 = (__pyx_v_mc == NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":548
 *         mc = < lcms.cmsICCMeasurementConditions *> lcms.cmsReadTag(self.hProfile, info)
 *         if mc is NULL:
 *             return None             # <<<<<<<<<<<<<<
 * 
 *         if mc.Geometry == 1:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":552
 *         if mc.Geometry == 1:
 *             geo = "45/0, 0/45"
 *         elif mc.Geometry == 2:             # <<<<<<<<<<<<<<
 *             geo = "0d, d/0"
 *         else:
 */
  switch (__pyx_v_mc->Geometry) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":550
 *             return None
 * 
 *         if mc.Geometry == 1:             # <<<<<<<<<<<<<<
 *             geo = "45/0, 0/45"
 *         elif mc.Geometry == 2:
 */
    case 1:

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":551
 * 
 *         if mc.Geometry == 1:
 *             geo = "45/0, 0/45"             # <<<<<<<<<<<<<<
 *         elif mc.Geometry == 2:
 *             geo = "0d, d/0"
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
    __pyx_v_geo = ((PyObject *)__pyx_kp_s_34);
    break;

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":552
 *         if mc.Geometry == 1:
 *             geo = "45/0, 0/45"
 *         elif mc.Geometry == 2:             # <<<<<<<<<<<<<<
 *             geo = "0d, d/0"
 *         else:
 */
    case 2:

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":553
 *             geo = "45/0, 0/45"
 *         elif mc.Geometry == 2:
 *             geo = "0d, d/0"             # <<<<<<<<<<<<<<
 *         else:
 *             geo = "unknown"
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
    __pyx_v_geo = ((PyObject *)__pyx_kp_s_35);
    break;
    default:

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":555
 *             geo = "0d, d/0"
 *         else:
 *             geo = "unknown"             # <<<<<<<<<<<<<<
 * 
 *         return dict(observer=mc.Observer, backing=(mc.Backing.X, mc.Backing.Y, mc.Backing.Z),
 */
    __Pyx_INCREF(((PyObject *)__pyx_n_s__unknown));
    __pyx_v_geo = ((PyObject *)__pyx_n_s__unknown);
    break;
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":557
 *             geo = "unknown"
 * 
 *         return dict(observer=mc.Observer, backing=(mc.Backing.X, mc.Backing.Y, mc.Backing.Z),             # <<<<<<<<<<<<<<
 *                     geometry=geo, flare=mc.Flare, illuminantType=_illu_map.get(mc.IlluminantType, None))
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = __Pyx_PyInt_to_py_cmsUInt32Number(__pyx_v_mc->Observer); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__observer), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_mc->Backing.X); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_mc->Backing.Y); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_mc->Backing.Z); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__backing), ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":558
 * 
 *         return dict(observer=mc.Observer, backing=(mc.Backing.X, mc.Backing.Y, mc.Backing.Z),
 *                     geometry=geo, flare=mc.Flare, illuminantType=_illu_map.get(mc.IlluminantType, None))             # <<<<<<<<<<<<<<
 * 
 *     cdef _readICCViewingCond(self):
 */
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__geometry), __pyx_v_geo) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_mc->Flare); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__flare), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s___illu_map); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__get); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_to_py_cmsUInt32Number(__pyx_v_mc->IlluminantType); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_4, 1, Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__illuminantType), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._readICCMeasurementCond", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_geo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":560
 *                     geometry=geo, flare=mc.Flare, illuminantType=_illu_map.get(mc.IlluminantType, None))
 * 
 *     cdef _readICCViewingCond(self):             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsICCViewingConditions * vc
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigViewingConditionsTag
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readICCViewingCond(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self) {
  cmsICCViewingConditions *__pyx_v_vc;
  cmsTagSignature __pyx_v_info;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_readICCViewingCond", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":562
 *     cdef _readICCViewingCond(self):
 *         cdef lcms.cmsICCViewingConditions * vc
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigViewingConditionsTag             # <<<<<<<<<<<<<<
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 */
  __pyx_v_info = cmsSigViewingConditionsTag;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":563
 *         cdef lcms.cmsICCViewingConditions * vc
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigViewingConditionsTag
 *         if not lcms.cmsIsTag(self.hProfile, info):             # <<<<<<<<<<<<<<
 *             return None
 *         vc = < lcms.cmsICCViewingConditions *> lcms.cmsReadTag(self.hProfile, info)
 */
  __pyx_t_1 = (!cmsIsTag(__pyx_v_self->hProfile, __pyx_v_info));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":564
 *         cdef lcms.cmsTagSignature info = lcms.cmsSigViewingConditionsTag
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None             # <<<<<<<<<<<<<<
 *         vc = < lcms.cmsICCViewingConditions *> lcms.cmsReadTag(self.hProfile, info)
 *         if vc is NULL:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":565
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 *         vc = < lcms.cmsICCViewingConditions *> lcms.cmsReadTag(self.hProfile, info)             # <<<<<<<<<<<<<<
 *         if vc is NULL:
 *             return None
 */
  __pyx_v_vc = ((cmsICCViewingConditions *)cmsReadTag(__pyx_v_self->hProfile, __pyx_v_info));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":566
 *             return None
 *         vc = < lcms.cmsICCViewingConditions *> lcms.cmsReadTag(self.hProfile, info)
 *         if vc is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         return dict(illuminant=(vc.IlluminantXYZ.X, vc.IlluminantXYZ.Y, vc.IlluminantXYZ.Z),
 */
  __pyx_t_1 = (__pyx_v_vc == NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":567
 *         vc = < lcms.cmsICCViewingConditions *> lcms.cmsReadTag(self.hProfile, info)
 *         if vc is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         return dict(illuminant=(vc.IlluminantXYZ.X, vc.IlluminantXYZ.Y, vc.IlluminantXYZ.Z),
 *                     surround=(vc.SurroundXYZ.X, vc.SurroundXYZ.Y, vc.SurroundXYZ.Z),
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":568
 *         if vc is NULL:
 *             return None
 *         return dict(illuminant=(vc.IlluminantXYZ.X, vc.IlluminantXYZ.Y, vc.IlluminantXYZ.Z),             # <<<<<<<<<<<<<<
 *                     surround=(vc.SurroundXYZ.X, vc.SurroundXYZ.Y, vc.SurroundXYZ.Z),
 *                     illuminantType=_illu_map.get(vc.IlluminantType, None))
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_vc->IlluminantXYZ.X); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_vc->IlluminantXYZ.Y); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_vc->IlluminantXYZ.Z); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__illuminant), ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":569
 *             return None
 *         return dict(illuminant=(vc.IlluminantXYZ.X, vc.IlluminantXYZ.Y, vc.IlluminantXYZ.Z),
 *                     surround=(vc.SurroundXYZ.X, vc.SurroundXYZ.Y, vc.SurroundXYZ.Z),             # <<<<<<<<<<<<<<
 *                     illuminantType=_illu_map.get(vc.IlluminantType, None))
 * 
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_vc->SurroundXYZ.X); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_vc->SurroundXYZ.Y); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_vc->SurroundXYZ.Z); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_6 = 0;
  __pyx_t_5 = 0;
  __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__surround), ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":570
 *         return dict(illuminant=(vc.IlluminantXYZ.X, vc.IlluminantXYZ.Y, vc.IlluminantXYZ.Z),
 *                     surround=(vc.SurroundXYZ.X, vc.SurroundXYZ.Y, vc.SurroundXYZ.Z),
 *                     illuminantType=_illu_map.get(vc.IlluminantType, None))             # <<<<<<<<<<<<<<
 * 
 *     def _readNamedColorList(self, lcms.cmsTagSignature info):
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___illu_map); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__get); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_to_py_cmsUInt32Number(__pyx_v_vc->IlluminantType); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_5, 1, Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__illuminantType), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._readICCViewingCond", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_5_readNamedColorList(PyObject *__pyx_v_self, PyObject *__pyx_arg_info); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_5_readNamedColorList(PyObject *__pyx_v_self, PyObject *__pyx_arg_info) {
  cmsTagSignature __pyx_v_info;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_readNamedColorList (wrapper)", 0);
  assert(__pyx_arg_info); {
    __pyx_v_info = ((cmsTagSignature)PyInt_AsLong(__pyx_arg_info)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._readNamedColorList", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4_readNamedColorList(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self), ((cmsTagSignature)__pyx_v_info));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":572
 *                     illuminantType=_illu_map.get(vc.IlluminantType, None))
 * 
 *     def _readNamedColorList(self, lcms.cmsTagSignature info):             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsNAMEDCOLORLIST * ncl
 *         cdef int i, n
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4_readNamedColorList(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self, cmsTagSignature __pyx_v_info) {
  cmsNAMEDCOLORLIST *__pyx_v_ncl;
  int __pyx_v_i;
  int __pyx_v_n;
  char __pyx_v_name[cmsMAX_PATH];
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_readNamedColorList", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":577
 *         cdef char name[lcms.cmsMAX_PATH]
 * 
 *         if not lcms.cmsIsTag(self.hProfile, info):             # <<<<<<<<<<<<<<
 *             return None
 *         ncl = < lcms.cmsNAMEDCOLORLIST *> lcms.cmsReadTag(self.hProfile, info)
 */
  __pyx_t_1 = (!cmsIsTag(__pyx_v_self->hProfile, __pyx_v_info));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":578
 * 
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None             # <<<<<<<<<<<<<<
 *         ncl = < lcms.cmsNAMEDCOLORLIST *> lcms.cmsReadTag(self.hProfile, info)
 *         if ncl is NULL:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":579
 *         if not lcms.cmsIsTag(self.hProfile, info):
 *             return None
 *         ncl = < lcms.cmsNAMEDCOLORLIST *> lcms.cmsReadTag(self.hProfile, info)             # <<<<<<<<<<<<<<
 *         if ncl is NULL:
 *             return None
 */
  __pyx_v_ncl = ((cmsNAMEDCOLORLIST *)cmsReadTag(__pyx_v_self->hProfile, __pyx_v_info));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":580
 *             return None
 *         ncl = < lcms.cmsNAMEDCOLORLIST *> lcms.cmsReadTag(self.hProfile, info)
 *         if ncl is NULL:             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
  __pyx_t_1 = (__pyx_v_ncl == NULL);
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":581
 *         ncl = < lcms.cmsNAMEDCOLORLIST *> lcms.cmsReadTag(self.hProfile, info)
 *         if ncl is NULL:
 *             return None             # <<<<<<<<<<<<<<
 * 
 *         n = lcms.cmsNamedColorCount(ncl)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":583
 *             return None
 * 
 *         n = lcms.cmsNamedColorCount(ncl)             # <<<<<<<<<<<<<<
 *         result = []
 *         for i from 0 <= i < n:
 */
  __pyx_v_n = cmsNamedColorCount(__pyx_v_ncl);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":584
 * 
 *         n = lcms.cmsNamedColorCount(ncl)
 *         result = []             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < n:
 *             lcms.cmsNamedColorInfo(ncl, i, name, NULL, NULL, NULL, NULL)
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_result = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":585
 *         n = lcms.cmsNamedColorCount(ncl)
 *         result = []
 *         for i from 0 <= i < n:             # <<<<<<<<<<<<<<
 *             lcms.cmsNamedColorInfo(ncl, i, name, NULL, NULL, NULL, NULL)
 *             result.append(name)
 */
  __pyx_t_3 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":586
 *         result = []
 *         for i from 0 <= i < n:
 *             lcms.cmsNamedColorInfo(ncl, i, name, NULL, NULL, NULL, NULL)             # <<<<<<<<<<<<<<
 *             result.append(name)
 *         return result
 */
    cmsNamedColorInfo(__pyx_v_ncl, __pyx_v_i, __pyx_v_name, NULL, NULL, NULL, NULL);

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":587
 *         for i from 0 <= i < n:
 *             lcms.cmsNamedColorInfo(ncl, i, name, NULL, NULL, NULL, NULL)
 *             result.append(name)             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_t_2 = PyBytes_FromString(__pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_4 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  }

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":588
 *             lcms.cmsNamedColorInfo(ncl, i, name, NULL, NULL, NULL, NULL)
 *             result.append(name)
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cdef _parse(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._readNamedColorList", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":590
 *         return result
 * 
 *     cdef _parse(self):             # <<<<<<<<<<<<<<
 *         cdef smc_fi.tm ct
 *         cdef lcms.cmsUInt64Number attr = 0
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__parse(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self) {
  struct tm __pyx_v_ct;
  cmsUInt64Number __pyx_v_attr;
  cmsUInt8Number __pyx_v_hid[16];
  PyObject *__pyx_v_primaries = NULL;
  PyObject *__pyx_v_intent = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  cmsBool __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIEXYZ __pyx_t_16;
  Py_ssize_t __pyx_t_17;
  PyObject *(*__pyx_t_18)(PyObject *);
  cmsUInt32Number __pyx_t_19;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_parse", 0);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":592
 *     cdef _parse(self):
 *         cdef smc_fi.tm ct
 *         cdef lcms.cmsUInt64Number attr = 0             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsUInt8Number hid[16]
 * 
 */
  __pyx_v_attr = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":595
 *         cdef lcms.cmsUInt8Number hid[16]
 * 
 *         self.info["creationDate"] = None             # <<<<<<<<<<<<<<
 *         if lcms.cmsGetHeaderCreationDateTime(self.hProfile, & ct):
 *             if ct.tm_year and ct.tm_mon and ct.tm_mday:
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__creationDate), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":596
 * 
 *         self.info["creationDate"] = None
 *         if lcms.cmsGetHeaderCreationDateTime(self.hProfile, & ct):             # <<<<<<<<<<<<<<
 *             if ct.tm_year and ct.tm_mon and ct.tm_mday:
 *                 try:
 */
  __pyx_t_1 = cmsGetHeaderCreationDateTime(__pyx_v_self->hProfile, (&__pyx_v_ct));
  if (__pyx_t_1) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":597
 *         self.info["creationDate"] = None
 *         if lcms.cmsGetHeaderCreationDateTime(self.hProfile, & ct):
 *             if ct.tm_year and ct.tm_mon and ct.tm_mday:             # <<<<<<<<<<<<<<
 *                 try:
 *                     self.info["creationDate"] = datetime(1900 + ct.tm_year, ct.tm_mon, ct.tm_mday, ct.tm_hour, ct.tm_min, ct.tm_sec)
 */
    if (__pyx_v_ct.tm_year) {
      if (__pyx_v_ct.tm_mon) {
        __pyx_t_2 = __pyx_v_ct.tm_mday;
      } else {
        __pyx_t_2 = __pyx_v_ct.tm_mon;
      }
      __pyx_t_3 = __pyx_t_2;
    } else {
      __pyx_t_3 = __pyx_v_ct.tm_year;
    }
    if (__pyx_t_3) {

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":598
 *         if lcms.cmsGetHeaderCreationDateTime(self.hProfile, & ct):
 *             if ct.tm_year and ct.tm_mon and ct.tm_mday:
 *                 try:             # <<<<<<<<<<<<<<
 *                     self.info["creationDate"] = datetime(1900 + ct.tm_year, ct.tm_mon, ct.tm_mday, ct.tm_hour, ct.tm_min, ct.tm_sec)
 *                 except ValueError:
 */
      {
        __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_4);
        __Pyx_XGOTREF(__pyx_t_5);
        __Pyx_XGOTREF(__pyx_t_6);
        /*try:*/ {

          /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":599
 *             if ct.tm_year and ct.tm_mon and ct.tm_mday:
 *                 try:
 *                     self.info["creationDate"] = datetime(1900 + ct.tm_year, ct.tm_mon, ct.tm_mday, ct.tm_hour, ct.tm_min, ct.tm_sec)             # <<<<<<<<<<<<<<
 *                 except ValueError:
 *                     pass
 */
          __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__datetime); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_8 = PyInt_FromLong((1900 + __pyx_v_ct.tm_year)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_9 = PyInt_FromLong(__pyx_v_ct.tm_mon); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = PyInt_FromLong(__pyx_v_ct.tm_mday); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_11 = PyInt_FromLong(__pyx_v_ct.tm_hour); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_12 = PyInt_FromLong(__pyx_v_ct.tm_min); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_13 = PyInt_FromLong(__pyx_v_ct.tm_sec); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_14 = PyTuple_New(6); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_14);
          PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_13);
          __pyx_t_8 = 0;
          __pyx_t_9 = 0;
          __pyx_t_10 = 0;
          __pyx_t_11 = 0;
          __pyx_t_12 = 0;
          __pyx_t_13 = 0;
          __pyx_t_13 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
          if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__creationDate), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L12_try_end;
        __pyx_L5_error:;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":600
 *                 try:
 *                     self.info["creationDate"] = datetime(1900 + ct.tm_year, ct.tm_mon, ct.tm_mday, ct.tm_hour, ct.tm_min, ct.tm_sec)
 *                 except ValueError:             # <<<<<<<<<<<<<<
 *                     pass
 * 
 */
        __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
        if (__pyx_t_15) {
          PyErr_Restore(0,0,0);
          goto __pyx_L6_exception_handled;
        }
        __Pyx_XGIVEREF(__pyx_t_4);
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
        goto __pyx_L1_error;
        __pyx_L6_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_4);
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
        __pyx_L12_try_end:;
      }
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":603
 *                     pass
 * 
 *         self.info["headerFlags"] = int(lcms.cmsGetHeaderFlags(self.hProfile))             # <<<<<<<<<<<<<<
 *         self.info["headerManufacturer"] = int2str(lcms.cmsGetHeaderManufacturer(self.hProfile))
 *         self.info["headerModel"] = int2str(lcms.cmsGetHeaderModel(self.hProfile))
 */
  __pyx_t_13 = __Pyx_PyInt_to_py_cmsUInt32Number(cmsGetHeaderFlags(__pyx_v_self->hProfile)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  __pyx_t_13 = 0;
  __pyx_t_13 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__headerFlags), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":604
 * 
 *         self.info["headerFlags"] = int(lcms.cmsGetHeaderFlags(self.hProfile))
 *         self.info["headerManufacturer"] = int2str(lcms.cmsGetHeaderManufacturer(self.hProfile))             # <<<<<<<<<<<<<<
 *         self.info["headerModel"] = int2str(lcms.cmsGetHeaderModel(self.hProfile))
 *         lcms.cmsGetHeaderAttributes(self.hProfile, & attr)
 */
  __pyx_t_13 = __pyx_f_3smc_9freeimage_10_freeimage_int2str(cmsGetHeaderManufacturer(__pyx_v_self->hProfile)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__headerManufacturer), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":605
 *         self.info["headerFlags"] = int(lcms.cmsGetHeaderFlags(self.hProfile))
 *         self.info["headerManufacturer"] = int2str(lcms.cmsGetHeaderManufacturer(self.hProfile))
 *         self.info["headerModel"] = int2str(lcms.cmsGetHeaderModel(self.hProfile))             # <<<<<<<<<<<<<<
 *         lcms.cmsGetHeaderAttributes(self.hProfile, & attr)
 *         self.info["attributes"] = int(attr)
 */
  __pyx_t_13 = __pyx_f_3smc_9freeimage_10_freeimage_int2str(cmsGetHeaderModel(__pyx_v_self->hProfile)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__headerModel), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":606
 *         self.info["headerManufacturer"] = int2str(lcms.cmsGetHeaderManufacturer(self.hProfile))
 *         self.info["headerModel"] = int2str(lcms.cmsGetHeaderModel(self.hProfile))
 *         lcms.cmsGetHeaderAttributes(self.hProfile, & attr)             # <<<<<<<<<<<<<<
 *         self.info["attributes"] = int(attr)
 *         self.info["deviceClass"] = int2str(lcms.cmsGetDeviceClass(self.hProfile))
 */
  cmsGetHeaderAttributes(__pyx_v_self->hProfile, (&__pyx_v_attr));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":607
 *         self.info["headerModel"] = int2str(lcms.cmsGetHeaderModel(self.hProfile))
 *         lcms.cmsGetHeaderAttributes(self.hProfile, & attr)
 *         self.info["attributes"] = int(attr)             # <<<<<<<<<<<<<<
 *         self.info["deviceClass"] = int2str(lcms.cmsGetDeviceClass(self.hProfile))
 *         self.info["version"] = lcms.cmsGetProfileVersion(self.hProfile)
 */
  __pyx_t_13 = __Pyx_PyInt_to_py_cmsUInt64Number(__pyx_v_attr); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  __pyx_t_13 = 0;
  __pyx_t_13 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__attributes), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":608
 *         lcms.cmsGetHeaderAttributes(self.hProfile, & attr)
 *         self.info["attributes"] = int(attr)
 *         self.info["deviceClass"] = int2str(lcms.cmsGetDeviceClass(self.hProfile))             # <<<<<<<<<<<<<<
 *         self.info["version"] = lcms.cmsGetProfileVersion(self.hProfile)
 *         self.info["iccVersion"] = hex(lcms.cmsGetEncodedICCversion(self.hProfile))
 */
  __pyx_t_13 = __pyx_f_3smc_9freeimage_10_freeimage_int2str(cmsGetDeviceClass(__pyx_v_self->hProfile)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__deviceClass), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":609
 *         self.info["attributes"] = int(attr)
 *         self.info["deviceClass"] = int2str(lcms.cmsGetDeviceClass(self.hProfile))
 *         self.info["version"] = lcms.cmsGetProfileVersion(self.hProfile)             # <<<<<<<<<<<<<<
 *         self.info["iccVersion"] = hex(lcms.cmsGetEncodedICCversion(self.hProfile))
 *         lcms.cmsGetHeaderProfileID(self.hProfile, hid)
 */
  __pyx_t_13 = PyFloat_FromDouble(cmsGetProfileVersion(__pyx_v_self->hProfile)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__version), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":610
 *         self.info["deviceClass"] = int2str(lcms.cmsGetDeviceClass(self.hProfile))
 *         self.info["version"] = lcms.cmsGetProfileVersion(self.hProfile)
 *         self.info["iccVersion"] = hex(lcms.cmsGetEncodedICCversion(self.hProfile))             # <<<<<<<<<<<<<<
 *         lcms.cmsGetHeaderProfileID(self.hProfile, hid)
 *         self.info["profileid"] = cpython.PyBytes_FromStringAndSize(< char *> hid, 16)
 */
  __pyx_t_13 = __Pyx_PyInt_to_py_cmsUInt32Number(cmsGetEncodedICCversion(__pyx_v_self->hProfile)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  __pyx_t_13 = 0;
  __pyx_t_13 = PyObject_Call(__pyx_builtin_hex, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__iccVersion), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":611
 *         self.info["version"] = lcms.cmsGetProfileVersion(self.hProfile)
 *         self.info["iccVersion"] = hex(lcms.cmsGetEncodedICCversion(self.hProfile))
 *         lcms.cmsGetHeaderProfileID(self.hProfile, hid)             # <<<<<<<<<<<<<<
 *         self.info["profileid"] = cpython.PyBytes_FromStringAndSize(< char *> hid, 16)
 * 
 */
  cmsGetHeaderProfileID(__pyx_v_self->hProfile, __pyx_v_hid);

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":612
 *         self.info["iccVersion"] = hex(lcms.cmsGetEncodedICCversion(self.hProfile))
 *         lcms.cmsGetHeaderProfileID(self.hProfile, hid)
 *         self.info["profileid"] = cpython.PyBytes_FromStringAndSize(< char *> hid, 16)             # <<<<<<<<<<<<<<
 * 
 *         self.info["renderingIntent"] = int(lcms.cmsGetHeaderRenderingIntent(self.hProfile))
 */
  __pyx_t_13 = ((PyObject *)PyBytes_FromStringAndSize(((char *)__pyx_v_hid), 16)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__profileid), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":614
 *         self.info["profileid"] = cpython.PyBytes_FromStringAndSize(< char *> hid, 16)
 * 
 *         self.info["renderingIntent"] = int(lcms.cmsGetHeaderRenderingIntent(self.hProfile))             # <<<<<<<<<<<<<<
 *         self.info["connectionSpace"] = int2str(lcms.cmsGetPCS(self.hProfile))
 *         self.info["colorSpace"] = int2str(lcms.cmsGetColorSpace(self.hProfile))
 */
  __pyx_t_13 = __Pyx_PyInt_to_py_cmsUInt32Number(cmsGetHeaderRenderingIntent(__pyx_v_self->hProfile)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  __pyx_t_13 = 0;
  __pyx_t_13 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__renderingIntent), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":615
 * 
 *         self.info["renderingIntent"] = int(lcms.cmsGetHeaderRenderingIntent(self.hProfile))
 *         self.info["connectionSpace"] = int2str(lcms.cmsGetPCS(self.hProfile))             # <<<<<<<<<<<<<<
 *         self.info["colorSpace"] = int2str(lcms.cmsGetColorSpace(self.hProfile))
 * 
 */
  __pyx_t_13 = __pyx_f_3smc_9freeimage_10_freeimage_int2str(cmsGetPCS(__pyx_v_self->hProfile)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__connectionSpace), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":616
 *         self.info["renderingIntent"] = int(lcms.cmsGetHeaderRenderingIntent(self.hProfile))
 *         self.info["connectionSpace"] = int2str(lcms.cmsGetPCS(self.hProfile))
 *         self.info["colorSpace"] = int2str(lcms.cmsGetColorSpace(self.hProfile))             # <<<<<<<<<<<<<<
 * 
 *         self.info["target"] = self._readMLU(lcms.cmsSigCharTargetTag)
 */
  __pyx_t_13 = __pyx_f_3smc_9freeimage_10_freeimage_int2str(cmsGetColorSpace(__pyx_v_self->hProfile)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__colorSpace), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":618
 *         self.info["colorSpace"] = int2str(lcms.cmsGetColorSpace(self.hProfile))
 * 
 *         self.info["target"] = self._readMLU(lcms.cmsSigCharTargetTag)             # <<<<<<<<<<<<<<
 *         self.info["copyright"] = self._readMLU(lcms.cmsSigCopyrightTag)
 *         self.info["manufacturer"] = self._readMLU(lcms.cmsSigDeviceMfgDescTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readMLU(__pyx_v_self, cmsSigCharTargetTag, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__target), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":619
 * 
 *         self.info["target"] = self._readMLU(lcms.cmsSigCharTargetTag)
 *         self.info["copyright"] = self._readMLU(lcms.cmsSigCopyrightTag)             # <<<<<<<<<<<<<<
 *         self.info["manufacturer"] = self._readMLU(lcms.cmsSigDeviceMfgDescTag)
 *         self.info["model"] = self._readMLU(lcms.cmsSigDeviceModelDescTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readMLU(__pyx_v_self, cmsSigCopyrightTag, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__copyright), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":620
 *         self.info["target"] = self._readMLU(lcms.cmsSigCharTargetTag)
 *         self.info["copyright"] = self._readMLU(lcms.cmsSigCopyrightTag)
 *         self.info["manufacturer"] = self._readMLU(lcms.cmsSigDeviceMfgDescTag)             # <<<<<<<<<<<<<<
 *         self.info["model"] = self._readMLU(lcms.cmsSigDeviceModelDescTag)
 *         self.info["profileDescription"] = self._readMLU(lcms.cmsSigProfileDescriptionTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readMLU(__pyx_v_self, cmsSigDeviceMfgDescTag, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__manufacturer), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":621
 *         self.info["copyright"] = self._readMLU(lcms.cmsSigCopyrightTag)
 *         self.info["manufacturer"] = self._readMLU(lcms.cmsSigDeviceMfgDescTag)
 *         self.info["model"] = self._readMLU(lcms.cmsSigDeviceModelDescTag)             # <<<<<<<<<<<<<<
 *         self.info["profileDescription"] = self._readMLU(lcms.cmsSigProfileDescriptionTag)
 *         self.info["screeningDescription"] = self._readMLU(lcms.cmsSigScreeningDescTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readMLU(__pyx_v_self, cmsSigDeviceModelDescTag, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__model), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":622
 *         self.info["manufacturer"] = self._readMLU(lcms.cmsSigDeviceMfgDescTag)
 *         self.info["model"] = self._readMLU(lcms.cmsSigDeviceModelDescTag)
 *         self.info["profileDescription"] = self._readMLU(lcms.cmsSigProfileDescriptionTag)             # <<<<<<<<<<<<<<
 *         self.info["screeningDescription"] = self._readMLU(lcms.cmsSigScreeningDescTag)
 *         self.info["viewingCondition"] = self._readMLU(lcms.cmsSigViewingCondDescTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readMLU(__pyx_v_self, cmsSigProfileDescriptionTag, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__profileDescription), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":623
 *         self.info["model"] = self._readMLU(lcms.cmsSigDeviceModelDescTag)
 *         self.info["profileDescription"] = self._readMLU(lcms.cmsSigProfileDescriptionTag)
 *         self.info["screeningDescription"] = self._readMLU(lcms.cmsSigScreeningDescTag)             # <<<<<<<<<<<<<<
 *         self.info["viewingCondition"] = self._readMLU(lcms.cmsSigViewingCondDescTag)
 *         self.info["technology"] = self._readSignature(lcms.cmsSigTechnologyTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readMLU(__pyx_v_self, cmsSigScreeningDescTag, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s_36), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":624
 *         self.info["profileDescription"] = self._readMLU(lcms.cmsSigProfileDescriptionTag)
 *         self.info["screeningDescription"] = self._readMLU(lcms.cmsSigScreeningDescTag)
 *         self.info["viewingCondition"] = self._readMLU(lcms.cmsSigViewingCondDescTag)             # <<<<<<<<<<<<<<
 *         self.info["technology"] = self._readSignature(lcms.cmsSigTechnologyTag)
 *         self.info["colorimetricIntent"] = self._readSignature(lcms.cmsSigColorimetricIntentImageStateTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readMLU(__pyx_v_self, cmsSigViewingCondDescTag, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__viewingCondition), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":625
 *         self.info["screeningDescription"] = self._readMLU(lcms.cmsSigScreeningDescTag)
 *         self.info["viewingCondition"] = self._readMLU(lcms.cmsSigViewingCondDescTag)
 *         self.info["technology"] = self._readSignature(lcms.cmsSigTechnologyTag)             # <<<<<<<<<<<<<<
 *         self.info["colorimetricIntent"] = self._readSignature(lcms.cmsSigColorimetricIntentImageStateTag)
 *         self.info["perceptualRenderingIntentGamut"] = self._readSignature(lcms.cmsSigPerceptualRenderingIntentGamutTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readSignature(__pyx_v_self, cmsSigTechnologyTag); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__technology), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":626
 *         self.info["viewingCondition"] = self._readMLU(lcms.cmsSigViewingCondDescTag)
 *         self.info["technology"] = self._readSignature(lcms.cmsSigTechnologyTag)
 *         self.info["colorimetricIntent"] = self._readSignature(lcms.cmsSigColorimetricIntentImageStateTag)             # <<<<<<<<<<<<<<
 *         self.info["perceptualRenderingIntentGamut"] = self._readSignature(lcms.cmsSigPerceptualRenderingIntentGamutTag)
 *         self.info["saturationRenderingIntentGamut"] = self._readSignature(lcms.cmsSigSaturationRenderingIntentGamutTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readSignature(__pyx_v_self, cmsSigColorimetricIntentImageStateTag); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__colorimetricIntent), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":627
 *         self.info["technology"] = self._readSignature(lcms.cmsSigTechnologyTag)
 *         self.info["colorimetricIntent"] = self._readSignature(lcms.cmsSigColorimetricIntentImageStateTag)
 *         self.info["perceptualRenderingIntentGamut"] = self._readSignature(lcms.cmsSigPerceptualRenderingIntentGamutTag)             # <<<<<<<<<<<<<<
 *         self.info["saturationRenderingIntentGamut"] = self._readSignature(lcms.cmsSigSaturationRenderingIntentGamutTag)
 *         self.info["colorantTable"] = self._readNamedColorList(lcms.cmsSigColorantTableTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readSignature(__pyx_v_self, cmsSigPerceptualRenderingIntentGamutTag); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s_37), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":628
 *         self.info["colorimetricIntent"] = self._readSignature(lcms.cmsSigColorimetricIntentImageStateTag)
 *         self.info["perceptualRenderingIntentGamut"] = self._readSignature(lcms.cmsSigPerceptualRenderingIntentGamutTag)
 *         self.info["saturationRenderingIntentGamut"] = self._readSignature(lcms.cmsSigSaturationRenderingIntentGamutTag)             # <<<<<<<<<<<<<<
 *         self.info["colorantTable"] = self._readNamedColorList(lcms.cmsSigColorantTableTag)
 *         self.info["colorantTableOut"] = self._readNamedColorList(lcms.cmsSigColorantTableOutTag)
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readSignature(__pyx_v_self, cmsSigSaturationRenderingIntentGamutTag); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s_38), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":629
 *         self.info["perceptualRenderingIntentGamut"] = self._readSignature(lcms.cmsSigPerceptualRenderingIntentGamutTag)
 *         self.info["saturationRenderingIntentGamut"] = self._readSignature(lcms.cmsSigSaturationRenderingIntentGamutTag)
 *         self.info["colorantTable"] = self._readNamedColorList(lcms.cmsSigColorantTableTag)             # <<<<<<<<<<<<<<
 *         self.info["colorantTableOut"] = self._readNamedColorList(lcms.cmsSigColorantTableOutTag)
 * 
 */
  __pyx_t_13 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___readNamedColorList); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = PyInt_FromLong(cmsSigColorantTableTag); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_14);
  __pyx_t_14 = 0;
  __pyx_t_14 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__colorantTable), __pyx_t_14) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":630
 *         self.info["saturationRenderingIntentGamut"] = self._readSignature(lcms.cmsSigSaturationRenderingIntentGamutTag)
 *         self.info["colorantTable"] = self._readNamedColorList(lcms.cmsSigColorantTableTag)
 *         self.info["colorantTableOut"] = self._readNamedColorList(lcms.cmsSigColorantTableOutTag)             # <<<<<<<<<<<<<<
 * 
 *         self.info["isMatrixShaper"] = bool(lcms.cmsIsMatrixShaper(self.hProfile))
 */
  __pyx_t_14 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___readNamedColorList); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_7 = PyInt_FromLong(cmsSigColorantTableOutTag); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_13), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__colorantTableOut), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":632
 *         self.info["colorantTableOut"] = self._readNamedColorList(lcms.cmsSigColorantTableOutTag)
 * 
 *         self.info["isMatrixShaper"] = bool(lcms.cmsIsMatrixShaper(self.hProfile))             # <<<<<<<<<<<<<<
 * 
 *         # media points (don't trust the black point!)
 */
  __pyx_t_7 = __Pyx_PyInt_to_py_cmsBool(cmsIsMatrixShaper(__pyx_v_self->hProfile)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__isMatrixShaper), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":635
 * 
 *         # media points (don't trust the black point!)
 *         self.info["mediaWhitePoint"] = self._readCIEXYZ(lcms.cmsSigMediaWhitePointTag)             # <<<<<<<<<<<<<<
 *         self.info["mediaWhitePointTemperature"] = self._readCIEXYZWhitePointTemp()
 *         self.info["mediaBlackPoint"] = self._readCIEXYZ(lcms.cmsSigMediaBlackPointTag)
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readCIEXYZ(__pyx_v_self, cmsSigMediaWhitePointTag, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__mediaWhitePoint), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":636
 *         # media points (don't trust the black point!)
 *         self.info["mediaWhitePoint"] = self._readCIEXYZ(lcms.cmsSigMediaWhitePointTag)
 *         self.info["mediaWhitePointTemperature"] = self._readCIEXYZWhitePointTemp()             # <<<<<<<<<<<<<<
 *         self.info["mediaBlackPoint"] = self._readCIEXYZ(lcms.cmsSigMediaBlackPointTag)
 *         # colorants
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readCIEXYZWhitePointTemp(__pyx_v_self); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s_39), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":637
 *         self.info["mediaWhitePoint"] = self._readCIEXYZ(lcms.cmsSigMediaWhitePointTag)
 *         self.info["mediaWhitePointTemperature"] = self._readCIEXYZWhitePointTemp()
 *         self.info["mediaBlackPoint"] = self._readCIEXYZ(lcms.cmsSigMediaBlackPointTag)             # <<<<<<<<<<<<<<
 *         # colorants
 *         self.info["redColorant"] = None
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readCIEXYZ(__pyx_v_self, cmsSigMediaBlackPointTag, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__mediaBlackPoint), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":639
 *         self.info["mediaBlackPoint"] = self._readCIEXYZ(lcms.cmsSigMediaBlackPointTag)
 *         # colorants
 *         self.info["redColorant"] = None             # <<<<<<<<<<<<<<
 *         self.info["greenColorant"] = None
 *         self.info["blueColorant"] = None
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__redColorant), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":640
 *         # colorants
 *         self.info["redColorant"] = None
 *         self.info["greenColorant"] = None             # <<<<<<<<<<<<<<
 *         self.info["blueColorant"] = None
 *         # primaries
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__greenColorant), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":641
 *         self.info["redColorant"] = None
 *         self.info["greenColorant"] = None
 *         self.info["blueColorant"] = None             # <<<<<<<<<<<<<<
 *         # primaries
 *         self.info["redPrimary"] = None
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__blueColorant), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":643
 *         self.info["blueColorant"] = None
 *         # primaries
 *         self.info["redPrimary"] = None             # <<<<<<<<<<<<<<
 *         self.info["greenPrimary"] = None
 *         self.info["bluePrimary"] = None
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__redPrimary), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":644
 *         # primaries
 *         self.info["redPrimary"] = None
 *         self.info["greenPrimary"] = None             # <<<<<<<<<<<<<<
 *         self.info["bluePrimary"] = None
 * 
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__greenPrimary), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":645
 *         self.info["redPrimary"] = None
 *         self.info["greenPrimary"] = None
 *         self.info["bluePrimary"] = None             # <<<<<<<<<<<<<<
 * 
 *         if self.info["isMatrixShaper"]:
 */
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__bluePrimary), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":647
 *         self.info["bluePrimary"] = None
 * 
 *         if self.info["isMatrixShaper"]:             # <<<<<<<<<<<<<<
 *             # colorants
 *             self.info["redColorant"] = self._readCIEXYZ(lcms.cmsSigRedColorantTag)
 */
  __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__isMatrixShaper)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_3) {

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":649
 *         if self.info["isMatrixShaper"]:
 *             # colorants
 *             self.info["redColorant"] = self._readCIEXYZ(lcms.cmsSigRedColorantTag)             # <<<<<<<<<<<<<<
 *             self.info["greenColorant"] = self._readCIEXYZ(lcms.cmsSigGreenColorantTag)
 *             self.info["blueColorant"] = self._readCIEXYZ(lcms.cmsSigBlueColorantTag)
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readCIEXYZ(__pyx_v_self, cmsSigRedColorantTag, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__redColorant), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":650
 *             # colorants
 *             self.info["redColorant"] = self._readCIEXYZ(lcms.cmsSigRedColorantTag)
 *             self.info["greenColorant"] = self._readCIEXYZ(lcms.cmsSigGreenColorantTag)             # <<<<<<<<<<<<<<
 *             self.info["blueColorant"] = self._readCIEXYZ(lcms.cmsSigBlueColorantTag)
 *             # primaries
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readCIEXYZ(__pyx_v_self, cmsSigGreenColorantTag, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__greenColorant), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":651
 *             self.info["redColorant"] = self._readCIEXYZ(lcms.cmsSigRedColorantTag)
 *             self.info["greenColorant"] = self._readCIEXYZ(lcms.cmsSigGreenColorantTag)
 *             self.info["blueColorant"] = self._readCIEXYZ(lcms.cmsSigBlueColorantTag)             # <<<<<<<<<<<<<<
 *             # primaries
 *             primaries = self._calculateRGBPrimaries()
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readCIEXYZ(__pyx_v_self, cmsSigBlueColorantTag, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__blueColorant), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":653
 *             self.info["blueColorant"] = self._readCIEXYZ(lcms.cmsSigBlueColorantTag)
 *             # primaries
 *             primaries = self._calculateRGBPrimaries()             # <<<<<<<<<<<<<<
 *             if primaries:
 *                 self.info["redPrimary"] = primaries["red"]
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_calculateRGBPrimaries(__pyx_v_self); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_v_primaries = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":654
 *             # primaries
 *             primaries = self._calculateRGBPrimaries()
 *             if primaries:             # <<<<<<<<<<<<<<
 *                 self.info["redPrimary"] = primaries["red"]
 *                 self.info["greenPrimary"] = primaries["green"]
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_primaries); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_3) {

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":655
 *             primaries = self._calculateRGBPrimaries()
 *             if primaries:
 *                 self.info["redPrimary"] = primaries["red"]             # <<<<<<<<<<<<<<
 *                 self.info["greenPrimary"] = primaries["green"]
 *                 self.info["bluePrimary"] = primaries["blue"]
 */
      __pyx_t_7 = PyObject_GetItem(__pyx_v_primaries, ((PyObject *)__pyx_n_s__red)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__redPrimary), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":656
 *             if primaries:
 *                 self.info["redPrimary"] = primaries["red"]
 *                 self.info["greenPrimary"] = primaries["green"]             # <<<<<<<<<<<<<<
 *                 self.info["bluePrimary"] = primaries["blue"]
 * 
 */
      __pyx_t_7 = PyObject_GetItem(__pyx_v_primaries, ((PyObject *)__pyx_n_s__green)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__greenPrimary), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":657
 *                 self.info["redPrimary"] = primaries["red"]
 *                 self.info["greenPrimary"] = primaries["green"]
 *                 self.info["bluePrimary"] = primaries["blue"]             # <<<<<<<<<<<<<<
 * 
 *         # chroma / luma
 */
      __pyx_t_7 = PyObject_GetItem(__pyx_v_primaries, ((PyObject *)__pyx_n_s__blue)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__bluePrimary), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L14;
    }
    __pyx_L14:;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":660
 * 
 *         # chroma / luma
 *         self.info["luminance"] = self._readCIEXYZ(lcms.cmsSigLuminanceTag)             # <<<<<<<<<<<<<<
 *         self.info["chromaticAdaptation"] = self._readCIEXYZ(lcms.cmsSigChromaticAdaptationTag, True)
 *         self.info["chromaticity"] = self._readCIExyYTriple(lcms.cmsSigChromaticityTag)
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readCIEXYZ(__pyx_v_self, cmsSigLuminanceTag, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__luminance), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":661
 *         # chroma / luma
 *         self.info["luminance"] = self._readCIEXYZ(lcms.cmsSigLuminanceTag)
 *         self.info["chromaticAdaptation"] = self._readCIEXYZ(lcms.cmsSigChromaticAdaptationTag, True)             # <<<<<<<<<<<<<<
 *         self.info["chromaticity"] = self._readCIExyYTriple(lcms.cmsSigChromaticityTag)
 * 
 */
  __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_16.__pyx_n = 1;
  __pyx_t_16.multi = __pyx_t_7;
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readCIEXYZ(__pyx_v_self, cmsSigChromaticAdaptationTag, &__pyx_t_16); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__chromaticAdaptation), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":662
 *         self.info["luminance"] = self._readCIEXYZ(lcms.cmsSigLuminanceTag)
 *         self.info["chromaticAdaptation"] = self._readCIEXYZ(lcms.cmsSigChromaticAdaptationTag, True)
 *         self.info["chromaticity"] = self._readCIExyYTriple(lcms.cmsSigChromaticityTag)             # <<<<<<<<<<<<<<
 * 
 *         self.info["iccMeasurementCondition"] = self._readICCMeasurementCond()
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readCIExyYTriple(__pyx_v_self, cmsSigChromaticityTag); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__chromaticity), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":664
 *         self.info["chromaticity"] = self._readCIExyYTriple(lcms.cmsSigChromaticityTag)
 * 
 *         self.info["iccMeasurementCondition"] = self._readICCMeasurementCond()             # <<<<<<<<<<<<<<
 *         self.info["iccViewingCondition"] = self._readICCViewingCond()
 * 
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readICCMeasurementCond(__pyx_v_self); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s_40), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":665
 * 
 *         self.info["iccMeasurementCondition"] = self._readICCMeasurementCond()
 *         self.info["iccViewingCondition"] = self._readICCViewingCond()             # <<<<<<<<<<<<<<
 * 
 *         self.info["isIntentSupported"] = {}
 */
  __pyx_t_13 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self->__pyx_vtab)->_readICCViewingCond(__pyx_v_self); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__iccViewingCondition), __pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":667
 *         self.info["iccViewingCondition"] = self._readICCViewingCond()
 * 
 *         self.info["isIntentSupported"] = {}             # <<<<<<<<<<<<<<
 *         self.info["isCLUT"] = {}
 *         for intent in getIntents().keys():
 */
  __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_13));
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__isIntentSupported), ((PyObject *)__pyx_t_13)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":668
 * 
 *         self.info["isIntentSupported"] = {}
 *         self.info["isCLUT"] = {}             # <<<<<<<<<<<<<<
 *         for intent in getIntents().keys():
 *             self.info["isIntentSupported"][intent] = (
 */
  __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_13));
  if (PyDict_SetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__isCLUT), ((PyObject *)__pyx_t_13)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":669
 *         self.info["isIntentSupported"] = {}
 *         self.info["isCLUT"] = {}
 *         for intent in getIntents().keys():             # <<<<<<<<<<<<<<
 *             self.info["isIntentSupported"][intent] = (
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_INPUT)),
 */
  __pyx_t_13 = __Pyx_GetName(__pyx_m, __pyx_n_s__getIntents); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_7 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__keys); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  if (PyList_CheckExact(__pyx_t_7) || PyTuple_CheckExact(__pyx_t_7)) {
    __pyx_t_13 = __pyx_t_7; __Pyx_INCREF(__pyx_t_13); __pyx_t_17 = 0;
    __pyx_t_18 = NULL;
  } else {
    __pyx_t_17 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_18 = Py_TYPE(__pyx_t_13)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  for (;;) {
    if (!__pyx_t_18 && PyList_CheckExact(__pyx_t_13)) {
      if (__pyx_t_17 >= PyList_GET_SIZE(__pyx_t_13)) break;
      __pyx_t_7 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_17); __Pyx_INCREF(__pyx_t_7); __pyx_t_17++;
    } else if (!__pyx_t_18 && PyTuple_CheckExact(__pyx_t_13)) {
      if (__pyx_t_17 >= PyTuple_GET_SIZE(__pyx_t_13)) break;
      __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_17); __Pyx_INCREF(__pyx_t_7); __pyx_t_17++;
    } else {
      __pyx_t_7 = __pyx_t_18(__pyx_t_13);
      if (unlikely(!__pyx_t_7)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    __Pyx_XDECREF(__pyx_v_intent);
    __pyx_v_intent = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":671
 *         for intent in getIntents().keys():
 *             self.info["isIntentSupported"][intent] = (
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_INPUT)),             # <<<<<<<<<<<<<<
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_OUTPUT)),
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_PROOF))
 */
    __pyx_t_19 = __Pyx_PyInt_from_py_cmsUInt32Number(__pyx_v_intent); if (unlikely((__pyx_t_19 == (cmsUInt32Number)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_to_py_cmsBool(cmsIsIntentSupported(__pyx_v_self->hProfile, __pyx_t_19, LCMS_USED_AS_INPUT)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":672
 *             self.info["isIntentSupported"][intent] = (
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_INPUT)),
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_OUTPUT)),             # <<<<<<<<<<<<<<
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_PROOF))
 *                 )
 */
    __pyx_t_19 = __Pyx_PyInt_from_py_cmsUInt32Number(__pyx_v_intent); if (unlikely((__pyx_t_19 == (cmsUInt32Number)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_14 = __Pyx_PyInt_to_py_cmsBool(cmsIsIntentSupported(__pyx_v_self->hProfile, __pyx_t_19, LCMS_USED_AS_OUTPUT)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_14 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":673
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_INPUT)),
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_OUTPUT)),
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_PROOF))             # <<<<<<<<<<<<<<
 *                 )
 *             self.info["isCLUT"][intent] = (
 */
    __pyx_t_19 = __Pyx_PyInt_from_py_cmsUInt32Number(__pyx_v_intent); if (unlikely((__pyx_t_19 == (cmsUInt32Number)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __Pyx_PyInt_to_py_cmsBool(cmsIsIntentSupported(__pyx_v_self->hProfile, __pyx_t_19, LCMS_USED_AS_PROOF)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_14);
    PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_12);
    __pyx_t_7 = 0;
    __pyx_t_14 = 0;
    __pyx_t_12 = 0;

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":670
 *         self.info["isCLUT"] = {}
 *         for intent in getIntents().keys():
 *             self.info["isIntentSupported"][intent] = (             # <<<<<<<<<<<<<<
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_INPUT)),
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_OUTPUT)),
 */
    __pyx_t_12 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__isIntentSupported)); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    if (PyObject_SetItem(__pyx_t_12, __pyx_v_intent, ((PyObject *)__pyx_t_11)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":676
 *                 )
 *             self.info["isCLUT"][intent] = (
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_INPUT)),             # <<<<<<<<<<<<<<
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_OUTPUT)),
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_PROOF))
 */
    __pyx_t_19 = __Pyx_PyInt_from_py_cmsUInt32Number(__pyx_v_intent); if (unlikely((__pyx_t_19 == (cmsUInt32Number)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = __Pyx_PyInt_to_py_cmsBool(cmsIsCLUT(__pyx_v_self->hProfile, __pyx_t_19, LCMS_USED_AS_INPUT)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":677
 *             self.info["isCLUT"][intent] = (
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_INPUT)),
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_OUTPUT)),             # <<<<<<<<<<<<<<
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_PROOF))
 *                 )
 */
    __pyx_t_19 = __Pyx_PyInt_from_py_cmsUInt32Number(__pyx_v_intent); if (unlikely((__pyx_t_19 == (cmsUInt32Number)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __Pyx_PyInt_to_py_cmsBool(cmsIsCLUT(__pyx_v_self->hProfile, __pyx_t_19, LCMS_USED_AS_OUTPUT)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":678
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_INPUT)),
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_OUTPUT)),
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_PROOF))             # <<<<<<<<<<<<<<
 *                 )
 */
    __pyx_t_19 = __Pyx_PyInt_from_py_cmsUInt32Number(__pyx_v_intent); if (unlikely((__pyx_t_19 == (cmsUInt32Number)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_14 = __Pyx_PyInt_to_py_cmsBool(cmsIsCLUT(__pyx_v_self->hProfile, __pyx_t_19, LCMS_USED_AS_PROOF)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_14 = __Pyx_PyBool_FromLong((!(!__pyx_t_3))); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_14);
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_14 = 0;

    /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":675
 *                 bool(lcms.cmsIsIntentSupported(self.hProfile, intent, lcms.LCMS_USED_AS_PROOF))
 *                 )
 *             self.info["isCLUT"][intent] = (             # <<<<<<<<<<<<<<
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_INPUT)),
 *                 bool(lcms.cmsIsCLUT(self.hProfile, intent, lcms.LCMS_USED_AS_OUTPUT)),
 */
    __pyx_t_14 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_self->info), ((PyObject *)__pyx_n_s__isCLUT)); if (!__pyx_t_14) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    if (PyObject_SetItem(__pyx_t_14, __pyx_v_intent, ((PyObject *)__pyx_t_7)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo._parse", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_primaries);
  __Pyx_XDECREF(__pyx_v_intent);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":418
 * cdef class LCMSProfileInfo(object):
 *     cdef lcms.cmsHPROFILE hProfile
 *     cdef public dict info             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, bytes data=None, filename=None):
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->info));
  __pyx_r = ((PyObject *)__pyx_v_self->info);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_2__set__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self), ((PyObject *)__pyx_v_value));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_2__set__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected dict, got %.200s", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->info);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->info));
  __pyx_v_self->info = ((PyObject*)__pyx_v_value);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.LCMSProfileInfo.info.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_4__del__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_4__del__(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->info);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->info));
  __pyx_v_self->info = ((PyObject*)Py_None);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":186
 * 
 * 
 * cdef void clearError():             # <<<<<<<<<<<<<<
 *     global tls_key
 *     cdef SmcFiError *old
 */

static void __pyx_f_3smc_9freeimage_10_freeimage_clearError(void) {
  struct __pyx_t_3smc_9freeimage_10_freeimage_SmcFiError *__pyx_v_old;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("clearError", 0);

  /* "smc/freeimage/_freeimage.pyx":190
 *     cdef SmcFiError *old
 * 
 *     old = <SmcFiError*>cpython.PyThread_get_key_value(tls_key)             # <<<<<<<<<<<<<<
 *     if old != NULL:
 *         # must free() value first, it's not freed by delete_key_value()
 */
  __pyx_v_old = ((struct __pyx_t_3smc_9freeimage_10_freeimage_SmcFiError *)PyThread_get_key_value(__pyx_v_3smc_9freeimage_10_freeimage_tls_key));

  /* "smc/freeimage/_freeimage.pyx":191
 * 
 *     old = <SmcFiError*>cpython.PyThread_get_key_value(tls_key)
 *     if old != NULL:             # <<<<<<<<<<<<<<
 *         # must free() value first, it's not freed by delete_key_value()
 *         if old.msg != NULL:
 */
  __pyx_t_1 = (__pyx_v_old != NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":193
 *     if old != NULL:
 *         # must free() value first, it's not freed by delete_key_value()
 *         if old.msg != NULL:             # <<<<<<<<<<<<<<
 *             stdlib.free(old.msg)
 *         stdlib.free(old)
 */
    __pyx_t_1 = (__pyx_v_old->msg != NULL);
    if (__pyx_t_1) {

      /* "smc/freeimage/_freeimage.pyx":194
 *         # must free() value first, it's not freed by delete_key_value()
 *         if old.msg != NULL:
 *             stdlib.free(old.msg)             # <<<<<<<<<<<<<<
 *         stdlib.free(old)
 *         cpython.PyThread_delete_key_value(tls_key)
 */
      free(__pyx_v_old->msg);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "smc/freeimage/_freeimage.pyx":195
 *         if old.msg != NULL:
 *             stdlib.free(old.msg)
 *         stdlib.free(old)             # <<<<<<<<<<<<<<
 *         cpython.PyThread_delete_key_value(tls_key)
 * 
 */
    free(__pyx_v_old);

    /* "smc/freeimage/_freeimage.pyx":196
 *             stdlib.free(old.msg)
 *         stdlib.free(old)
 *         cpython.PyThread_delete_key_value(tls_key)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    PyThread_delete_key_value(__pyx_v_3smc_9freeimage_10_freeimage_tls_key);
    goto __pyx_L3;
  }
  __pyx_L3:;

  __Pyx_RefNannyFinishContext();
}

/* "smc/freeimage/_freeimage.pyx":199
 * 
 * 
 * cdef void setError(fi.FREE_IMAGE_FORMAT format, smc_fi.const_char_ptr msg):             # <<<<<<<<<<<<<<
 *     cdef SmcFiError *error
 * 
 */

static void __pyx_f_3smc_9freeimage_10_freeimage_setError(enum FREE_IMAGE_FORMAT __pyx_v_format, const char* __pyx_v_msg) {
  struct __pyx_t_3smc_9freeimage_10_freeimage_SmcFiError *__pyx_v_error;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("setError", 0);

  /* "smc/freeimage/_freeimage.pyx":203
 * 
 *     # clear error first, otherwise I can't set a new value
 *     clearError()             # <<<<<<<<<<<<<<
 * 
 *     error = <SmcFiError*>stdlib.malloc(sizeof(SmcFiError))
 */
  __pyx_f_3smc_9freeimage_10_freeimage_clearError();

  /* "smc/freeimage/_freeimage.pyx":205
 *     clearError()
 * 
 *     error = <SmcFiError*>stdlib.malloc(sizeof(SmcFiError))             # <<<<<<<<<<<<<<
 *     if error == NULL:
 *         # error but can't report it here :/
 */
  __pyx_v_error = ((struct __pyx_t_3smc_9freeimage_10_freeimage_SmcFiError *)malloc((sizeof(struct __pyx_t_3smc_9freeimage_10_freeimage_SmcFiError))));

  /* "smc/freeimage/_freeimage.pyx":206
 * 
 *     error = <SmcFiError*>stdlib.malloc(sizeof(SmcFiError))
 *     if error == NULL:             # <<<<<<<<<<<<<<
 *         # error but can't report it here :/
 *         return
 */
  __pyx_t_1 = (__pyx_v_error == NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":208
 *     if error == NULL:
 *         # error but can't report it here :/
 *         return             # <<<<<<<<<<<<<<
 * 
 *     error.msglen = string.strlen(msg)
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":210
 *         return
 * 
 *     error.msglen = string.strlen(msg)             # <<<<<<<<<<<<<<
 *     error.format = format
 *     error.msg = <char*>stdlib.malloc((error.msglen+1) * sizeof(char))
 */
  __pyx_v_error->msglen = strlen(__pyx_v_msg);

  /* "smc/freeimage/_freeimage.pyx":211
 * 
 *     error.msglen = string.strlen(msg)
 *     error.format = format             # <<<<<<<<<<<<<<
 *     error.msg = <char*>stdlib.malloc((error.msglen+1) * sizeof(char))
 *     if error.msg == NULL:
 */
  __pyx_v_error->format = __pyx_v_format;

  /* "smc/freeimage/_freeimage.pyx":212
 *     error.msglen = string.strlen(msg)
 *     error.format = format
 *     error.msg = <char*>stdlib.malloc((error.msglen+1) * sizeof(char))             # <<<<<<<<<<<<<<
 *     if error.msg == NULL:
 *         stdlib.free(error)
 */
  __pyx_v_error->msg = ((char *)malloc(((__pyx_v_error->msglen + 1) * (sizeof(char)))));

  /* "smc/freeimage/_freeimage.pyx":213
 *     error.format = format
 *     error.msg = <char*>stdlib.malloc((error.msglen+1) * sizeof(char))
 *     if error.msg == NULL:             # <<<<<<<<<<<<<<
 *         stdlib.free(error)
 *         return
 */
  __pyx_t_1 = (__pyx_v_error->msg == NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":214
 *     error.msg = <char*>stdlib.malloc((error.msglen+1) * sizeof(char))
 *     if error.msg == NULL:
 *         stdlib.free(error)             # <<<<<<<<<<<<<<
 *         return
 *     string.strncpy(error.msg, msg, error.msglen)
 */
    free(__pyx_v_error);

    /* "smc/freeimage/_freeimage.pyx":215
 *     if error.msg == NULL:
 *         stdlib.free(error)
 *         return             # <<<<<<<<<<<<<<
 *     string.strncpy(error.msg, msg, error.msglen)
 *     error.msg[error.msglen] = 0 # terminate string
 */
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":216
 *         stdlib.free(error)
 *         return
 *     string.strncpy(error.msg, msg, error.msglen)             # <<<<<<<<<<<<<<
 *     error.msg[error.msglen] = 0 # terminate string
 * 
 */
  strncpy(__pyx_v_error->msg, __pyx_v_msg, __pyx_v_error->msglen);

  /* "smc/freeimage/_freeimage.pyx":217
 *         return
 *     string.strncpy(error.msg, msg, error.msglen)
 *     error.msg[error.msglen] = 0 # terminate string             # <<<<<<<<<<<<<<
 * 
 *     cpython.PyThread_set_key_value(tls_key, <void*>error)
 */
  (__pyx_v_error->msg[__pyx_v_error->msglen]) = 0;

  /* "smc/freeimage/_freeimage.pyx":219
 *     error.msg[error.msglen] = 0 # terminate string
 * 
 *     cpython.PyThread_set_key_value(tls_key, <void*>error)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  PyThread_set_key_value(__pyx_v_3smc_9freeimage_10_freeimage_tls_key, ((void *)__pyx_v_error));

  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "smc/freeimage/_freeimage.pyx":222
 * 
 * 
 * cdef char* getError():             # <<<<<<<<<<<<<<
 *     # Returns either NULL or a malloc'ed char array
 *     # The caller is responsible to free the char*
 */

static char *__pyx_f_3smc_9freeimage_10_freeimage_getError(void) {
  char *__pyx_v_msg;
  struct __pyx_t_3smc_9freeimage_10_freeimage_SmcFiError *__pyx_v_error;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("getError", 0);

  /* "smc/freeimage/_freeimage.pyx":228
 *     cdef SmcFiError *error
 * 
 *     error = <SmcFiError*>cpython.PyThread_get_key_value(tls_key)             # <<<<<<<<<<<<<<
 * 
 *     if error == NULL:
 */
  __pyx_v_error = ((struct __pyx_t_3smc_9freeimage_10_freeimage_SmcFiError *)PyThread_get_key_value(__pyx_v_3smc_9freeimage_10_freeimage_tls_key));

  /* "smc/freeimage/_freeimage.pyx":230
 *     error = <SmcFiError*>cpython.PyThread_get_key_value(tls_key)
 * 
 *     if error == NULL:             # <<<<<<<<<<<<<<
 *         return NULL
 *     else:
 */
  __pyx_t_1 = (__pyx_v_error == NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":231
 * 
 *     if error == NULL:
 *         return NULL             # <<<<<<<<<<<<<<
 *     else:
 *         msg = error.msg
 */
    __pyx_r = NULL;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":233
 *         return NULL
 *     else:
 *         msg = error.msg             # <<<<<<<<<<<<<<
 *         error.msg = NULL
 *         clearError()
 */
    __pyx_v_msg = __pyx_v_error->msg;

    /* "smc/freeimage/_freeimage.pyx":234
 *     else:
 *         msg = error.msg
 *         error.msg = NULL             # <<<<<<<<<<<<<<
 *         clearError()
 *         return msg
 */
    __pyx_v_error->msg = NULL;

    /* "smc/freeimage/_freeimage.pyx":235
 *         msg = error.msg
 *         error.msg = NULL
 *         clearError()             # <<<<<<<<<<<<<<
 *         return msg
 * 
 */
    __pyx_f_3smc_9freeimage_10_freeimage_clearError();

    /* "smc/freeimage/_freeimage.pyx":236
 *         error.msg = NULL
 *         clearError()
 *         return msg             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_r = __pyx_v_msg;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":239
 * 
 * 
 * cdef initErrorHandler():             # <<<<<<<<<<<<<<
 *     global tls_key
 *     if tls_key != -1:
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_initErrorHandler(void) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("initErrorHandler", 0);

  /* "smc/freeimage/_freeimage.pyx":241
 * cdef initErrorHandler():
 *     global tls_key
 *     if tls_key != -1:             # <<<<<<<<<<<<<<
 *         raise RuntimeError("Already initializes")
 *     # Initialize Python's threading API first. Sorry, there is no way
 */
  __pyx_t_1 = (__pyx_v_3smc_9freeimage_10_freeimage_tls_key != -1);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":242
 *     global tls_key
 *     if tls_key != -1:
 *         raise RuntimeError("Already initializes")             # <<<<<<<<<<<<<<
 *     # Initialize Python's threading API first. Sorry, there is no way
 *     # around it.
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_42), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":245
 *     # Initialize Python's threading API first. Sorry, there is no way
 *     # around it.
 *     cpython.PyThread_init_thread()             # <<<<<<<<<<<<<<
 *     tls_key = cpython.PyThread_create_key()
 *     FreeImage_SetOutputMessage(&setError)
 */
  PyThread_init_thread();

  /* "smc/freeimage/_freeimage.pyx":246
 *     # around it.
 *     cpython.PyThread_init_thread()
 *     tls_key = cpython.PyThread_create_key()             # <<<<<<<<<<<<<<
 *     FreeImage_SetOutputMessage(&setError)
 * 
 */
  __pyx_v_3smc_9freeimage_10_freeimage_tls_key = PyThread_create_key();

  /* "smc/freeimage/_freeimage.pyx":247
 *     cpython.PyThread_init_thread()
 *     tls_key = cpython.PyThread_create_key()
 *     FreeImage_SetOutputMessage(&setError)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  FreeImage_SetOutputMessage((&__pyx_f_3smc_9freeimage_10_freeimage_setError));

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.initErrorHandler", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11dispatchFIError(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_11dispatchFIError = {__Pyx_NAMESTR("dispatchFIError"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_11dispatchFIError, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11dispatchFIError(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_args = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__cls,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dispatchFIError (wrapper)", 0);
  __pyx_self = __pyx_self;
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cls);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "dispatchFIError") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_cls = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dispatchFIError", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_AddTraceback("smc.freeimage._freeimage.dispatchFIError", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10dispatchFIError(__pyx_self, __pyx_v_cls, __pyx_v_args);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":252
 * #--- exceptions
 * 
 * def dispatchFIError(cls, *args):             # <<<<<<<<<<<<<<
 *     cdef char* err
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10dispatchFIError(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_args) {
  char *__pyx_v_err;
  PyObject *__pyx_v_fimsg = NULL;
  PyObject *__pyx_v_fimsgl = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dispatchFIError", 0);

  /* "smc/freeimage/_freeimage.pyx":256
 * 
 *     # get error message from FreeImage
 *     err = getError()             # <<<<<<<<<<<<<<
 *     if err != NULL:
 *         fimsg = unicode(err, "utf-8")
 */
  __pyx_v_err = __pyx_f_3smc_9freeimage_10_freeimage_getError();

  /* "smc/freeimage/_freeimage.pyx":257
 *     # get error message from FreeImage
 *     err = getError()
 *     if err != NULL:             # <<<<<<<<<<<<<<
 *         fimsg = unicode(err, "utf-8")
 *         stdlib.free(err)
 */
  __pyx_t_1 = (__pyx_v_err != NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":258
 *     err = getError()
 *     if err != NULL:
 *         fimsg = unicode(err, "utf-8")             # <<<<<<<<<<<<<<
 *         stdlib.free(err)
 *         err = NULL
 */
    __pyx_t_2 = PyBytes_FromString(__pyx_v_err); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_kp_s_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_v_fimsg = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "smc/freeimage/_freeimage.pyx":259
 *     if err != NULL:
 *         fimsg = unicode(err, "utf-8")
 *         stdlib.free(err)             # <<<<<<<<<<<<<<
 *         err = NULL
 *     else:
 */
    free(__pyx_v_err);

    /* "smc/freeimage/_freeimage.pyx":260
 *         fimsg = unicode(err, "utf-8")
 *         stdlib.free(err)
 *         err = NULL             # <<<<<<<<<<<<<<
 *     else:
 *         fimsg = None
 */
    __pyx_v_err = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":262
 *         err = NULL
 *     else:
 *         fimsg = None             # <<<<<<<<<<<<<<
 * 
 *     # it's a memory error if the message contains words like
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_fimsg = Py_None;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":269
 *     # 'DIB allocation failed'
 *     # 'Not enough memory'
 *     if fimsg:             # <<<<<<<<<<<<<<
 *         fimsgl = fimsg.lower()
 *         for msg in ("allocate", "allocation", "memory", "no space"):
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_fimsg); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":270
 *     # 'Not enough memory'
 *     if fimsg:
 *         fimsgl = fimsg.lower()             # <<<<<<<<<<<<<<
 *         for msg in ("allocate", "allocation", "memory", "no space"):
 *             if msg in fimsgl:
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_fimsg, __pyx_n_s__lower); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_fimsgl = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "smc/freeimage/_freeimage.pyx":271
 *     if fimsg:
 *         fimsgl = fimsg.lower()
 *         for msg in ("allocate", "allocation", "memory", "no space"):             # <<<<<<<<<<<<<<
 *             if msg in fimsgl:
 *                 # it's some kind of memory error
 */
    __pyx_t_3 = ((PyObject *)__pyx_k_tuple_44); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
      __Pyx_XDECREF(__pyx_v_msg);
      __pyx_v_msg = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "smc/freeimage/_freeimage.pyx":272
 *         fimsgl = fimsg.lower()
 *         for msg in ("allocate", "allocation", "memory", "no space"):
 *             if msg in fimsgl:             # <<<<<<<<<<<<<<
 *                 # it's some kind of memory error
 *                 return FreeImageMemoryError(*args, fimsg=fimsg)
 */
      __pyx_t_1 = ((PySequence_Contains(__pyx_v_fimsgl, __pyx_v_msg))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_1) {

        /* "smc/freeimage/_freeimage.pyx":274
 *             if msg in fimsgl:
 *                 # it's some kind of memory error
 *                 return FreeImageMemoryError(*args, fimsg=fimsg)             # <<<<<<<<<<<<<<
 * 
 *     return cls(*args, fimsg=fimsg)
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s_45); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_5));
        __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
        if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__fimsg), __pyx_v_fimsg) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __pyx_r = __pyx_t_7;
        __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L0;
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":276
 *                 return FreeImageMemoryError(*args, fimsg=fimsg)
 * 
 *     return cls(*args, fimsg=fimsg)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__fimsg), __pyx_v_fimsg) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyObject_Call(__pyx_v_cls, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("smc.freeimage._freeimage.dispatchFIError", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_fimsg);
  __Pyx_XDECREF(__pyx_v_fimsgl);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_14FreeImageError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_14FreeImageError_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_14FreeImageError_1__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_14FreeImageError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fimsg = 0;
  PyObject *__pyx_v_args = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fimsg,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_self = __pyx_self;
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    PyObject* values[2] = {0,0};

    /* "smc/freeimage/_freeimage.pyx":280
 * 
 * class FreeImageError(Exception):
 *     def __init__(self, *args, fimsg=None):             # <<<<<<<<<<<<<<
 *         if fimsg is not None:
 *             args = args + (fimsg,)
 */
    values[1] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      while (kw_args > 0) {
        PyObject* value;
        value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fimsg);
        if (value) { values[1] = value; if (!(--kw_args)) break; }
        break;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_self = values[0];
    __pyx_v_fimsg = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_AddTraceback("smc.freeimage._freeimage.FreeImageError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_14FreeImageError___init__(__pyx_self, __pyx_v_self, __pyx_v_fimsg, __pyx_v_args);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_14FreeImageError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fimsg, PyObject *__pyx_v_args) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_INCREF(__pyx_v_args);

  /* "smc/freeimage/_freeimage.pyx":281
 * class FreeImageError(Exception):
 *     def __init__(self, *args, fimsg=None):
 *         if fimsg is not None:             # <<<<<<<<<<<<<<
 *             args = args + (fimsg,)
 *         self.fimsg = fimsg
 */
  __pyx_t_1 = (__pyx_v_fimsg != Py_None);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":282
 *     def __init__(self, *args, fimsg=None):
 *         if fimsg is not None:
 *             args = args + (fimsg,)             # <<<<<<<<<<<<<<
 *         self.fimsg = fimsg
 *         super(FreeImageError, self).__init__(*args)
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_fimsg);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_fimsg);
    __Pyx_GIVEREF(__pyx_v_fimsg);
    __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_v_args), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_args));
    __pyx_v_args = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":283
 *         if fimsg is not None:
 *             args = args + (fimsg,)
 *         self.fimsg = fimsg             # <<<<<<<<<<<<<<
 *         super(FreeImageError, self).__init__(*args)
 * 
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__fimsg, __pyx_v_fimsg) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":284
 *             args = args + (fimsg,)
 *         self.fimsg = fimsg
 *         super(FreeImageError, self).__init__(*args)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__FreeImageError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____init__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FreeImageError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":362
 * 
 * 
 * cdef _DibWrapper DibWrapper(fi.FIBITMAP* dib, oldimg):             # <<<<<<<<<<<<<<
 *     """Factory to wrap a bitmap in an object
 *     """
 */

static struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(FIBITMAP *__pyx_v_dib, PyObject *__pyx_v_oldimg) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *__pyx_v_dw = 0;
  struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("DibWrapper", 0);

  /* "smc/freeimage/_freeimage.pyx":366
 *     """
 *     cdef _DibWrapper dw
 *     dw = _DibWrapper()             # <<<<<<<<<<<<<<
 *     dw.dib = dib
 *     dw.oldimg = oldimg
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage__DibWrapper)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_dw = ((struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":367
 *     cdef _DibWrapper dw
 *     dw = _DibWrapper()
 *     dw.dib = dib             # <<<<<<<<<<<<<<
 *     dw.oldimg = oldimg
 *     return dw
 */
  __pyx_v_dw->dib = __pyx_v_dib;

  /* "smc/freeimage/_freeimage.pyx":368
 *     dw = _DibWrapper()
 *     dw.dib = dib
 *     dw.oldimg = oldimg             # <<<<<<<<<<<<<<
 *     return dw
 * 
 */
  if (!(likely(((__pyx_v_oldimg) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_oldimg, __pyx_ptype_3smc_9freeimage_10_freeimage_Image))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_oldimg);
  __Pyx_GIVEREF(__pyx_v_oldimg);
  __Pyx_GOTREF(__pyx_v_dw->oldimg);
  __Pyx_DECREF(((PyObject *)__pyx_v_dw->oldimg));
  __pyx_v_dw->oldimg = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_oldimg);

  /* "smc/freeimage/_freeimage.pyx":369
 *     dw.dib = dib
 *     dw.oldimg = oldimg
 *     return dw             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_dw));
  __pyx_r = __pyx_v_dw;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.DibWrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_dw);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_1__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_1__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo___repr__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":387
 *     cdef readonly fi.DWORD colors_important
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return ("<BitmapInfo size=%lu, width=%ld, height=%ld, planes=%d,"
 *         " bit_count=%d, compression=%lu, size_image=%lu, xppm=%d,"
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo___repr__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "smc/freeimage/_freeimage.pyx":388
 * 
 *     def __repr__(self):
 *         return ("<BitmapInfo size=%lu, width=%ld, height=%ld, planes=%d,"             # <<<<<<<<<<<<<<
 *         " bit_count=%d, compression=%lu, size_image=%lu, xppm=%d,"
 *         " yppm=%d, colors_used=%lu, colors_important=%lu>" % (
 */
  __Pyx_XDECREF(__pyx_r);

  /* "smc/freeimage/_freeimage.pyx":391
 *         " bit_count=%d, compression=%lu, size_image=%lu, xppm=%d,"
 *         " yppm=%d, colors_used=%lu, colors_important=%lu>" % (
 *         self.size, self.width, self.height, self.planes, self.bit_count,             # <<<<<<<<<<<<<<
 *         self.compression, self.size_image, self.xppm, self.yppm,
 *         self.colors_used, self.colors_important
 */
  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->width); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->height); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_to_py_uint16_t(__pyx_v_self->planes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_to_py_uint16_t(__pyx_v_self->bit_count); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "smc/freeimage/_freeimage.pyx":392
 *         " yppm=%d, colors_used=%lu, colors_important=%lu>" % (
 *         self.size, self.width, self.height, self.planes, self.bit_count,
 *         self.compression, self.size_image, self.xppm, self.yppm,             # <<<<<<<<<<<<<<
 *         self.colors_used, self.colors_important
 *     ))
 */
  __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->compression); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->size_image); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->xppm); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->yppm); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);

  /* "smc/freeimage/_freeimage.pyx":393
 *         self.size, self.width, self.height, self.planes, self.bit_count,
 *         self.compression, self.size_image, self.xppm, self.yppm,
 *         self.colors_used, self.colors_important             # <<<<<<<<<<<<<<
 *     ))
 * 
 */
  __pyx_t_10 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->colors_used); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->colors_important); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = PyTuple_New(11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_12, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_12, 5, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_12, 6, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_12, 7, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_12, 8, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_12, 9, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_12, 10, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;
  __pyx_t_10 = 0;
  __pyx_t_11 = 0;
  __pyx_t_11 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), ((PyObject *)__pyx_t_12)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_11));
  __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
  __pyx_r = ((PyObject *)__pyx_t_11);
  __pyx_t_11 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_4size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_4size___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":375
 *     """Wrapper for bitmap info header
 *     """
 *     cdef readonly fi.DWORD size             # <<<<<<<<<<<<<<
 *     cdef readonly fi.LONG  width
 *     cdef readonly fi.LONG  height
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_4size___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_5width_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_5width_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_5width___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":376
 *     """
 *     cdef readonly fi.DWORD size
 *     cdef readonly fi.LONG  width             # <<<<<<<<<<<<<<
 *     cdef readonly fi.LONG  height
 *     cdef readonly fi.WORD  planes
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_5width___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.width.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_6height_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_6height_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_6height___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":377
 *     cdef readonly fi.DWORD size
 *     cdef readonly fi.LONG  width
 *     cdef readonly fi.LONG  height             # <<<<<<<<<<<<<<
 *     cdef readonly fi.WORD  planes
 *     cdef readonly fi.WORD  bit_count
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_6height___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.height.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_6planes_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_6planes_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_6planes___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":378
 *     cdef readonly fi.LONG  width
 *     cdef readonly fi.LONG  height
 *     cdef readonly fi.WORD  planes             # <<<<<<<<<<<<<<
 *     cdef readonly fi.WORD  bit_count
 *     cdef readonly fi.DWORD compression
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_6planes___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint16_t(__pyx_v_self->planes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.planes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_9bit_count_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_9bit_count_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_9bit_count___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":379
 *     cdef readonly fi.LONG  height
 *     cdef readonly fi.WORD  planes
 *     cdef readonly fi.WORD  bit_count             # <<<<<<<<<<<<<<
 *     cdef readonly fi.DWORD compression
 *     cdef readonly fi.DWORD size_image
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_9bit_count___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint16_t(__pyx_v_self->bit_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.bit_count.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_11compression_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_11compression_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_11compression___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":380
 *     cdef readonly fi.WORD  planes
 *     cdef readonly fi.WORD  bit_count
 *     cdef readonly fi.DWORD compression             # <<<<<<<<<<<<<<
 *     cdef readonly fi.DWORD size_image
 *     cdef readonly fi.LONG  xppm
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_11compression___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->compression); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.compression.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_10size_image_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_10size_image_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_10size_image___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":381
 *     cdef readonly fi.WORD  bit_count
 *     cdef readonly fi.DWORD compression
 *     cdef readonly fi.DWORD size_image             # <<<<<<<<<<<<<<
 *     cdef readonly fi.LONG  xppm
 *     cdef readonly fi.LONG  yppm
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_10size_image___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->size_image); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.size_image.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_4xppm_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_4xppm_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_4xppm___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":382
 *     cdef readonly fi.DWORD compression
 *     cdef readonly fi.DWORD size_image
 *     cdef readonly fi.LONG  xppm             # <<<<<<<<<<<<<<
 *     cdef readonly fi.LONG  yppm
 *     cdef readonly fi.DWORD colors_used
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_4xppm___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->xppm); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.xppm.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_4yppm_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_4yppm_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_4yppm___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":383
 *     cdef readonly fi.DWORD size_image
 *     cdef readonly fi.LONG  xppm
 *     cdef readonly fi.LONG  yppm             # <<<<<<<<<<<<<<
 *     cdef readonly fi.DWORD colors_used
 *     cdef readonly fi.DWORD colors_important
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_4yppm___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->yppm); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.yppm.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_11colors_used_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_11colors_used_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_11colors_used___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":384
 *     cdef readonly fi.LONG  xppm
 *     cdef readonly fi.LONG  yppm
 *     cdef readonly fi.DWORD colors_used             # <<<<<<<<<<<<<<
 *     cdef readonly fi.DWORD colors_important
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_11colors_used___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->colors_used); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.colors_used.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_16colors_important_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_16colors_important_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_16colors_important___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":385
 *     cdef readonly fi.LONG  yppm
 *     cdef readonly fi.DWORD colors_used
 *     cdef readonly fi.DWORD colors_important             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_11_BitmapInfo_16colors_important___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->colors_important); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._BitmapInfo.colors_important.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":397
 * 
 * 
 * cdef _BitmapInfo BitmapInfo(fi.BITMAPINFOHEADER *header):             # <<<<<<<<<<<<<<
 *     """Factory to wrap a bitmap info header
 *     """
 */

static struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_f_3smc_9freeimage_10_freeimage_BitmapInfo(BITMAPINFOHEADER *__pyx_v_header) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_v_bi = 0;
  struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("BitmapInfo", 0);

  /* "smc/freeimage/_freeimage.pyx":401
 *     """
 *     cdef _BitmapInfo bi
 *     bi = _BitmapInfo()             # <<<<<<<<<<<<<<
 *     bi.size = header.biSize
 *     bi.width = header.biWidth
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage__BitmapInfo)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bi = ((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":402
 *     cdef _BitmapInfo bi
 *     bi = _BitmapInfo()
 *     bi.size = header.biSize             # <<<<<<<<<<<<<<
 *     bi.width = header.biWidth
 *     bi.height = header.biHeight
 */
  __pyx_v_bi->size = __pyx_v_header->biSize;

  /* "smc/freeimage/_freeimage.pyx":403
 *     bi = _BitmapInfo()
 *     bi.size = header.biSize
 *     bi.width = header.biWidth             # <<<<<<<<<<<<<<
 *     bi.height = header.biHeight
 *     bi.planes = header.biPlanes
 */
  __pyx_v_bi->width = __pyx_v_header->biWidth;

  /* "smc/freeimage/_freeimage.pyx":404
 *     bi.size = header.biSize
 *     bi.width = header.biWidth
 *     bi.height = header.biHeight             # <<<<<<<<<<<<<<
 *     bi.planes = header.biPlanes
 *     bi.bit_count = header.biBitCount
 */
  __pyx_v_bi->height = __pyx_v_header->biHeight;

  /* "smc/freeimage/_freeimage.pyx":405
 *     bi.width = header.biWidth
 *     bi.height = header.biHeight
 *     bi.planes = header.biPlanes             # <<<<<<<<<<<<<<
 *     bi.bit_count = header.biBitCount
 *     bi.compression = header.biCompression
 */
  __pyx_v_bi->planes = __pyx_v_header->biPlanes;

  /* "smc/freeimage/_freeimage.pyx":406
 *     bi.height = header.biHeight
 *     bi.planes = header.biPlanes
 *     bi.bit_count = header.biBitCount             # <<<<<<<<<<<<<<
 *     bi.compression = header.biCompression
 *     bi.size_image = header.biSizeImage
 */
  __pyx_v_bi->bit_count = __pyx_v_header->biBitCount;

  /* "smc/freeimage/_freeimage.pyx":407
 *     bi.planes = header.biPlanes
 *     bi.bit_count = header.biBitCount
 *     bi.compression = header.biCompression             # <<<<<<<<<<<<<<
 *     bi.size_image = header.biSizeImage
 *     bi.xppm = header.biXPelsPerMeter
 */
  __pyx_v_bi->compression = __pyx_v_header->biCompression;

  /* "smc/freeimage/_freeimage.pyx":408
 *     bi.bit_count = header.biBitCount
 *     bi.compression = header.biCompression
 *     bi.size_image = header.biSizeImage             # <<<<<<<<<<<<<<
 *     bi.xppm = header.biXPelsPerMeter
 *     bi.yppm = header.biYPelsPerMeter
 */
  __pyx_v_bi->size_image = __pyx_v_header->biSizeImage;

  /* "smc/freeimage/_freeimage.pyx":409
 *     bi.compression = header.biCompression
 *     bi.size_image = header.biSizeImage
 *     bi.xppm = header.biXPelsPerMeter             # <<<<<<<<<<<<<<
 *     bi.yppm = header.biYPelsPerMeter
 *     bi.colors_used = header.biClrUsed
 */
  __pyx_v_bi->xppm = __pyx_v_header->biXPelsPerMeter;

  /* "smc/freeimage/_freeimage.pyx":410
 *     bi.size_image = header.biSizeImage
 *     bi.xppm = header.biXPelsPerMeter
 *     bi.yppm = header.biYPelsPerMeter             # <<<<<<<<<<<<<<
 *     bi.colors_used = header.biClrUsed
 *     bi.colors_important = header.biClrImportant
 */
  __pyx_v_bi->yppm = __pyx_v_header->biYPelsPerMeter;

  /* "smc/freeimage/_freeimage.pyx":411
 *     bi.xppm = header.biXPelsPerMeter
 *     bi.yppm = header.biYPelsPerMeter
 *     bi.colors_used = header.biClrUsed             # <<<<<<<<<<<<<<
 *     bi.colors_important = header.biClrImportant
 *     return bi
 */
  __pyx_v_bi->colors_used = __pyx_v_header->biClrUsed;

  /* "smc/freeimage/_freeimage.pyx":412
 *     bi.yppm = header.biYPelsPerMeter
 *     bi.colors_used = header.biClrUsed
 *     bi.colors_important = header.biClrImportant             # <<<<<<<<<<<<<<
 *     return bi
 * 
 */
  __pyx_v_bi->colors_important = __pyx_v_header->biClrImportant;

  /* "smc/freeimage/_freeimage.pyx":413
 *     bi.colors_used = header.biClrUsed
 *     bi.colors_important = header.biClrImportant
 *     return bi             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_bi));
  __pyx_r = __pyx_v_bi;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.BitmapInfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_bi);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_img = 0;
  int __pyx_v_format;
  int __pyx_v_flags;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__img,&__pyx_n_s__format,&__pyx_n_s__flags,0};
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__img);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[1]) {
      } else {
        __pyx_v_format = ((int)-1);
      }
      if (values[2]) {
      } else {
        __pyx_v_flags = ((int)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_img = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)values[0]);
    if (values[1]) {
      __pyx_v_format = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_format == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_format = ((int)-1);
    }
    if (values[2]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_img), __pyx_ptype_3smc_9freeimage_10_freeimage_Image, 0, "img", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO___init__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)__pyx_v_self), __pyx_v_img, __pyx_v_format, __pyx_v_flags);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":444
 *     cdef Image _img
 * 
 *     def __init__(self, Image img not None, int format=-1, int flags=0):             # <<<<<<<<<<<<<<
 *         cdef fi.FIMEMORY *mem = NULL
 *         self._mem = NULL
 */

static int __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_img, int __pyx_v_format, int __pyx_v_flags) {
  struct FIMEMORY *__pyx_v_mem;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "smc/freeimage/_freeimage.pyx":445
 * 
 *     def __init__(self, Image img not None, int format=-1, int flags=0):
 *         cdef fi.FIMEMORY *mem = NULL             # <<<<<<<<<<<<<<
 *         self._mem = NULL
 * 
 */
  __pyx_v_mem = NULL;

  /* "smc/freeimage/_freeimage.pyx":446
 *     def __init__(self, Image img not None, int format=-1, int flags=0):
 *         cdef fi.FIMEMORY *mem = NULL
 *         self._mem = NULL             # <<<<<<<<<<<<<<
 * 
 *         if img._dib == NULL:
 */
  __pyx_v_self->_mem = NULL;

  /* "smc/freeimage/_freeimage.pyx":448
 *         self._mem = NULL
 * 
 *         if img._dib == NULL:             # <<<<<<<<<<<<<<
 *             raise IOError("Operation on closed image")
 *         if format == fi.FIF_UNKNOWN:
 */
  __pyx_t_1 = (__pyx_v_img->_dib == NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":449
 * 
 *         if img._dib == NULL:
 *             raise IOError("Operation on closed image")             # <<<<<<<<<<<<<<
 *         if format == fi.FIF_UNKNOWN:
 *             self._format = img._format
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_48), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":450
 *         if img._dib == NULL:
 *             raise IOError("Operation on closed image")
 *         if format == fi.FIF_UNKNOWN:             # <<<<<<<<<<<<<<
 *             self._format = img._format
 *             # sensible default
 */
  __pyx_t_1 = (__pyx_v_format == FIF_UNKNOWN);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":451
 *             raise IOError("Operation on closed image")
 *         if format == fi.FIF_UNKNOWN:
 *             self._format = img._format             # <<<<<<<<<<<<<<
 *             # sensible default
 *             if self._format == fi.FIF_ICO:
 */
    __pyx_v_self->_format = __pyx_v_img->_format;

    /* "smc/freeimage/_freeimage.pyx":453
 *             self._format = img._format
 *             # sensible default
 *             if self._format == fi.FIF_ICO:             # <<<<<<<<<<<<<<
 *                 self._format = fi.FIF_PNG
 *         else:
 */
    __pyx_t_1 = (__pyx_v_self->_format == FIF_ICO);
    if (__pyx_t_1) {

      /* "smc/freeimage/_freeimage.pyx":454
 *             # sensible default
 *             if self._format == fi.FIF_ICO:
 *                 self._format = fi.FIF_PNG             # <<<<<<<<<<<<<<
 *         else:
 *             self._format = <fi.FREE_IMAGE_FORMAT>format
 */
      __pyx_v_self->_format = FIF_PNG;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":456
 *                 self._format = fi.FIF_PNG
 *         else:
 *             self._format = <fi.FREE_IMAGE_FORMAT>format             # <<<<<<<<<<<<<<
 * 
 *         if self._format < 0 or self._format > fi.FreeImage_GetFIFCount():
 */
    __pyx_v_self->_format = ((enum FREE_IMAGE_FORMAT)__pyx_v_format);
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":458
 *             self._format = <fi.FREE_IMAGE_FORMAT>format
 * 
 *         if self._format < 0 or self._format > fi.FreeImage_GetFIFCount():             # <<<<<<<<<<<<<<
 *             raise ValueError("Invalid image format")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_format < 0);
  if (!__pyx_t_1) {
    __pyx_t_3 = (__pyx_v_self->_format > FreeImage_GetFIFCount());
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_1;
  }
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":459
 * 
 *         if self._format < 0 or self._format > fi.FreeImage_GetFIFCount():
 *             raise ValueError("Invalid image format")             # <<<<<<<<<<<<<<
 * 
 *         mem = fi.FreeImage_OpenMemory(NULL, 0)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_50), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":461
 *             raise ValueError("Invalid image format")
 * 
 *         mem = fi.FreeImage_OpenMemory(NULL, 0)             # <<<<<<<<<<<<<<
 *         if mem == NULL:
 *             raise dispatchFIError(FreeImageMemoryError, "fi.FreeImage_OpenMemory() has failed")
 */
  __pyx_v_mem = FreeImage_OpenMemory(NULL, 0);

  /* "smc/freeimage/_freeimage.pyx":462
 * 
 *         mem = fi.FreeImage_OpenMemory(NULL, 0)
 *         if mem == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(FreeImageMemoryError, "fi.FreeImage_OpenMemory() has failed")
 * 
 */
  __pyx_t_4 = (__pyx_v_mem == NULL);
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":463
 *         mem = fi.FreeImage_OpenMemory(NULL, 0)
 *         if mem == NULL:
 *             raise dispatchFIError(FreeImageMemoryError, "fi.FreeImage_OpenMemory() has failed")             # <<<<<<<<<<<<<<
 * 
 *         if not fi.FreeImage_SaveToMemory(self._format, img._dib, mem, flags):
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s_45); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_51));
    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_kp_s_51));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_51));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "smc/freeimage/_freeimage.pyx":465
 *             raise dispatchFIError(FreeImageMemoryError, "fi.FreeImage_OpenMemory() has failed")
 * 
 *         if not fi.FreeImage_SaveToMemory(self._format, img._dib, mem, flags):             # <<<<<<<<<<<<<<
 *             fi.FreeImage_CloseMemory(mem)
 *             mem = NULL
 */
  __pyx_t_4 = (!FreeImage_SaveToMemory(__pyx_v_self->_format, __pyx_v_img->_dib, __pyx_v_mem, __pyx_v_flags));
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":466
 * 
 *         if not fi.FreeImage_SaveToMemory(self._format, img._dib, mem, flags):
 *             fi.FreeImage_CloseMemory(mem)             # <<<<<<<<<<<<<<
 *             mem = NULL
 *             raise dispatchFIError(OperationError, "Can't save image to memory")
 */
    FreeImage_CloseMemory(__pyx_v_mem);

    /* "smc/freeimage/_freeimage.pyx":467
 *         if not fi.FreeImage_SaveToMemory(self._format, img._dib, mem, flags):
 *             fi.FreeImage_CloseMemory(mem)
 *             mem = NULL             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Can't save image to memory")
 * 
 */
    __pyx_v_mem = NULL;

    /* "smc/freeimage/_freeimage.pyx":468
 *             fi.FreeImage_CloseMemory(mem)
 *             mem = NULL
 *             raise dispatchFIError(OperationError, "Can't save image to memory")             # <<<<<<<<<<<<<<
 * 
 *         fi.FreeImage_SeekMemory(mem, 0, stdio.SEEK_END)
 */
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_52));
    PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_kp_s_52));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_52));
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "smc/freeimage/_freeimage.pyx":470
 *             raise dispatchFIError(OperationError, "Can't save image to memory")
 * 
 *         fi.FreeImage_SeekMemory(mem, 0, stdio.SEEK_END)             # <<<<<<<<<<<<<<
 *         self.size = fi.FreeImage_TellMemory(mem)
 *         fi.FreeImage_SeekMemory(mem, 0, stdio.SEEK_SET)
 */
  FreeImage_SeekMemory(__pyx_v_mem, 0, SEEK_END);

  /* "smc/freeimage/_freeimage.pyx":471
 * 
 *         fi.FreeImage_SeekMemory(mem, 0, stdio.SEEK_END)
 *         self.size = fi.FreeImage_TellMemory(mem)             # <<<<<<<<<<<<<<
 *         fi.FreeImage_SeekMemory(mem, 0, stdio.SEEK_SET)
 *         self._mem = mem
 */
  __pyx_v_self->size = FreeImage_TellMemory(__pyx_v_mem);

  /* "smc/freeimage/_freeimage.pyx":472
 *         fi.FreeImage_SeekMemory(mem, 0, stdio.SEEK_END)
 *         self.size = fi.FreeImage_TellMemory(mem)
 *         fi.FreeImage_SeekMemory(mem, 0, stdio.SEEK_SET)             # <<<<<<<<<<<<<<
 *         self._mem = mem
 * 
 */
  FreeImage_SeekMemory(__pyx_v_mem, 0, SEEK_SET);

  /* "smc/freeimage/_freeimage.pyx":473
 *         self.size = fi.FreeImage_TellMemory(mem)
 *         fi.FreeImage_SeekMemory(mem, 0, stdio.SEEK_SET)
 *         self._mem = mem             # <<<<<<<<<<<<<<
 * 
 *         # keep a reference to the image and increase the buffer counter
 */
  __pyx_v_self->_mem = __pyx_v_mem;

  /* "smc/freeimage/_freeimage.pyx":478
 *         # This avoid images from being closed while a buffer still points to
 *         # its data.
 *         self._img = img             # <<<<<<<<<<<<<<
 *         self._img.buffers += 1
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_img));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_img));
  __Pyx_GOTREF(__pyx_v_self->_img);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_img));
  __pyx_v_self->_img = __pyx_v_img;

  /* "smc/freeimage/_freeimage.pyx":479
 *         # its data.
 *         self._img = img
 *         self._img.buffers += 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_img));
  __pyx_t_7 = __pyx_v_self->_img;
  __pyx_t_7->buffers = (__pyx_t_7->buffers + 1);
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(((PyObject *)__pyx_t_7));
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_2__dealloc__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "smc/freeimage/_freeimage.pyx":482
 * 
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._mem != NULL:
 *             fi.FreeImage_CloseMemory(self._mem)
 */

static void __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_2__dealloc__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "smc/freeimage/_freeimage.pyx":483
 * 
 *     def __dealloc__(self):
 *         if self._mem != NULL:             # <<<<<<<<<<<<<<
 *             fi.FreeImage_CloseMemory(self._mem)
 *         self._mem = NULL
 */
  __pyx_t_1 = (__pyx_v_self->_mem != NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":484
 *     def __dealloc__(self):
 *         if self._mem != NULL:
 *             fi.FreeImage_CloseMemory(self._mem)             # <<<<<<<<<<<<<<
 *         self._mem = NULL
 *         self._img.buffers -= 1
 */
    FreeImage_CloseMemory(__pyx_v_self->_mem);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":485
 *         if self._mem != NULL:
 *             fi.FreeImage_CloseMemory(self._mem)
 *         self._mem = NULL             # <<<<<<<<<<<<<<
 *         self._img.buffers -= 1
 * 
 */
  __pyx_v_self->_mem = NULL;

  /* "smc/freeimage/_freeimage.pyx":486
 *             fi.FreeImage_CloseMemory(self._mem)
 *         self._mem = NULL
 *         self._img.buffers -= 1             # <<<<<<<<<<<<<<
 * 
 *     def __getreadbuffer__(self, int index, void **ptr):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_img));
  __pyx_t_2 = __pyx_v_self->_img;
  __pyx_t_2->buffers = (__pyx_t_2->buffers - 1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
#if PY_MAJOR_VERSION < 3
static Py_ssize_t __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_5__getreadbuffer__(PyObject *__pyx_v_self, Py_ssize_t __pyx_arg_index, void **__pyx_v_ptr); /*proto*/
static Py_ssize_t __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_5__getreadbuffer__(PyObject *__pyx_v_self, Py_ssize_t __pyx_arg_index, void **__pyx_v_ptr) {
  int __pyx_v_index;
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getreadbuffer__ (wrapper)", 0);
  __pyx_v_index = __pyx_arg_index;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_4__getreadbuffer__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)__pyx_v_self), ((int)__pyx_v_index), ((void **)__pyx_v_ptr));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* "smc/freeimage/_freeimage.pyx":488
 *         self._img.buffers -= 1
 * 
 *     def __getreadbuffer__(self, int index, void **ptr):             # <<<<<<<<<<<<<<
 *         cdef fi.DWORD size
 *         if index != 0:
 */

#if PY_MAJOR_VERSION < 3
static Py_ssize_t __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_4__getreadbuffer__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self, int __pyx_v_index, void **__pyx_v_ptr) {
  DWORD __pyx_v_size;
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getreadbuffer__", 0);

  /* "smc/freeimage/_freeimage.pyx":490
 *     def __getreadbuffer__(self, int index, void **ptr):
 *         cdef fi.DWORD size
 *         if index != 0:             # <<<<<<<<<<<<<<
 *             raise SystemError("accessing non-existent string segment")
 *         fi.FreeImage_AcquireMemory(self._mem, <fi.BYTE**>ptr, &size)
 */
  __pyx_t_1 = (__pyx_v_index != 0);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":491
 *         cdef fi.DWORD size
 *         if index != 0:
 *             raise SystemError("accessing non-existent string segment")             # <<<<<<<<<<<<<<
 *         fi.FreeImage_AcquireMemory(self._mem, <fi.BYTE**>ptr, &size)
 *         return size
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_SystemError, ((PyObject *)__pyx_k_tuple_54), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":492
 *         if index != 0:
 *             raise SystemError("accessing non-existent string segment")
 *         fi.FreeImage_AcquireMemory(self._mem, <fi.BYTE**>ptr, &size)             # <<<<<<<<<<<<<<
 *         return size
 * 
 */
  FreeImage_AcquireMemory(__pyx_v_self->_mem, ((BYTE **)__pyx_v_ptr), (&__pyx_v_size));

  /* "smc/freeimage/_freeimage.pyx":493
 *             raise SystemError("accessing non-existent string segment")
 *         fi.FreeImage_AcquireMemory(self._mem, <fi.BYTE**>ptr, &size)
 *         return size             # <<<<<<<<<<<<<<
 * 
 *     def __getsegcount__(self, Py_ssize_t *lenp):
 */
  __pyx_r = __pyx_v_size;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.__getreadbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* Python wrapper */
#if PY_MAJOR_VERSION < 3
static Py_ssize_t __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_7__getsegcount__(PyObject *__pyx_v_self, Py_ssize_t *__pyx_v_lenp); /*proto*/
static Py_ssize_t __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_7__getsegcount__(PyObject *__pyx_v_self, Py_ssize_t *__pyx_v_lenp) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getsegcount__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_6__getsegcount__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)__pyx_v_self), ((Py_ssize_t *)__pyx_v_lenp));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* "smc/freeimage/_freeimage.pyx":495
 *         return size
 * 
 *     def __getsegcount__(self, Py_ssize_t *lenp):             # <<<<<<<<<<<<<<
 *         cdef long pos
 *         cdef Py_ssize_t len
 */

#if PY_MAJOR_VERSION < 3
static Py_ssize_t __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_6__getsegcount__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self, Py_ssize_t *__pyx_v_lenp) {
  Py_ssize_t __pyx_v_len;
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__getsegcount__", 0);

  /* "smc/freeimage/_freeimage.pyx":499
 *         cdef Py_ssize_t len
 * 
 *         if lenp:             # <<<<<<<<<<<<<<
 *             len = <Py_ssize_t>self.size
 *             lenp = &len
 */
  __pyx_t_1 = (__pyx_v_lenp != 0);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":500
 * 
 *         if lenp:
 *             len = <Py_ssize_t>self.size             # <<<<<<<<<<<<<<
 *             lenp = &len
 * 
 */
    __pyx_v_len = ((Py_ssize_t)__pyx_v_self->size);

    /* "smc/freeimage/_freeimage.pyx":501
 *         if lenp:
 *             len = <Py_ssize_t>self.size
 *             lenp = &len             # <<<<<<<<<<<<<<
 * 
 *         return 1
 */
    __pyx_v_lenp = (&__pyx_v_len);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":503
 *             lenp = &len
 * 
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_9__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_9__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_8__str__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":505
 *         return 1
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         cdef char *buf
 *         cdef Py_ssize_t size
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_8__str__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self) {
  char *__pyx_v_buf;
  Py_ssize_t __pyx_v_size;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "smc/freeimage/_freeimage.pyx":512
 *         # Data is copied exactly ONE time in PyBytes_FromStringAndSize.
 *         # Neither the buffer API nor the MemoryIO API copies the data.
 *         smc_fi.PyObject_AsReadBuffer(self, <smc_fi.const_void_ptr *>&buf, &size)             # <<<<<<<<<<<<<<
 *         return cpython.PyBytes_FromStringAndSize(buf, size)
 * 
 */
  __pyx_t_1 = PyObject_AsReadBuffer(((PyObject *)__pyx_v_self), ((const void* *)(&__pyx_v_buf)), (&__pyx_v_size)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":513
 *         # Neither the buffer API nor the MemoryIO API copies the data.
 *         smc_fi.PyObject_AsReadBuffer(self, <smc_fi.const_void_ptr *>&buf, &size)
 *         return cpython.PyBytes_FromStringAndSize(buf, size)             # <<<<<<<<<<<<<<
 * 
 *     property format:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)PyBytes_FromStringAndSize(__pyx_v_buf, __pyx_v_size)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_6format_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_6format_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_6format___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":516
 * 
 *     property format:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._format
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_6format___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":517
 *     property format:
 *         def __get__(self):
 *             return self._format             # <<<<<<<<<<<<<<
 * 
 *     def tell(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.format.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_11tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_9_MemoryIO_10tell[] = "tell() -> int\n\n        current file position\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_11tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tell (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_10tell(((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":519
 *             return self._format
 * 
 *     def tell(self):             # <<<<<<<<<<<<<<
 *         """tell() -> int
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_10tell(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tell", 0);

  /* "smc/freeimage/_freeimage.pyx":524
 *         current file position
 *         """
 *         return fi.FreeImage_TellMemory(self._mem)             # <<<<<<<<<<<<<<
 * 
 *     def seek(self, int offset, unsigned whence=stdio.SEEK_SET):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(FreeImage_TellMemory(__pyx_v_self->_mem)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_13seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_9_MemoryIO_12seek[] = "seek(offset [, whence]) -> None\n\n        Move to new file position.\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_13seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_offset;
  unsigned int __pyx_v_whence;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__offset,&__pyx_n_s__whence,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("seek (wrapper)", 0);
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__offset);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__whence);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "seek") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[1]) {
      } else {
        __pyx_v_whence = __pyx_k_55;
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_offset = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_offset == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[1]) {
      __pyx_v_whence = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_whence == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_whence = __pyx_k_55;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("seek", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.seek", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_12seek(((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)__pyx_v_self), __pyx_v_offset, __pyx_v_whence);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":526
 *         return fi.FreeImage_TellMemory(self._mem)
 * 
 *     def seek(self, int offset, unsigned whence=stdio.SEEK_SET):             # <<<<<<<<<<<<<<
 *         """seek(offset [, whence]) -> None
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_12seek(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self, int __pyx_v_offset, unsigned int __pyx_v_whence) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("seek", 0);

  /* "smc/freeimage/_freeimage.pyx":531
 *         Move to new file position.
 *         """
 *         if whence < stdio.SEEK_SET or whence > stdio.SEEK_END:             # <<<<<<<<<<<<<<
 *             raise ValueError("whence must be 0, 1 or 2")
 *         if not fi.FreeImage_SeekMemory(self._mem, offset, whence):
 */
  __pyx_t_1 = (__pyx_v_whence < SEEK_SET);
  if (!__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_whence > SEEK_END);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":532
 *         """
 *         if whence < stdio.SEEK_SET or whence > stdio.SEEK_END:
 *             raise ValueError("whence must be 0, 1 or 2")             # <<<<<<<<<<<<<<
 *         if not fi.FreeImage_SeekMemory(self._mem, offset, whence):
 *             raise dispatchFIError(OperationError, "Failure during seek")
 */
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_57), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":533
 *         if whence < stdio.SEEK_SET or whence > stdio.SEEK_END:
 *             raise ValueError("whence must be 0, 1 or 2")
 *         if not fi.FreeImage_SeekMemory(self._mem, offset, whence):             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failure during seek")
 * 
 */
  __pyx_t_3 = (!FreeImage_SeekMemory(__pyx_v_self->_mem, __pyx_v_offset, __pyx_v_whence));
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":534
 *             raise ValueError("whence must be 0, 1 or 2")
 *         if not fi.FreeImage_SeekMemory(self._mem, offset, whence):
 *             raise dispatchFIError(OperationError, "Failure during seek")             # <<<<<<<<<<<<<<
 * 
 *     def read(self, signed size=-1):
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_58));
    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_kp_s_58));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_58));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.seek", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_15read(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_9_MemoryIO_14read[] = "read([size]) -> data\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_15read(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  signed int __pyx_v_size;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__size,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("read (wrapper)", 0);
  {
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[0]) {
      } else {
        __pyx_v_size = ((signed int)-1);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_size = __Pyx_PyInt_AsSignedInt(values[0]); if (unlikely((__pyx_v_size == (signed int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_size = ((signed int)-1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("read", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_14read(((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)__pyx_v_self), __pyx_v_size);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":536
 *             raise dispatchFIError(OperationError, "Failure during seek")
 * 
 *     def read(self, signed size=-1):             # <<<<<<<<<<<<<<
 *         """read([size]) -> data
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_14read(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self, signed int __pyx_v_size) {
  unsigned int __pyx_v_amount;
  PyObject *__pyx_v_result = 0;
  char *__pyx_v_buf;
  int __pyx_v_pos;
  int __pyx_v_rsize;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char *__pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("read", 0);

  /* "smc/freeimage/_freeimage.pyx":544
 *         cdef int pos, rsize
 * 
 *         rsize = size             # <<<<<<<<<<<<<<
 *         if rsize == 0:
 *             return ''
 */
  __pyx_v_rsize = __pyx_v_size;

  /* "smc/freeimage/_freeimage.pyx":545
 * 
 *         rsize = size
 *         if rsize == 0:             # <<<<<<<<<<<<<<
 *             return ''
 *         elif rsize == -1:
 */
  __pyx_t_1 = (__pyx_v_rsize == 0);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":546
 *         rsize = size
 *         if rsize == 0:
 *             return ''             # <<<<<<<<<<<<<<
 *         elif rsize == -1:
 *             rsize = self.size
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
    __pyx_r = ((PyObject *)__pyx_kp_s_59);
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "smc/freeimage/_freeimage.pyx":547
 *         if rsize == 0:
 *             return ''
 *         elif rsize == -1:             # <<<<<<<<<<<<<<
 *             rsize = self.size
 *         elif rsize < 0:
 */
  __pyx_t_1 = (__pyx_v_rsize == -1);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":548
 *             return ''
 *         elif rsize == -1:
 *             rsize = self.size             # <<<<<<<<<<<<<<
 *         elif rsize < 0:
 *             raise ValueError("Invalid size")
 */
    __pyx_v_rsize = __pyx_v_self->size;
    goto __pyx_L3;
  }

  /* "smc/freeimage/_freeimage.pyx":549
 *         elif rsize == -1:
 *             rsize = self.size
 *         elif rsize < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("Invalid size")
 * 
 */
  __pyx_t_1 = (__pyx_v_rsize < 0);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":550
 *             rsize = self.size
 *         elif rsize < 0:
 *             raise ValueError("Invalid size")             # <<<<<<<<<<<<<<
 * 
 *         # read up the EOF max
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_61), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":553
 * 
 *         # read up the EOF max
 *         pos = fi.FreeImage_TellMemory(self._mem)             # <<<<<<<<<<<<<<
 *         if (self.size - pos) < rsize:
 *             rsize = self.size - pos
 */
  __pyx_v_pos = FreeImage_TellMemory(__pyx_v_self->_mem);

  /* "smc/freeimage/_freeimage.pyx":554
 *         # read up the EOF max
 *         pos = fi.FreeImage_TellMemory(self._mem)
 *         if (self.size - pos) < rsize:             # <<<<<<<<<<<<<<
 *             rsize = self.size - pos
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->size - __pyx_v_pos) < __pyx_v_rsize);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":555
 *         pos = fi.FreeImage_TellMemory(self._mem)
 *         if (self.size - pos) < rsize:
 *             rsize = self.size - pos             # <<<<<<<<<<<<<<
 * 
 *         # allocate buffer
 */
    __pyx_v_rsize = (__pyx_v_self->size - __pyx_v_pos);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":558
 * 
 *         # allocate buffer
 *         result = cpython.PyBytes_FromStringAndSize(NULL, rsize)             # <<<<<<<<<<<<<<
 *         buf = cpython.PyBytes_AsString(result)
 *         # ATTENTION! I'm using a nasty but useful trick here.
 */
  __pyx_t_2 = ((PyObject *)PyBytes_FromStringAndSize(NULL, __pyx_v_rsize)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_result = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":559
 *         # allocate buffer
 *         result = cpython.PyBytes_FromStringAndSize(NULL, rsize)
 *         buf = cpython.PyBytes_AsString(result)             # <<<<<<<<<<<<<<
 *         # ATTENTION! I'm using a nasty but useful trick here.
 *         # The pay load (obsval) of a PyBytes object is (ab)used as target
 */
  __pyx_t_3 = PyBytes_AsString(__pyx_v_result); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_buf = __pyx_t_3;

  /* "smc/freeimage/_freeimage.pyx":567
 *         # stores the image data directly into the string and thus avoids another
 *         # copy operation.
 *         amount = fi.FreeImage_ReadMemory(buf, <unsigned>rsize, 1, self._mem)             # <<<<<<<<<<<<<<
 *         # no data, invalid data
 *         if amount == 0:
 */
  __pyx_v_amount = FreeImage_ReadMemory(__pyx_v_buf, ((unsigned int)__pyx_v_rsize), 1, __pyx_v_self->_mem);

  /* "smc/freeimage/_freeimage.pyx":569
 *         amount = fi.FreeImage_ReadMemory(buf, <unsigned>rsize, 1, self._mem)
 *         # no data, invalid data
 *         if amount == 0:             # <<<<<<<<<<<<<<
 *             raise IOError("Failed to read %i bytes (requested %i)" %
 *                           (rsize, size))
 */
  __pyx_t_1 = (__pyx_v_amount == 0);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":571
 *         if amount == 0:
 *             raise IOError("Failed to read %i bytes (requested %i)" %
 *                           (rsize, size))             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_t_2 = PyInt_FromLong(__pyx_v_rsize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyInt_FromLong(__pyx_v_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_62), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "smc/freeimage/_freeimage.pyx":572
 *             raise IOError("Failed to read %i bytes (requested %i)" %
 *                           (rsize, size))
 *         return result             # <<<<<<<<<<<<<<
 * 
 * ###
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_4size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_4size___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":440
 *     """
 *     cdef fi.FIMEMORY *_mem
 *     cdef readonly int size             # <<<<<<<<<<<<<<
 *     cdef fi.FREE_IMAGE_FORMAT _format
 *     cdef Image _img
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_9_MemoryIO_4size___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage._MemoryIO.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":575
 * 
 * ###
 * cdef int floodfill(fi.FIBITMAP* dib, unsigned red, unsigned green, unsigned blue, unsigned alpha) nogil:             # <<<<<<<<<<<<<<
 *     """fill bitmap with the given colors
 * 
 */

static int __pyx_f_3smc_9freeimage_10_freeimage_floodfill(FIBITMAP *__pyx_v_dib, unsigned int __pyx_v_red, unsigned int __pyx_v_green, unsigned int __pyx_v_blue, unsigned int __pyx_v_alpha) {
  BYTE *__pyx_v_bits;
  BYTE *__pyx_v_pixel;
  unsigned int __pyx_v_width;
  unsigned int __pyx_v_height;
  unsigned int __pyx_v_pitch;
  unsigned int __pyx_v_bpp;
  CYTHON_UNUSED unsigned int __pyx_v_x;
  CYTHON_UNUSED unsigned int __pyx_v_y;
  enum FREE_IMAGE_TYPE __pyx_v_image_type;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  unsigned int __pyx_t_6;
  unsigned int __pyx_t_7;

  /* "smc/freeimage/_freeimage.pyx":586
 *     cdef fi.FREE_IMAGE_TYPE image_type
 * 
 *     if red < 0 or green < 0 or blue < 0 or alpha < 0:             # <<<<<<<<<<<<<<
 *         return ERR_ARG
 * 
 */
  __pyx_t_1 = (__pyx_v_red < 0);
  if (!__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_green < 0);
    if (!__pyx_t_2) {
      __pyx_t_3 = (__pyx_v_blue < 0);
      if (!__pyx_t_3) {
        __pyx_t_4 = (__pyx_v_alpha < 0);
        __pyx_t_5 = __pyx_t_4;
      } else {
        __pyx_t_5 = __pyx_t_3;
      }
      __pyx_t_3 = __pyx_t_5;
    } else {
      __pyx_t_3 = __pyx_t_2;
    }
    __pyx_t_2 = __pyx_t_3;
  } else {
    __pyx_t_2 = __pyx_t_1;
  }
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":587
 * 
 *     if red < 0 or green < 0 or blue < 0 or alpha < 0:
 *         return ERR_ARG             # <<<<<<<<<<<<<<
 * 
 *     width = fi.FreeImage_GetWidth(dib)
 */
    __pyx_r = -1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":589
 *         return ERR_ARG
 * 
 *     width = fi.FreeImage_GetWidth(dib)             # <<<<<<<<<<<<<<
 *     height = fi.FreeImage_GetHeight(dib)
 *     pitch = fi.FreeImage_GetPitch(dib)
 */
  __pyx_v_width = FreeImage_GetWidth(__pyx_v_dib);

  /* "smc/freeimage/_freeimage.pyx":590
 * 
 *     width = fi.FreeImage_GetWidth(dib)
 *     height = fi.FreeImage_GetHeight(dib)             # <<<<<<<<<<<<<<
 *     pitch = fi.FreeImage_GetPitch(dib)
 *     image_type = fi.FreeImage_GetImageType(dib)
 */
  __pyx_v_height = FreeImage_GetHeight(__pyx_v_dib);

  /* "smc/freeimage/_freeimage.pyx":591
 *     width = fi.FreeImage_GetWidth(dib)
 *     height = fi.FreeImage_GetHeight(dib)
 *     pitch = fi.FreeImage_GetPitch(dib)             # <<<<<<<<<<<<<<
 *     image_type = fi.FreeImage_GetImageType(dib)
 *     bpp = fi.FreeImage_GetBPP(dib)
 */
  __pyx_v_pitch = FreeImage_GetPitch(__pyx_v_dib);

  /* "smc/freeimage/_freeimage.pyx":592
 *     height = fi.FreeImage_GetHeight(dib)
 *     pitch = fi.FreeImage_GetPitch(dib)
 *     image_type = fi.FreeImage_GetImageType(dib)             # <<<<<<<<<<<<<<
 *     bpp = fi.FreeImage_GetBPP(dib)
 * 
 */
  __pyx_v_image_type = FreeImage_GetImageType(__pyx_v_dib);

  /* "smc/freeimage/_freeimage.pyx":593
 *     pitch = fi.FreeImage_GetPitch(dib)
 *     image_type = fi.FreeImage_GetImageType(dib)
 *     bpp = fi.FreeImage_GetBPP(dib)             # <<<<<<<<<<<<<<
 * 
 *     if image_type == fi.FIT_BITMAP and bpp == 24:
 */
  __pyx_v_bpp = FreeImage_GetBPP(__pyx_v_dib);

  /* "smc/freeimage/_freeimage.pyx":595
 *     bpp = fi.FreeImage_GetBPP(dib)
 * 
 *     if image_type == fi.FIT_BITMAP and bpp == 24:             # <<<<<<<<<<<<<<
 *         if red > 255 or green > 255 or blue > 255 or alpha:
 *             return ERR_ARG
 */
  __pyx_t_2 = (__pyx_v_image_type == FIT_BITMAP);
  if (__pyx_t_2) {
    __pyx_t_1 = (__pyx_v_bpp == 24);
    __pyx_t_3 = __pyx_t_1;
  } else {
    __pyx_t_3 = __pyx_t_2;
  }
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":596
 * 
 *     if image_type == fi.FIT_BITMAP and bpp == 24:
 *         if red > 255 or green > 255 or blue > 255 or alpha:             # <<<<<<<<<<<<<<
 *             return ERR_ARG
 * 
 */
    __pyx_t_3 = (__pyx_v_red > 255);
    if (!__pyx_t_3) {
      __pyx_t_2 = (__pyx_v_green > 255);
      if (!__pyx_t_2) {
        __pyx_t_1 = (__pyx_v_blue > 255);
        if (!__pyx_t_1) {
          __pyx_t_5 = __pyx_v_alpha;
        } else {
          __pyx_t_5 = __pyx_t_1;
        }
        __pyx_t_1 = __pyx_t_5;
      } else {
        __pyx_t_1 = __pyx_t_2;
      }
      __pyx_t_2 = __pyx_t_1;
    } else {
      __pyx_t_2 = __pyx_t_3;
    }
    if (__pyx_t_2) {

      /* "smc/freeimage/_freeimage.pyx":597
 *     if image_type == fi.FIT_BITMAP and bpp == 24:
 *         if red > 255 or green > 255 or blue > 255 or alpha:
 *             return ERR_ARG             # <<<<<<<<<<<<<<
 * 
 *         bits = fi.FreeImage_GetBits(dib)
 */
      __pyx_r = -1;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "smc/freeimage/_freeimage.pyx":599
 *             return ERR_ARG
 * 
 *         bits = fi.FreeImage_GetBits(dib)             # <<<<<<<<<<<<<<
 *         for y from 0 <= y < height:
 *             pixel = bits
 */
    __pyx_v_bits = FreeImage_GetBits(__pyx_v_dib);

    /* "smc/freeimage/_freeimage.pyx":600
 * 
 *         bits = fi.FreeImage_GetBits(dib)
 *         for y from 0 <= y < height:             # <<<<<<<<<<<<<<
 *             pixel = bits
 *             for x from 0 <= x < width:
 */
    __pyx_t_6 = __pyx_v_height;
    for (__pyx_v_y = 0; __pyx_v_y < __pyx_t_6; __pyx_v_y++) {

      /* "smc/freeimage/_freeimage.pyx":601
 *         bits = fi.FreeImage_GetBits(dib)
 *         for y from 0 <= y < height:
 *             pixel = bits             # <<<<<<<<<<<<<<
 *             for x from 0 <= x < width:
 *                 pixel[fi.FI_RGBA_BLUE] = blue
 */
      __pyx_v_pixel = __pyx_v_bits;

      /* "smc/freeimage/_freeimage.pyx":602
 *         for y from 0 <= y < height:
 *             pixel = bits
 *             for x from 0 <= x < width:             # <<<<<<<<<<<<<<
 *                 pixel[fi.FI_RGBA_BLUE] = blue
 *                 pixel[fi.FI_RGBA_GREEN] = green
 */
      __pyx_t_7 = __pyx_v_width;
      for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_7; __pyx_v_x++) {

        /* "smc/freeimage/_freeimage.pyx":603
 *             pixel = bits
 *             for x from 0 <= x < width:
 *                 pixel[fi.FI_RGBA_BLUE] = blue             # <<<<<<<<<<<<<<
 *                 pixel[fi.FI_RGBA_GREEN] = green
 *                 pixel[fi.FI_RGBA_RED] = red
 */
        (__pyx_v_pixel[FI_RGBA_BLUE]) = __pyx_v_blue;

        /* "smc/freeimage/_freeimage.pyx":604
 *             for x from 0 <= x < width:
 *                 pixel[fi.FI_RGBA_BLUE] = blue
 *                 pixel[fi.FI_RGBA_GREEN] = green             # <<<<<<<<<<<<<<
 *                 pixel[fi.FI_RGBA_RED] = red
 *                 pixel += 3
 */
        (__pyx_v_pixel[FI_RGBA_GREEN]) = __pyx_v_green;

        /* "smc/freeimage/_freeimage.pyx":605
 *                 pixel[fi.FI_RGBA_BLUE] = blue
 *                 pixel[fi.FI_RGBA_GREEN] = green
 *                 pixel[fi.FI_RGBA_RED] = red             # <<<<<<<<<<<<<<
 *                 pixel += 3
 *             # next line
 */
        (__pyx_v_pixel[FI_RGBA_RED]) = __pyx_v_red;

        /* "smc/freeimage/_freeimage.pyx":606
 *                 pixel[fi.FI_RGBA_GREEN] = green
 *                 pixel[fi.FI_RGBA_RED] = red
 *                 pixel += 3             # <<<<<<<<<<<<<<
 *             # next line
 *             bits += pitch
 */
        __pyx_v_pixel = (__pyx_v_pixel + 3);
      }

      /* "smc/freeimage/_freeimage.pyx":608
 *                 pixel += 3
 *             # next line
 *             bits += pitch             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
      __pyx_v_bits = (__pyx_v_bits + __pyx_v_pitch);
    }

    /* "smc/freeimage/_freeimage.pyx":610
 *             bits += pitch
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     return ERR_UNSUP
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":612
 *         return 0
 * 
 *     return ERR_UNSUP             # <<<<<<<<<<<<<<
 * #--- Image
 * 
 */
  __pyx_r = -2;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":615
 * #--- Image
 * 
 * cdef void removeAllMetadata(fi.FIBITMAP *dib):             # <<<<<<<<<<<<<<
 *     """Remove ICC profile and metadata
 *     """
 */

static void __pyx_f_3smc_9freeimage_10_freeimage_removeAllMetadata(FIBITMAP *__pyx_v_dib) {
  PyObject *__pyx_v_model = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  enum FREE_IMAGE_MDMODEL __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("removeAllMetadata", 0);

  /* "smc/freeimage/_freeimage.pyx":618
 *     """Remove ICC profile and metadata
 *     """
 *     fi.FreeImage_DestroyICCProfile(dib)             # <<<<<<<<<<<<<<
 *     for model in _META_MODELS.values():
 *         fi.FreeImage_SetMetadata(<fi.FREE_IMAGE_MDMODEL>model, dib, NULL, NULL)
 */
  FreeImage_DestroyICCProfile(__pyx_v_dib);

  /* "smc/freeimage/_freeimage.pyx":619
 *     """
 *     fi.FreeImage_DestroyICCProfile(dib)
 *     for model in _META_MODELS.values():             # <<<<<<<<<<<<<<
 *         fi.FreeImage_SetMetadata(<fi.FREE_IMAGE_MDMODEL>model, dib, NULL, NULL)
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___META_MODELS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__values); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[1]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_model);
    __pyx_v_model = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "smc/freeimage/_freeimage.pyx":620
 *     fi.FreeImage_DestroyICCProfile(dib)
 *     for model in _META_MODELS.values():
 *         fi.FreeImage_SetMetadata(<fi.FREE_IMAGE_MDMODEL>model, dib, NULL, NULL)             # <<<<<<<<<<<<<<
 * 
 * cdef int cloneICCProfile(fi.FIBITMAP *src, fi.FIBITMAP *dst):
 */
    __pyx_t_5 = ((enum FREE_IMAGE_MDMODEL)PyInt_AsLong(__pyx_v_model)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    FreeImage_SetMetadata(((enum FREE_IMAGE_MDMODEL)__pyx_t_5), __pyx_v_dib, NULL, NULL);
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_WriteUnraisable("smc.freeimage._freeimage.removeAllMetadata", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_model);
  __Pyx_RefNannyFinishContext();
}

/* "smc/freeimage/_freeimage.pyx":622
 *         fi.FreeImage_SetMetadata(<fi.FREE_IMAGE_MDMODEL>model, dib, NULL, NULL)
 * 
 * cdef int cloneICCProfile(fi.FIBITMAP *src, fi.FIBITMAP *dst):             # <<<<<<<<<<<<<<
 *     """Clone ICC profile from src to dst
 *     """
 */

static int __pyx_f_3smc_9freeimage_10_freeimage_cloneICCProfile(FIBITMAP *__pyx_v_src, FIBITMAP *__pyx_v_dst) {
  FIICCPROFILE *__pyx_v_icc;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("cloneICCProfile", 0);

  /* "smc/freeimage/_freeimage.pyx":626
 *     """
 *     cdef fi.FIICCPROFILE* icc
 *     icc = fi.FreeImage_GetICCProfile(src)             # <<<<<<<<<<<<<<
 *     if icc != NULL:
 *         fi.FreeImage_CreateICCProfile(dst, icc.data, icc.size)
 */
  __pyx_v_icc = FreeImage_GetICCProfile(__pyx_v_src);

  /* "smc/freeimage/_freeimage.pyx":627
 *     cdef fi.FIICCPROFILE* icc
 *     icc = fi.FreeImage_GetICCProfile(src)
 *     if icc != NULL:             # <<<<<<<<<<<<<<
 *         fi.FreeImage_CreateICCProfile(dst, icc.data, icc.size)
 *         return 1
 */
  __pyx_t_1 = (__pyx_v_icc != NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":628
 *     icc = fi.FreeImage_GetICCProfile(src)
 *     if icc != NULL:
 *         fi.FreeImage_CreateICCProfile(dst, icc.data, icc.size)             # <<<<<<<<<<<<<<
 *         return 1
 *     else:
 */
    FreeImage_CreateICCProfile(__pyx_v_dst, __pyx_v_icc->data, __pyx_v_icc->size);

    /* "smc/freeimage/_freeimage.pyx":629
 *     if icc != NULL:
 *         fi.FreeImage_CreateICCProfile(dst, icc.data, icc.size)
 *         return 1             # <<<<<<<<<<<<<<
 *     else:
 *         fi.FreeImage_DestroyICCProfile(dst)
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":631
 *         return 1
 *     else:
 *         fi.FreeImage_DestroyICCProfile(dst)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
    FreeImage_DestroyICCProfile(__pyx_v_dst);

    /* "smc/freeimage/_freeimage.pyx":632
 *     else:
 *         fi.FreeImage_DestroyICCProfile(dst)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * def _new_image(unsigned width, unsigned height, unsigned bpp,
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_13_new_image(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_13_new_image = {__Pyx_NAMESTR("_new_image"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_13_new_image, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_13_new_image(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  unsigned int __pyx_v_width;
  unsigned int __pyx_v_height;
  unsigned int __pyx_v_bpp;
  unsigned int __pyx_v_red_mask;
  unsigned int __pyx_v_green_mask;
  unsigned int __pyx_v_blue_mask;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__width,&__pyx_n_s__height,&__pyx_n_s__bpp,&__pyx_n_s__red_mask,&__pyx_n_s__green_mask,&__pyx_n_s__blue_mask,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_new_image (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[6] = {0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__width);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__height);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_new_image", 0, 3, 6, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bpp);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_new_image", 0, 3, 6, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__red_mask);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__green_mask);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__blue_mask);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_new_image") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[3]) {
      } else {
        __pyx_v_red_mask = ((unsigned int)0);
      }
      if (values[4]) {
      } else {
        __pyx_v_green_mask = ((unsigned int)0);
      }
      if (values[5]) {
      } else {
        __pyx_v_blue_mask = ((unsigned int)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_width = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_width == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_height = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_height == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_bpp = __Pyx_PyInt_AsUnsignedInt(values[2]); if (unlikely((__pyx_v_bpp == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[3]) {
      __pyx_v_red_mask = __Pyx_PyInt_AsUnsignedInt(values[3]); if (unlikely((__pyx_v_red_mask == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_red_mask = ((unsigned int)0);
    }
    if (values[4]) {
      __pyx_v_green_mask = __Pyx_PyInt_AsUnsignedInt(values[4]); if (unlikely((__pyx_v_green_mask == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_green_mask = ((unsigned int)0);
    }
    if (values[5]) {
      __pyx_v_blue_mask = __Pyx_PyInt_AsUnsignedInt(values[5]); if (unlikely((__pyx_v_blue_mask == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_blue_mask = ((unsigned int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_new_image", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage._new_image", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_12_new_image(__pyx_self, __pyx_v_width, __pyx_v_height, __pyx_v_bpp, __pyx_v_red_mask, __pyx_v_green_mask, __pyx_v_blue_mask);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":634
 *         return 0
 * 
 * def _new_image(unsigned width, unsigned height, unsigned bpp,             # <<<<<<<<<<<<<<
 *               unsigned red_mask = 0, unsigned green_mask = 0, unsigned blue_mask = 0):
 *         cdef fi.FIBITMAP* dib
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_12_new_image(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_width, unsigned int __pyx_v_height, unsigned int __pyx_v_bpp, unsigned int __pyx_v_red_mask, unsigned int __pyx_v_green_mask, unsigned int __pyx_v_blue_mask) {
  FIBITMAP *__pyx_v_dib;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_new_image", 0);

  /* "smc/freeimage/_freeimage.pyx":638
 *         cdef fi.FIBITMAP* dib
 *         cdef Image img
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Allocate(width, height, bpp, red_mask, green_mask, blue_mask)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":639
 *         cdef Image img
 *         with nogil:
 *             dib = fi.FreeImage_Allocate(width, height, bpp, red_mask, green_mask, blue_mask)             # <<<<<<<<<<<<<<
 * 
 *         if dib == NULL:
 */
        __pyx_v_dib = FreeImage_Allocate(__pyx_v_width, __pyx_v_height, __pyx_v_bpp, __pyx_v_red_mask, __pyx_v_green_mask, __pyx_v_blue_mask);
      }

      /* "smc/freeimage/_freeimage.pyx":638
 *         cdef fi.FIBITMAP* dib
 *         cdef Image img
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Allocate(width, height, bpp, red_mask, green_mask, blue_mask)
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":641
 *             dib = fi.FreeImage_Allocate(width, height, bpp, red_mask, green_mask, blue_mask)
 * 
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(LoadError, "Unable to allocate image")
 * 
 */
  __pyx_t_1 = (__pyx_v_dib == NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":642
 * 
 *         if dib == NULL:
 *             raise dispatchFIError(LoadError, "Unable to allocate image")             # <<<<<<<<<<<<<<
 * 
 *         return Image(_bitmap=DibWrapper(dib, None))
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__LoadError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_63));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_63));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_63));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":644
 *             raise dispatchFIError(LoadError, "Unable to allocate image")
 * 
 *         return Image(_bitmap=DibWrapper(dib, None))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = Py_None;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_2 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, __pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage._new_image", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_5Image_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_5Image_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  PyObject *__pyx_v_buffer = 0;
  struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *__pyx_v__bitmap = 0;
  int __pyx_v_fd;
  int __pyx_v_flags;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__buffer,&__pyx_n_s___bitmap,&__pyx_n_s__fd,&__pyx_n_s__flags,0};
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    PyObject* values[5] = {0,0,0,0,0};

    /* "smc/freeimage/_freeimage.pyx":660
 *     cdef fi.FIICCPROFILE* _icc
 * 
 *     def __init__(self, filename=None, buffer=None, _DibWrapper _bitmap = None,             # <<<<<<<<<<<<<<
 *                   int fd=-2, int flags = 0):
 *         if (bool(filename) + bool(_bitmap is not None) +
 */
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = (PyObject *)((struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s___bitmap);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fd);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[3]) {
      } else {
        __pyx_v_fd = ((int)-2);
      }
      if (values[4]) {
      } else {
        __pyx_v_flags = ((int)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_filename = values[0];
    __pyx_v_buffer = values[1];
    __pyx_v__bitmap = ((struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *)values[2]);
    if (values[3]) {
      __pyx_v_fd = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_fd == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_fd = ((int)-2);
    }
    if (values[4]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__bitmap), __pyx_ptype_3smc_9freeimage_10_freeimage__DibWrapper, 1, "_bitmap", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image___init__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_filename, __pyx_v_buffer, __pyx_v__bitmap, __pyx_v_fd, __pyx_v_flags);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_3smc_9freeimage_10_freeimage_5Image___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_buffer, struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *__pyx_v__bitmap, int __pyx_v_fd, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "smc/freeimage/_freeimage.pyx":662
 *     def __init__(self, filename=None, buffer=None, _DibWrapper _bitmap = None,
 *                   int fd=-2, int flags = 0):
 *         if (bool(filename) + bool(_bitmap is not None) +             # <<<<<<<<<<<<<<
 *             bool(buffer is not None) + bool(fd != -2)) != 1:
 *             raise ValueError("Exactly one argument must be applied")
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_filename); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = (((PyObject *)__pyx_v__bitmap) != Py_None);
  __pyx_t_3 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "smc/freeimage/_freeimage.pyx":663
 *                   int fd=-2, int flags = 0):
 *         if (bool(filename) + bool(_bitmap is not None) +
 *             bool(buffer is not None) + bool(fd != -2)) != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError("Exactly one argument must be applied")
 *         if filename:
 */
  __pyx_t_1 = (__pyx_v_buffer != Py_None);
  __pyx_t_3 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyNumber_Add(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = (__pyx_v_fd != -2);
  __pyx_t_3 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_int_1, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":664
 *         if (bool(filename) + bool(_bitmap is not None) +
 *             bool(buffer is not None) + bool(fd != -2)) != 1:
 *             raise ValueError("Exactly one argument must be applied")             # <<<<<<<<<<<<<<
 *         if filename:
 *             self.from_filename(filename, flags)
 */
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_65), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":665
 *             bool(buffer is not None) + bool(fd != -2)) != 1:
 *             raise ValueError("Exactly one argument must be applied")
 *         if filename:             # <<<<<<<<<<<<<<
 *             self.from_filename(filename, flags)
 *         if buffer:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_filename); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":666
 *             raise ValueError("Exactly one argument must be applied")
 *         if filename:
 *             self.from_filename(filename, flags)             # <<<<<<<<<<<<<<
 *         if buffer:
 *             self.from_buffer(buffer, flags)
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->from_filename(__pyx_v_self, __pyx_v_filename, __pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":667
 *         if filename:
 *             self.from_filename(filename, flags)
 *         if buffer:             # <<<<<<<<<<<<<<
 *             self.from_buffer(buffer, flags)
 *         if _bitmap:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_buffer); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":668
 *             self.from_filename(filename, flags)
 *         if buffer:
 *             self.from_buffer(buffer, flags)             # <<<<<<<<<<<<<<
 *         if _bitmap:
 *             if flags:
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->from_buffer(__pyx_v_self, __pyx_v_buffer, __pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "smc/freeimage/_freeimage.pyx":669
 *         if buffer:
 *             self.from_buffer(buffer, flags)
 *         if _bitmap:             # <<<<<<<<<<<<<<
 *             if flags:
 *                 raise ValueError("Flags argument not used")
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v__bitmap)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":670
 *             self.from_buffer(buffer, flags)
 *         if _bitmap:
 *             if flags:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Flags argument not used")
 *             self.from_bitmap(_bitmap)
 */
    if (__pyx_v_flags) {

      /* "smc/freeimage/_freeimage.pyx":671
 *         if _bitmap:
 *             if flags:
 *                 raise ValueError("Flags argument not used")             # <<<<<<<<<<<<<<
 *             self.from_bitmap(_bitmap)
 *         if fd != -2:
 */
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_67), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "smc/freeimage/_freeimage.pyx":672
 *             if flags:
 *                 raise ValueError("Flags argument not used")
 *             self.from_bitmap(_bitmap)             # <<<<<<<<<<<<<<
 *         if fd != -2:
 *             self.from_fd(fd, flags)
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->from_bitmap(__pyx_v_self, __pyx_v__bitmap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":673
 *                 raise ValueError("Flags argument not used")
 *             self.from_bitmap(_bitmap)
 *         if fd != -2:             # <<<<<<<<<<<<<<
 *             self.from_fd(fd, flags)
 *         self.buffers = 0
 */
  __pyx_t_1 = (__pyx_v_fd != -2);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":674
 *             self.from_bitmap(_bitmap)
 *         if fd != -2:
 *             self.from_fd(fd, flags)             # <<<<<<<<<<<<<<
 *         self.buffers = 0
 * 
 */
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__from_fd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyInt_FromLong(__pyx_v_fd); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "smc/freeimage/_freeimage.pyx":675
 *         if fd != -2:
 *             self.from_fd(fd, flags)
 *         self.buffers = 0             # <<<<<<<<<<<<<<
 * 
 *     new = staticmethod(_new_image)
 */
  __pyx_v_self->buffers = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":679
 *     new = staticmethod(_new_image)
 * 
 *     cdef from_filename(self, filename, int flags):             # <<<<<<<<<<<<<<
 *         cdef char* cfilename
 *         cdef stdio.FILE *tmpf
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_5Image_from_filename(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, PyObject *__pyx_v_filename, int __pyx_v_flags) {
  char *__pyx_v_cfilename;
  FILE *__pyx_v_tmpf;
  PyObject *__pyx_v_bfilename = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_filename", 0);

  /* "smc/freeimage/_freeimage.pyx":683
 *         cdef stdio.FILE *tmpf
 * 
 *         bfilename = _decodeFilename(filename)             # <<<<<<<<<<<<<<
 *         cfilename = <char*>bfilename
 *         # try to open the file - will raise an exception if file can't be read
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bfilename = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":684
 * 
 *         bfilename = _decodeFilename(filename)
 *         cfilename = <char*>bfilename             # <<<<<<<<<<<<<<
 *         # try to open the file - will raise an exception if file can't be read
 *         tmpf = stdio.fopen(cfilename, "r")
 */
  __pyx_t_2 = PyBytes_AsString(((PyObject *)__pyx_v_bfilename)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cfilename = ((char *)__pyx_t_2);

  /* "smc/freeimage/_freeimage.pyx":686
 *         cfilename = <char*>bfilename
 *         # try to open the file - will raise an exception if file can't be read
 *         tmpf = stdio.fopen(cfilename, "r")             # <<<<<<<<<<<<<<
 *         if tmpf == NULL:
 *             cpython.PyErr_SetFromErrnoWithFilename(IOError, bfilename)
 */
  __pyx_v_tmpf = fopen(__pyx_v_cfilename, __pyx_k__r);

  /* "smc/freeimage/_freeimage.pyx":687
 *         # try to open the file - will raise an exception if file can't be read
 *         tmpf = stdio.fopen(cfilename, "r")
 *         if tmpf == NULL:             # <<<<<<<<<<<<<<
 *             cpython.PyErr_SetFromErrnoWithFilename(IOError, bfilename)
 *         else:
 */
  __pyx_t_3 = (__pyx_v_tmpf == NULL);
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":688
 *         tmpf = stdio.fopen(cfilename, "r")
 *         if tmpf == NULL:
 *             cpython.PyErr_SetFromErrnoWithFilename(IOError, bfilename)             # <<<<<<<<<<<<<<
 *         else:
 *             stdio.fclose(tmpf)
 */
    __pyx_t_1 = __pyx_builtin_IOError;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = PyBytes_AsString(((PyObject *)__pyx_v_bfilename)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyErr_SetFromErrnoWithFilename(__pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":690
 *             cpython.PyErr_SetFromErrnoWithFilename(IOError, bfilename)
 *         else:
 *             stdio.fclose(tmpf)             # <<<<<<<<<<<<<<
 * 
 *         self._filename = cfilename
 */
    fclose(__pyx_v_tmpf);
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":692
 *             stdio.fclose(tmpf)
 * 
 *         self._filename = cfilename             # <<<<<<<<<<<<<<
 *         self._format = fi.FreeImage_GetFileType(cfilename, 0)
 *         if self._format == fi.FIF_UNKNOWN:
 */
  __pyx_v_self->_filename = __pyx_v_cfilename;

  /* "smc/freeimage/_freeimage.pyx":693
 * 
 *         self._filename = cfilename
 *         self._format = fi.FreeImage_GetFileType(cfilename, 0)             # <<<<<<<<<<<<<<
 *         if self._format == fi.FIF_UNKNOWN:
 *             raise dispatchFIError(UnknownImageError, filename)
 */
  __pyx_v_self->_format = FreeImage_GetFileType(__pyx_v_cfilename, 0);

  /* "smc/freeimage/_freeimage.pyx":694
 *         self._filename = cfilename
 *         self._format = fi.FreeImage_GetFileType(cfilename, 0)
 *         if self._format == fi.FIF_UNKNOWN:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(UnknownImageError, filename)
 *         with nogil:
 */
  __pyx_t_3 = (__pyx_v_self->_format == FIF_UNKNOWN);
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":695
 *         self._format = fi.FreeImage_GetFileType(cfilename, 0)
 *         if self._format == fi.FIF_UNKNOWN:
 *             raise dispatchFIError(UnknownImageError, filename)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             self._dib = fi.FreeImage_Load(self._format, self._filename, flags)
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__UnknownImageError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":696
 *         if self._format == fi.FIF_UNKNOWN:
 *             raise dispatchFIError(UnknownImageError, filename)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._dib = fi.FreeImage_Load(self._format, self._filename, flags)
 *         if self._dib == NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":697
 *             raise dispatchFIError(UnknownImageError, filename)
 *         with nogil:
 *             self._dib = fi.FreeImage_Load(self._format, self._filename, flags)             # <<<<<<<<<<<<<<
 *         if self._dib == NULL:
 *             raise dispatchFIError(LoadError, filename)
 */
        __pyx_v_self->_dib = FreeImage_Load(__pyx_v_self->_format, __pyx_v_self->_filename, __pyx_v_flags);
      }

      /* "smc/freeimage/_freeimage.pyx":696
 *         if self._format == fi.FIF_UNKNOWN:
 *             raise dispatchFIError(UnknownImageError, filename)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._dib = fi.FreeImage_Load(self._format, self._filename, flags)
 *         if self._dib == NULL:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":698
 *         with nogil:
 *             self._dib = fi.FreeImage_Load(self._format, self._filename, flags)
 *         if self._dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(LoadError, filename)
 *         self._init_infos()
 */
  __pyx_t_3 = (__pyx_v_self->_dib == NULL);
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":699
 *             self._dib = fi.FreeImage_Load(self._format, self._filename, flags)
 *         if self._dib == NULL:
 *             raise dispatchFIError(LoadError, filename)             # <<<<<<<<<<<<<<
 *         self._init_infos()
 * 
 */
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__LoadError); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "smc/freeimage/_freeimage.pyx":700
 *         if self._dib == NULL:
 *             raise dispatchFIError(LoadError, filename)
 *         self._init_infos()             # <<<<<<<<<<<<<<
 * 
 *     cdef from_bitmap(self, _DibWrapper bitmap):
 */
  __pyx_t_6 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_init_infos(__pyx_v_self); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.from_filename", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bfilename);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":702
 *         self._init_infos()
 * 
 *     cdef from_bitmap(self, _DibWrapper bitmap):             # <<<<<<<<<<<<<<
 *         if bitmap.dib == NULL:
 *             raise dispatchFIError(LoadError, "DIB")
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_5Image_from_bitmap(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *__pyx_v_bitmap) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_bitmap", 0);

  /* "smc/freeimage/_freeimage.pyx":703
 * 
 *     cdef from_bitmap(self, _DibWrapper bitmap):
 *         if bitmap.dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(LoadError, "DIB")
 *         self._dib = bitmap.dib
 */
  __pyx_t_1 = (__pyx_v_bitmap->dib == NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":704
 *     cdef from_bitmap(self, _DibWrapper bitmap):
 *         if bitmap.dib == NULL:
 *             raise dispatchFIError(LoadError, "DIB")             # <<<<<<<<<<<<<<
 *         self._dib = bitmap.dib
 *         self._filename = "<bitmap>"
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__LoadError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__DIB));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__DIB));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DIB));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":705
 *         if bitmap.dib == NULL:
 *             raise dispatchFIError(LoadError, "DIB")
 *         self._dib = bitmap.dib             # <<<<<<<<<<<<<<
 *         self._filename = "<bitmap>"
 *         if bitmap.oldimg:
 */
  __pyx_v_self->_dib = __pyx_v_bitmap->dib;

  /* "smc/freeimage/_freeimage.pyx":706
 *             raise dispatchFIError(LoadError, "DIB")
 *         self._dib = bitmap.dib
 *         self._filename = "<bitmap>"             # <<<<<<<<<<<<<<
 *         if bitmap.oldimg:
 *             self._format = bitmap.oldimg._format
 */
  __pyx_v_self->_filename = __pyx_k_68;

  /* "smc/freeimage/_freeimage.pyx":707
 *         self._dib = bitmap.dib
 *         self._filename = "<bitmap>"
 *         if bitmap.oldimg:             # <<<<<<<<<<<<<<
 *             self._format = bitmap.oldimg._format
 *             self.dpi_x = bitmap.oldimg.dpi_x
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_bitmap->oldimg)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":708
 *         self._filename = "<bitmap>"
 *         if bitmap.oldimg:
 *             self._format = bitmap.oldimg._format             # <<<<<<<<<<<<<<
 *             self.dpi_x = bitmap.oldimg.dpi_x
 *             self.dpi_y = bitmap.oldimg.dpi_y
 */
    __pyx_v_self->_format = __pyx_v_bitmap->oldimg->_format;

    /* "smc/freeimage/_freeimage.pyx":709
 *         if bitmap.oldimg:
 *             self._format = bitmap.oldimg._format
 *             self.dpi_x = bitmap.oldimg.dpi_x             # <<<<<<<<<<<<<<
 *             self.dpi_y = bitmap.oldimg.dpi_y
 *         else:
 */
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_bitmap->oldimg), __pyx_n_s__dpi_x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__dpi_x, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "smc/freeimage/_freeimage.pyx":710
 *             self._format = bitmap.oldimg._format
 *             self.dpi_x = bitmap.oldimg.dpi_x
 *             self.dpi_y = bitmap.oldimg.dpi_y             # <<<<<<<<<<<<<<
 *         else:
 *             # sensible default
 */
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_bitmap->oldimg), __pyx_n_s__dpi_y); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__dpi_y, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":713
 *         else:
 *             # sensible default
 *             self._format = fi.FIF_PNG             # <<<<<<<<<<<<<<
 *         self._init_infos()
 * 
 */
    __pyx_v_self->_format = FIF_PNG;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":714
 *             # sensible default
 *             self._format = fi.FIF_PNG
 *         self._init_infos()             # <<<<<<<<<<<<<<
 * 
 *     cdef from_buffer(self, object obj, int flags):
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_init_infos(__pyx_v_self); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.from_bitmap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":716
 *         self._init_infos()
 * 
 *     cdef from_buffer(self, object obj, int flags):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t size
 *         cdef fi.BYTE *buffer
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_5Image_from_buffer(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags) {
  Py_ssize_t __pyx_v_size;
  BYTE *__pyx_v_buffer;
  struct FIMEMORY *__pyx_v_mem;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_buffer", 0);

  /* "smc/freeimage/_freeimage.pyx":721
 *         cdef fi.FIMEMORY *mem
 * 
 *         smc_fi.PyObject_AsReadBuffer(obj, <smc_fi.const_void_ptr *>&buffer, &size)             # <<<<<<<<<<<<<<
 *         mem = fi.FreeImage_OpenMemory(buffer, size)
 *         if mem == NULL:
 */
  __pyx_t_1 = PyObject_AsReadBuffer(__pyx_v_obj, ((const void* *)(&__pyx_v_buffer)), (&__pyx_v_size)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":722
 * 
 *         smc_fi.PyObject_AsReadBuffer(obj, <smc_fi.const_void_ptr *>&buffer, &size)
 *         mem = fi.FreeImage_OpenMemory(buffer, size)             # <<<<<<<<<<<<<<
 *         if mem == NULL:
 *             raise dispatchFIError(FreeImageMemoryError, "fi.FreeImage_OpenMemory() has failed")
 */
  __pyx_v_mem = FreeImage_OpenMemory(__pyx_v_buffer, __pyx_v_size);

  /* "smc/freeimage/_freeimage.pyx":723
 *         smc_fi.PyObject_AsReadBuffer(obj, <smc_fi.const_void_ptr *>&buffer, &size)
 *         mem = fi.FreeImage_OpenMemory(buffer, size)
 *         if mem == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(FreeImageMemoryError, "fi.FreeImage_OpenMemory() has failed")
 *         self._format = fi.FreeImage_GetFileTypeFromMemory(mem, 0)
 */
  __pyx_t_2 = (__pyx_v_mem == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":724
 *         mem = fi.FreeImage_OpenMemory(buffer, size)
 *         if mem == NULL:
 *             raise dispatchFIError(FreeImageMemoryError, "fi.FreeImage_OpenMemory() has failed")             # <<<<<<<<<<<<<<
 *         self._format = fi.FreeImage_GetFileTypeFromMemory(mem, 0)
 *         if self._format == fi.FIF_UNKNOWN:
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s_45); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_51));
    PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_kp_s_51));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_51));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":725
 *         if mem == NULL:
 *             raise dispatchFIError(FreeImageMemoryError, "fi.FreeImage_OpenMemory() has failed")
 *         self._format = fi.FreeImage_GetFileTypeFromMemory(mem, 0)             # <<<<<<<<<<<<<<
 *         if self._format == fi.FIF_UNKNOWN:
 *             fi.FreeImage_CloseMemory(mem)
 */
  __pyx_v_self->_format = FreeImage_GetFileTypeFromMemory(__pyx_v_mem, 0);

  /* "smc/freeimage/_freeimage.pyx":726
 *             raise dispatchFIError(FreeImageMemoryError, "fi.FreeImage_OpenMemory() has failed")
 *         self._format = fi.FreeImage_GetFileTypeFromMemory(mem, 0)
 *         if self._format == fi.FIF_UNKNOWN:             # <<<<<<<<<<<<<<
 *             fi.FreeImage_CloseMemory(mem)
 *             mem = NULL
 */
  __pyx_t_2 = (__pyx_v_self->_format == FIF_UNKNOWN);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":727
 *         self._format = fi.FreeImage_GetFileTypeFromMemory(mem, 0)
 *         if self._format == fi.FIF_UNKNOWN:
 *             fi.FreeImage_CloseMemory(mem)             # <<<<<<<<<<<<<<
 *             mem = NULL
 *             raise dispatchFIError(UnknownImageError, "<buffer>")
 */
    FreeImage_CloseMemory(__pyx_v_mem);

    /* "smc/freeimage/_freeimage.pyx":728
 *         if self._format == fi.FIF_UNKNOWN:
 *             fi.FreeImage_CloseMemory(mem)
 *             mem = NULL             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(UnknownImageError, "<buffer>")
 * 
 */
    __pyx_v_mem = NULL;

    /* "smc/freeimage/_freeimage.pyx":729
 *             fi.FreeImage_CloseMemory(mem)
 *             mem = NULL
 *             raise dispatchFIError(UnknownImageError, "<buffer>")             # <<<<<<<<<<<<<<
 * 
 *         self._dib = fi.FreeImage_LoadFromMemory(self._format, mem, flags)
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__UnknownImageError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_69));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_kp_s_69));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_69));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":731
 *             raise dispatchFIError(UnknownImageError, "<buffer>")
 * 
 *         self._dib = fi.FreeImage_LoadFromMemory(self._format, mem, flags)             # <<<<<<<<<<<<<<
 *         fi.FreeImage_CloseMemory(mem)
 * 
 */
  __pyx_v_self->_dib = FreeImage_LoadFromMemory(__pyx_v_self->_format, __pyx_v_mem, __pyx_v_flags);

  /* "smc/freeimage/_freeimage.pyx":732
 * 
 *         self._dib = fi.FreeImage_LoadFromMemory(self._format, mem, flags)
 *         fi.FreeImage_CloseMemory(mem)             # <<<<<<<<<<<<<<
 * 
 *         self._filename = ""
 */
  FreeImage_CloseMemory(__pyx_v_mem);

  /* "smc/freeimage/_freeimage.pyx":734
 *         fi.FreeImage_CloseMemory(mem)
 * 
 *         self._filename = ""             # <<<<<<<<<<<<<<
 *         self._init_infos()
 * 
 */
  __pyx_v_self->_filename = __pyx_k_59;

  /* "smc/freeimage/_freeimage.pyx":735
 * 
 *         self._filename = ""
 *         self._init_infos()             # <<<<<<<<<<<<<<
 * 
 *     cdef _init_infos(self):
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_init_infos(__pyx_v_self); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.from_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":737
 *         self._init_infos()
 * 
 *     cdef _init_infos(self):             # <<<<<<<<<<<<<<
 *         self.width = fi.FreeImage_GetWidth(self._dib)
 *         self.height = fi.FreeImage_GetHeight(self._dib)
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_5Image__init_infos(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_init_infos", 0);

  /* "smc/freeimage/_freeimage.pyx":738
 * 
 *     cdef _init_infos(self):
 *         self.width = fi.FreeImage_GetWidth(self._dib)             # <<<<<<<<<<<<<<
 *         self.height = fi.FreeImage_GetHeight(self._dib)
 *         self._icc = NULL
 */
  __pyx_v_self->width = FreeImage_GetWidth(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":739
 *     cdef _init_infos(self):
 *         self.width = fi.FreeImage_GetWidth(self._dib)
 *         self.height = fi.FreeImage_GetHeight(self._dib)             # <<<<<<<<<<<<<<
 *         self._icc = NULL
 * 
 */
  __pyx_v_self->height = FreeImage_GetHeight(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":740
 *         self.width = fi.FreeImage_GetWidth(self._dib)
 *         self.height = fi.FreeImage_GetHeight(self._dib)
 *         self._icc = NULL             # <<<<<<<<<<<<<<
 * 
 *     def close(self):
 */
  __pyx_v_self->_icc = NULL;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_2close[] = "close() -> None\n\n        Close the image and free all resources. The close operation fails when\n        a buffer is still using the image data.\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_2close(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":742
 *         self._icc = NULL
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         """close() -> None
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_2close(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("close", 0);

  /* "smc/freeimage/_freeimage.pyx":748
 *         a buffer is still using the image data.
 *         """
 *         if self.buffers:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Image is still access from %i buffer%s." %
 *                                  (self.buffers, 's' if self.buffers > 1 else ''))
 */
  if (__pyx_v_self->buffers) {

    /* "smc/freeimage/_freeimage.pyx":749
 *         """
 *         if self.buffers:
 *             raise dispatchFIError(OperationError, "Image is still access from %i buffer%s." %             # <<<<<<<<<<<<<<
 *                                  (self.buffers, 's' if self.buffers > 1 else ''))
 *         if self._dib:
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);

    /* "smc/freeimage/_freeimage.pyx":750
 *         if self.buffers:
 *             raise dispatchFIError(OperationError, "Image is still access from %i buffer%s." %
 *                                  (self.buffers, 's' if self.buffers > 1 else ''))             # <<<<<<<<<<<<<<
 *         if self._dib:
 *             with nogil:
 */
    __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_self->buffers); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if ((__pyx_v_self->buffers > 1)) {
      __Pyx_INCREF(((PyObject *)__pyx_n_s__s));
      __pyx_t_4 = __pyx_n_s__s;
    } else {
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
      __pyx_t_4 = __pyx_kp_s_59;
    }
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_70), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":751
 *             raise dispatchFIError(OperationError, "Image is still access from %i buffer%s." %
 *                                  (self.buffers, 's' if self.buffers > 1 else ''))
 *         if self._dib:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 fi.FreeImage_Unload(self._dib)
 */
  __pyx_t_6 = (__pyx_v_self->_dib != 0);
  if (__pyx_t_6) {

    /* "smc/freeimage/_freeimage.pyx":752
 *                                  (self.buffers, 's' if self.buffers > 1 else ''))
 *         if self._dib:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 fi.FreeImage_Unload(self._dib)
 *                 self._dib = NULL
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "smc/freeimage/_freeimage.pyx":753
 *         if self._dib:
 *             with nogil:
 *                 fi.FreeImage_Unload(self._dib)             # <<<<<<<<<<<<<<
 *                 self._dib = NULL
 * 
 */
          FreeImage_Unload(__pyx_v_self->_dib);

          /* "smc/freeimage/_freeimage.pyx":754
 *             with nogil:
 *                 fi.FreeImage_Unload(self._dib)
 *                 self._dib = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
          __pyx_v_self->_dib = NULL;
        }

        /* "smc/freeimage/_freeimage.pyx":752
 *                                  (self.buffers, 's' if self.buffers > 1 else ''))
 *         if self._dib:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 fi.FreeImage_Unload(self._dib)
 *                 self._dib = NULL
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }
    goto __pyx_L4;
  }
  __pyx_L4:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_3smc_9freeimage_10_freeimage_5Image_4__dealloc__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "smc/freeimage/_freeimage.pyx":756
 *                 self._dib = NULL
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         self.close()
 * 
 */

static void __pyx_pf_3smc_9freeimage_10_freeimage_5Image_4__dealloc__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "smc/freeimage/_freeimage.pyx":757
 * 
 *     def __dealloc__(self):
 *         self.close()             # <<<<<<<<<<<<<<
 * 
 *     def __sizeof__(self):
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_7__sizeof__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_7__sizeof__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sizeof__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_6__sizeof__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":759
 *         self.close()
 * 
 *     def __sizeof__(self):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t cls, data
 *         cls = (4 * 2 # 4 ints
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_6__sizeof__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  Py_ssize_t __pyx_v_cls;
  Py_ssize_t __pyx_v_data;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__sizeof__", 0);

  /* "smc/freeimage/_freeimage.pyx":763
 *         cls = (4 * 2 # 4 ints
 *                + 3 * 8 # three points
 *                + len(self._filename) # filename             # <<<<<<<<<<<<<<
 *                )
 *         if self._dib != NULL:
 */
  __pyx_t_1 = strlen(__pyx_v_self->_filename); 
  __pyx_v_cls = (32 + __pyx_t_1);

  /* "smc/freeimage/_freeimage.pyx":765
 *                + len(self._filename) # filename
 *                )
 *         if self._dib != NULL:             # <<<<<<<<<<<<<<
 *             # doesn't take alignment into account, might be larger
 *             data = self.bpp * self.width * self.height // 8
 */
  __pyx_t_2 = (__pyx_v_self->_dib != NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":767
 *         if self._dib != NULL:
 *             # doesn't take alignment into account, might be larger
 *             data = self.bpp * self.width * self.height // 8             # <<<<<<<<<<<<<<
 *         else:
 *             data = 0
 */
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__bpp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_self->width); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_Multiply(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_self->height); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_FloorDivide(__pyx_t_3, __pyx_int_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_data = __pyx_t_6;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":769
 *             data = self.bpp * self.width * self.height // 8
 *         else:
 *             data = 0             # <<<<<<<<<<<<<<
 *         return cls + data
 * 
 */
    __pyx_v_data = 0;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":770
 *         else:
 *             data = 0
 *         return cls + data             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyInt_FromSsize_t((__pyx_v_cls + __pyx_v_data)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.__sizeof__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_9__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_9__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_8__repr__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":772
 *         return cls + data
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s %ix%i %ibpp (%s; %s) at 0x%x>" % (self.__class__.__name__,
 *             self.width, self.height, self.bpp, self.mimetype,
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_8__repr__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "smc/freeimage/_freeimage.pyx":773
 * 
 *     def __repr__(self):
 *         return "<%s %ix%i %ibpp (%s; %s) at 0x%x>" % (self.__class__.__name__,             # <<<<<<<<<<<<<<
 *             self.width, self.height, self.bpp, self.mimetype,
 *             self.color_type_name, id(self))
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____name__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":774
 *     def __repr__(self):
 *         return "<%s %ix%i %ibpp (%s; %s) at 0x%x>" % (self.__class__.__name__,
 *             self.width, self.height, self.bpp, self.mimetype,             # <<<<<<<<<<<<<<
 *             self.color_type_name, id(self))
 * 
 */
  __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_self->height); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__bpp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__mimetype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "smc/freeimage/_freeimage.pyx":775
 *         return "<%s %ix%i %ibpp (%s; %s) at 0x%x>" % (self.__class__.__name__,
 *             self.width, self.height, self.bpp, self.mimetype,
 *             self.color_type_name, id(self))             # <<<<<<<<<<<<<<
 * 
 *     cdef _check_closed(self):
 */
  __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__color_type_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_8 = PyObject_Call(__pyx_builtin_id, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  __pyx_t_7 = PyTuple_New(7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 5, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_7, 6, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_71), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_8));
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  __pyx_r = ((PyObject *)__pyx_t_8);
  __pyx_t_8 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":777
 *             self.color_type_name, id(self))
 * 
 *     cdef _check_closed(self):             # <<<<<<<<<<<<<<
 *         if self._dib == NULL:
 *             raise IOError("Operation on closed image")
 */

static PyObject *__pyx_f_3smc_9freeimage_10_freeimage_5Image__check_closed(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_check_closed", 0);

  /* "smc/freeimage/_freeimage.pyx":778
 * 
 *     cdef _check_closed(self):
 *         if self._dib == NULL:             # <<<<<<<<<<<<<<
 *             raise IOError("Operation on closed image")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_dib == NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":779
 *     cdef _check_closed(self):
 *         if self._dib == NULL:
 *             raise IOError("Operation on closed image")             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_72), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image._check_closed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_11__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_11__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_10__enter__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":781
 *             raise IOError("Operation on closed image")
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         self._check_closed()
 *         return self
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_10__enter__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__enter__", 0);

  /* "smc/freeimage/_freeimage.pyx":782
 * 
 *     def __enter__(self):
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":783
 *     def __enter__(self):
 *         self._check_closed()
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __exit__(self, exc, value, tb):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_13__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_13__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_exc = 0;
  CYTHON_UNUSED PyObject *__pyx_v_value = 0;
  CYTHON_UNUSED PyObject *__pyx_v_tb = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__exc,&__pyx_n_s__value,&__pyx_n_s__tb,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
  {
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exc);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tb);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_exc = values[0];
    __pyx_v_value = values[1];
    __pyx_v_tb = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_12__exit__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_exc, __pyx_v_value, __pyx_v_tb);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":785
 *         return self
 * 
 *     def __exit__(self, exc, value, tb):             # <<<<<<<<<<<<<<
 *         self.close()
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_12__exit__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_exc, CYTHON_UNUSED PyObject *__pyx_v_value, CYTHON_UNUSED PyObject *__pyx_v_tb) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__exit__", 0);

  /* "smc/freeimage/_freeimage.pyx":786
 * 
 *     def __exit__(self, exc, value, tb):
 *         self.close()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_8filename_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_8filename_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_8filename___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":795
 *         """filename
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return funicode(self._filename)
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_8filename___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":796
 *         """
 *         def __get__(self):
 *             return funicode(self._filename)             # <<<<<<<<<<<<<<
 * 
 *     property size:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(__pyx_v_self->_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.filename.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_4size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_4size___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":801
 *         """size -> (widht: int, height: int)
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.width, self.height
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_4size___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":802
 *         """
 *         def __get__(self):
 *             return self.width, self.height             # <<<<<<<<<<<<<<
 * 
 *     property format:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->height); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_6format_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_6format_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_6format___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":809
 *         Format is the image format like fi.FIF_JPEG or fi.FIF_PNG.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._format
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_6format___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":810
 *         """
 *         def __get__(self):
 *             return self._format             # <<<<<<<<<<<<<<
 * 
 *     property type:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.format.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_4type_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_4type_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_4type___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":817
 *         Type referes to the data type of the image like fi.FIT_BITMAP or fi.FIT_RGBF.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_GetImageType(self._dib)
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_4type___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":818
 *         """
 *         def __get__(self):
 *             return fi.FreeImage_GetImageType(self._dib)             # <<<<<<<<<<<<<<
 * 
 *     property mimetype:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(FreeImage_GetImageType(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.type.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_8mimetype_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_8mimetype_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_8mimetype___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":825
 *         mimetype of the image, e.g. image/jpeg
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return funicode(fi.FreeImage_GetFIFMimeType(self._format))
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_8mimetype___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":826
 *         """
 *         def __get__(self):
 *             return funicode(fi.FreeImage_GetFIFMimeType(self._format))             # <<<<<<<<<<<<<<
 * 
 *     property dpi_x:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(FreeImage_GetFIFMimeType(__pyx_v_self->_format)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.mimetype.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_x_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_x_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_x___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":833
 *         Dots per inch (x axis)
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             return round(fi.FreeImage_GetDotsPerMeterX(self._dib) * INCH_METER)
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_x___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":834
 *         """
 *         def __get__(self):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             return round(fi.FreeImage_GetDotsPerMeterX(self._dib) * INCH_METER)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":835
 *         def __get__(self):
 *             self._check_closed()
 *             return round(fi.FreeImage_GetDotsPerMeterX(self._dib) * INCH_METER)             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, float dpi):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble((FreeImage_GetDotsPerMeterX(__pyx_v_self->_dib) * 0.0254)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_builtin_round, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpi_x.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_x_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_dpi); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_x_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_dpi) {
  float __pyx_v_dpi;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  assert(__pyx_arg_dpi); {
    __pyx_v_dpi = __pyx_PyFloat_AsFloat(__pyx_arg_dpi); if (unlikely((__pyx_v_dpi == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpi_x.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_x_2__set__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), ((float)__pyx_v_dpi));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":837
 *             return round(fi.FreeImage_GetDotsPerMeterX(self._dib) * INCH_METER)
 * 
 *         def __set__(self, float dpi):             # <<<<<<<<<<<<<<
 *             if dpi < 0:
 *                 raise ValueError("DPI must be positive or zero.")
 */

static int __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_x_2__set__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_dpi) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  unsigned int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "smc/freeimage/_freeimage.pyx":838
 * 
 *         def __set__(self, float dpi):
 *             if dpi < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("DPI must be positive or zero.")
 *             self._check_closed()
 */
  __pyx_t_1 = (__pyx_v_dpi < 0.0);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":839
 *         def __set__(self, float dpi):
 *             if dpi < 0:
 *                 raise ValueError("DPI must be positive or zero.")             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             fi.FreeImage_SetDotsPerMeterX(self._dib, int(round(dpi * METER_INCH)))
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_74), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":840
 *             if dpi < 0:
 *                 raise ValueError("DPI must be positive or zero.")
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             fi.FreeImage_SetDotsPerMeterX(self._dib, int(round(dpi * METER_INCH)))
 * 
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":841
 *                 raise ValueError("DPI must be positive or zero.")
 *             self._check_closed()
 *             fi.FreeImage_SetDotsPerMeterX(self._dib, int(round(dpi * METER_INCH)))             # <<<<<<<<<<<<<<
 * 
 *     property dpi_y:
 */
  __pyx_t_2 = PyFloat_FromDouble((__pyx_v_dpi * 39.3700787)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_round, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  FreeImage_SetDotsPerMeterX(__pyx_v_self->_dib, __pyx_t_4);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpi_x.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_y_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_y_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_y___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":848
 *         Dots per inch (y axis)
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             return round(fi.FreeImage_GetDotsPerMeterY(self._dib) * INCH_METER)
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_y___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":849
 *         """
 *         def __get__(self):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             return round(fi.FreeImage_GetDotsPerMeterY(self._dib) * INCH_METER)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":850
 *         def __get__(self):
 *             self._check_closed()
 *             return round(fi.FreeImage_GetDotsPerMeterY(self._dib) * INCH_METER)             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, float dpi):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble((FreeImage_GetDotsPerMeterY(__pyx_v_self->_dib) * 0.0254)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_builtin_round, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpi_y.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_y_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_dpi); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_y_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_dpi) {
  float __pyx_v_dpi;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  assert(__pyx_arg_dpi); {
    __pyx_v_dpi = __pyx_PyFloat_AsFloat(__pyx_arg_dpi); if (unlikely((__pyx_v_dpi == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpi_y.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_y_2__set__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), ((float)__pyx_v_dpi));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":852
 *             return round(fi.FreeImage_GetDotsPerMeterY(self._dib) * INCH_METER)
 * 
 *         def __set__(self, float dpi):             # <<<<<<<<<<<<<<
 *             if dpi < 0:
 *                 raise ValueError("DPI must be positive or zero.")
 */

static int __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpi_y_2__set__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_dpi) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  unsigned int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "smc/freeimage/_freeimage.pyx":853
 * 
 *         def __set__(self, float dpi):
 *             if dpi < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("DPI must be positive or zero.")
 *             self._check_closed()
 */
  __pyx_t_1 = (__pyx_v_dpi < 0.0);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":854
 *         def __set__(self, float dpi):
 *             if dpi < 0:
 *                 raise ValueError("DPI must be positive or zero.")             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             fi.FreeImage_SetDotsPerMeterY(self._dib, int(round(dpi * METER_INCH)))
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_75), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":855
 *             if dpi < 0:
 *                 raise ValueError("DPI must be positive or zero.")
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             fi.FreeImage_SetDotsPerMeterY(self._dib, int(round(dpi * METER_INCH)))
 * 
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":856
 *                 raise ValueError("DPI must be positive or zero.")
 *             self._check_closed()
 *             fi.FreeImage_SetDotsPerMeterY(self._dib, int(round(dpi * METER_INCH)))             # <<<<<<<<<<<<<<
 * 
 *     property dpi:
 */
  __pyx_t_2 = PyFloat_FromDouble((__pyx_v_dpi * 39.3700787)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_round, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  FreeImage_SetDotsPerMeterY(__pyx_v_self->_dib, __pyx_t_4);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpi_y.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_3dpi_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_3dpi_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_3dpi___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":861
 *         """dpi -> (dpi_x: int, dpi_y: int)
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.dpi_x, self.dpi_y
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_3dpi___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":862
 *         """
 *         def __get__(self):
 *             return self.dpi_x, self.dpi_y             # <<<<<<<<<<<<<<
 * 
 *     property dpm_x:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__dpi_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__dpi_y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpi.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_x_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_x_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_x___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":869
 *         Dots per meter (x axis)
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             return int(fi.FreeImage_GetDotsPerMeterX(self._dib))
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_x___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":870
 *         """
 *         def __get__(self):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             return int(fi.FreeImage_GetDotsPerMeterX(self._dib))
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":871
 *         def __get__(self):
 *             self._check_closed()
 *             return int(fi.FreeImage_GetDotsPerMeterX(self._dib))             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, unsigned dpm):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(FreeImage_GetDotsPerMeterX(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpm_x.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_x_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_dpm); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_x_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_dpm) {
  unsigned int __pyx_v_dpm;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  assert(__pyx_arg_dpm); {
    __pyx_v_dpm = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_dpm); if (unlikely((__pyx_v_dpm == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpm_x.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_x_2__set__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), ((unsigned int)__pyx_v_dpm));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":873
 *             return int(fi.FreeImage_GetDotsPerMeterX(self._dib))
 * 
 *         def __set__(self, unsigned dpm):             # <<<<<<<<<<<<<<
 *             fi.FreeImage_SetDotsPerMeterX(self._dib, dpm)
 * 
 */

static int __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_x_2__set__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_dpm) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "smc/freeimage/_freeimage.pyx":874
 * 
 *         def __set__(self, unsigned dpm):
 *             fi.FreeImage_SetDotsPerMeterX(self._dib, dpm)             # <<<<<<<<<<<<<<
 * 
 *     property dpm_y:
 */
  FreeImage_SetDotsPerMeterX(__pyx_v_self->_dib, __pyx_v_dpm);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_y_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_y_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_y___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":881
 *         Dots per meter (y axis)
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             return int(fi.FreeImage_GetDotsPerMeterY(self._dib))
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_y___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":882
 *         """
 *         def __get__(self):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             return int(fi.FreeImage_GetDotsPerMeterY(self._dib))
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":883
 *         def __get__(self):
 *             self._check_closed()
 *             return int(fi.FreeImage_GetDotsPerMeterY(self._dib))             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, unsigned dpm):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(FreeImage_GetDotsPerMeterY(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpm_y.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_y_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_dpm); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_y_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_dpm) {
  unsigned int __pyx_v_dpm;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  assert(__pyx_arg_dpm); {
    __pyx_v_dpm = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_dpm); if (unlikely((__pyx_v_dpm == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpm_y.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_y_2__set__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), ((unsigned int)__pyx_v_dpm));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":885
 *             return int(fi.FreeImage_GetDotsPerMeterY(self._dib))
 * 
 *         def __set__(self, unsigned dpm):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             fi.FreeImage_SetDotsPerMeterY(self._dib, dpm)
 */

static int __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5dpm_y_2__set__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_dpm) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "smc/freeimage/_freeimage.pyx":886
 * 
 *         def __set__(self, unsigned dpm):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             fi.FreeImage_SetDotsPerMeterY(self._dib, dpm)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":887
 *         def __set__(self, unsigned dpm):
 *             self._check_closed()
 *             fi.FreeImage_SetDotsPerMeterY(self._dib, dpm)             # <<<<<<<<<<<<<<
 * 
 *     property dpm:
 */
  FreeImage_SetDotsPerMeterY(__pyx_v_self->_dib, __pyx_v_dpm);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpm_y.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_3dpm_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_3dpm_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_3dpm___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":892
 *         """dpm -> (dpm_x: int, dpm_y: int)
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.dpm_x, self.dpm_y
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_3dpm___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":893
 *         """
 *         def __get__(self):
 *             return self.dpm_x, self.dpm_y             # <<<<<<<<<<<<<<
 * 
 *     property colors_used:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__dpm_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__dpm_y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dpm.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_11colors_used_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_11colors_used_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_11colors_used___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":901
 *         high color images.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             return fi.FreeImage_GetColorsUsed(self._dib)
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_11colors_used___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":902
 *         """
 *         def __get__(self):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_GetColorsUsed(self._dib)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":903
 *         def __get__(self):
 *             self._check_closed()
 *             return fi.FreeImage_GetColorsUsed(self._dib)             # <<<<<<<<<<<<<<
 * 
 *     property bpp:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(FreeImage_GetColorsUsed(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.colors_used.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_3bpp_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_3bpp_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_3bpp___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":910
 *         bits per pixel
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             return fi.FreeImage_GetBPP(self._dib)
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_3bpp___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":911
 *         """
 *         def __get__(self):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_GetBPP(self._dib)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":912
 *         def __get__(self):
 *             self._check_closed()
 *             return fi.FreeImage_GetBPP(self._dib)             # <<<<<<<<<<<<<<
 * 
 *     property has_icc:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(FreeImage_GetBPP(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.bpp.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_7has_icc_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_7has_icc_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_7has_icc___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":919
 *         Returns true if the image has an ICC profile
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._icc == NULL:
 *                 self._check_closed()
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_7has_icc___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":920
 *         """
 *         def __get__(self):
 *             if self._icc == NULL:             # <<<<<<<<<<<<<<
 *                 self._check_closed()
 *                 with nogil:
 */
  __pyx_t_1 = (__pyx_v_self->_icc == NULL);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":921
 *         def __get__(self):
 *             if self._icc == NULL:
 *                 self._check_closed()             # <<<<<<<<<<<<<<
 *                 with nogil:
 *                     self._icc = fi.FreeImage_GetICCProfile(self._dib)
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "smc/freeimage/_freeimage.pyx":922
 *             if self._icc == NULL:
 *                 self._check_closed()
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._icc = fi.FreeImage_GetICCProfile(self._dib)
 *             if self._icc.data:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "smc/freeimage/_freeimage.pyx":923
 *                 self._check_closed()
 *                 with nogil:
 *                     self._icc = fi.FreeImage_GetICCProfile(self._dib)             # <<<<<<<<<<<<<<
 *             if self._icc.data:
 *                 return True
 */
          __pyx_v_self->_icc = FreeImage_GetICCProfile(__pyx_v_self->_dib);
        }

        /* "smc/freeimage/_freeimage.pyx":922
 *             if self._icc == NULL:
 *                 self._check_closed()
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._icc = fi.FreeImage_GetICCProfile(self._dib)
 *             if self._icc.data:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":924
 *                 with nogil:
 *                     self._icc = fi.FreeImage_GetICCProfile(self._dib)
 *             if self._icc.data:             # <<<<<<<<<<<<<<
 *                 return True
 *             else:
 */
  __pyx_t_1 = (__pyx_v_self->_icc->data != 0);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":925
 *                     self._icc = fi.FreeImage_GetICCProfile(self._dib)
 *             if self._icc.data:
 *                 return True             # <<<<<<<<<<<<<<
 *             else:
 *                 return False
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":927
 *                 return True
 *             else:
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *     property icc_cmyk:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L7:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.has_icc.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_8icc_cmyk_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_8icc_cmyk_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_8icc_cmyk___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":932
 *         """icc_cmyk -> bool
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if not self.has_icc:
 *                 return None
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_8icc_cmyk___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":933
 *         """
 *         def __get__(self):
 *             if not self.has_icc:             # <<<<<<<<<<<<<<
 *                 return None
 *             if (self._icc.flags & fi.FIICC_COLOR_IS_CMYK) == fi.FIICC_COLOR_IS_CMYK:
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__has_icc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (!__pyx_t_2);
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":934
 *         def __get__(self):
 *             if not self.has_icc:
 *                 return None             # <<<<<<<<<<<<<<
 *             if (self._icc.flags & fi.FIICC_COLOR_IS_CMYK) == fi.FIICC_COLOR_IS_CMYK:
 *                 return True
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":935
 *             if not self.has_icc:
 *                 return None
 *             if (self._icc.flags & fi.FIICC_COLOR_IS_CMYK) == fi.FIICC_COLOR_IS_CMYK:             # <<<<<<<<<<<<<<
 *                 return True
 *             else:
 */
  __pyx_t_3 = ((__pyx_v_self->_icc->flags & FIICC_COLOR_IS_CMYK) == FIICC_COLOR_IS_CMYK);
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":936
 *                 return None
 *             if (self._icc.flags & fi.FIICC_COLOR_IS_CMYK) == fi.FIICC_COLOR_IS_CMYK:
 *                 return True             # <<<<<<<<<<<<<<
 *             else:
 *                 return False
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":938
 *                 return True
 *             else:
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *     property color_type:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __pyx_L4:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.icc_cmyk.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_10color_type_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_10color_type_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_10color_type___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":945
 *         Get color type of the image, e.g. fi.FIC_MINISBLACK, fi.FIC_RGB, fi.FIC_CMYK ...
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             return fi.FreeImage_GetColorType(self._dib)
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_10color_type___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":946
 *         """
 *         def __get__(self):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_GetColorType(self._dib)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":947
 *         def __get__(self):
 *             self._check_closed()
 *             return fi.FreeImage_GetColorType(self._dib)             # <<<<<<<<<<<<<<
 * 
 *     property color_type_name:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(FreeImage_GetColorType(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.color_type.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_15color_type_name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_15color_type_name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_15color_type_name___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":952
 *         """color_type_name -> str
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef fi.FREE_IMAGE_COLOR_TYPE ct
 *             self._check_closed()
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_15color_type_name___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  enum FREE_IMAGE_COLOR_TYPE __pyx_v_ct;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":954
 *         def __get__(self):
 *             cdef fi.FREE_IMAGE_COLOR_TYPE ct
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             ct = fi.FreeImage_GetColorType(self._dib)
 *             return _COLOR_TYPE_NAMES.get(ct, "UNKNOWN")
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":955
 *             cdef fi.FREE_IMAGE_COLOR_TYPE ct
 *             self._check_closed()
 *             ct = fi.FreeImage_GetColorType(self._dib)             # <<<<<<<<<<<<<<
 *             return _COLOR_TYPE_NAMES.get(ct, "UNKNOWN")
 * 
 */
  __pyx_v_ct = FreeImage_GetColorType(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":956
 *             self._check_closed()
 *             ct = fi.FreeImage_GetColorType(self._dib)
 *             return _COLOR_TYPE_NAMES.get(ct, "UNKNOWN")             # <<<<<<<<<<<<<<
 * 
 *     property is_transparent:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___COLOR_TYPE_NAMES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(__pyx_v_ct); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__UNKNOWN));
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__UNKNOWN));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__UNKNOWN));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.color_type_name.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_14is_transparent_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_14is_transparent_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_14is_transparent___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":961
 *         """is_transparent -> bool
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             return fi.FreeImage_IsTransparent(self._dib)
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_14is_transparent___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":962
 *         """
 *         def __get__(self):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_IsTransparent(self._dib)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":963
 *         def __get__(self):
 *             self._check_closed()
 *             return fi.FreeImage_IsTransparent(self._dib)             # <<<<<<<<<<<<<<
 * 
 *     property has_bg_color:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(FreeImage_IsTransparent(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.is_transparent.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_12has_bg_color_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_12has_bg_color_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_12has_bg_color___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":968
 *         """has_bg_color -> bool
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             return fi.FreeImage_HasBackgroundColor(self._dib)
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_12has_bg_color___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":969
 *         """
 *         def __get__(self):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_HasBackgroundColor(self._dib)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":970
 *         def __get__(self):
 *             self._check_closed()
 *             return fi.FreeImage_HasBackgroundColor(self._dib)             # <<<<<<<<<<<<<<
 * 
 *     property rgb_mask:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(FreeImage_HasBackgroundColor(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.has_bg_color.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_8rgb_mask_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_8rgb_mask_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_8rgb_mask___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":975
 *         """Get bitmask for red, green and blue channel
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             if fi.FreeImage_GetColorType(self._dib) != fi.FIC_RGB:
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_8rgb_mask___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":976
 *         """
 *         def __get__(self):
 *             self._check_closed()             # <<<<<<<<<<<<<<
 *             if fi.FreeImage_GetColorType(self._dib) != fi.FIC_RGB:
 *                 return None
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":977
 *         def __get__(self):
 *             self._check_closed()
 *             if fi.FreeImage_GetColorType(self._dib) != fi.FIC_RGB:             # <<<<<<<<<<<<<<
 *                 return None
 *             return (fi.FreeImage_GetRedMask(self._dib),
 */
  __pyx_t_2 = (FreeImage_GetColorType(__pyx_v_self->_dib) != FIC_RGB);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":978
 *             self._check_closed()
 *             if fi.FreeImage_GetColorType(self._dib) != fi.FIC_RGB:
 *                 return None             # <<<<<<<<<<<<<<
 *             return (fi.FreeImage_GetRedMask(self._dib),
 *                     fi.FreeImage_GetGreenMask(self._dib),
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":979
 *             if fi.FreeImage_GetColorType(self._dib) != fi.FIC_RGB:
 *                 return None
 *             return (fi.FreeImage_GetRedMask(self._dib),             # <<<<<<<<<<<<<<
 *                     fi.FreeImage_GetGreenMask(self._dib),
 *                     fi.FreeImage_GetBlueMask(self._dib))
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(FreeImage_GetRedMask(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "smc/freeimage/_freeimage.pyx":980
 *                 return None
 *             return (fi.FreeImage_GetRedMask(self._dib),
 *                     fi.FreeImage_GetGreenMask(self._dib),             # <<<<<<<<<<<<<<
 *                     fi.FreeImage_GetBlueMask(self._dib))
 * 
 */
  __pyx_t_3 = PyLong_FromUnsignedLong(FreeImage_GetGreenMask(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "smc/freeimage/_freeimage.pyx":981
 *             return (fi.FreeImage_GetRedMask(self._dib),
 *                     fi.FreeImage_GetGreenMask(self._dib),
 *                     fi.FreeImage_GetBlueMask(self._dib))             # <<<<<<<<<<<<<<
 * 
 *     property colororder:
 */
  __pyx_t_4 = PyLong_FromUnsignedLong(FreeImage_GetBlueMask(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = ((PyObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.rgb_mask.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_10colororder_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_10colororder_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_10colororder___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":988
 *         The color order depends on the endianess of the system
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if fi.FREEIMAGE_COLORORDER == fi.FREEIMAGE_COLORORDER_BGR:
 *                 return "BGR"
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_10colororder___get__(CYTHON_UNUSED struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":989
 *         """
 *         def __get__(self):
 *             if fi.FREEIMAGE_COLORORDER == fi.FREEIMAGE_COLORORDER_BGR:             # <<<<<<<<<<<<<<
 *                 return "BGR"
 *             else:
 */
  __pyx_t_1 = (FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":990
 *         def __get__(self):
 *             if fi.FREEIMAGE_COLORORDER == fi.FREEIMAGE_COLORORDER_BGR:
 *                 return "BGR"             # <<<<<<<<<<<<<<
 *             else:
 *                 return "RGB"
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__BGR));
    __pyx_r = ((PyObject *)__pyx_n_s__BGR);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":992
 *                 return "BGR"
 *             else:
 *                 return "RGB"             # <<<<<<<<<<<<<<
 * 
 *     property has_pixels:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__RGB));
    __pyx_r = ((PyObject *)__pyx_n_s__RGB);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_10has_pixels_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_10has_pixels_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_10has_pixels___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":999
 *         @return: True if image has pixel and isn't loaded with fi.FIF_LOAD_NOPIXELS
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return bool(fi.FreeImage_HasPixels(self._dib))
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_10has_pixels___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1000
 *         """
 *         def __get__(self):
 *             return bool(fi.FreeImage_HasPixels(self._dib))             # <<<<<<<<<<<<<<
 * 
 *     property closed:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(FreeImage_HasPixels(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.has_pixels.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_6closed_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_6closed_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_6closed___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1005
 *         """closed -> bool
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._dib == NULL
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_6closed___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1006
 *         """
 *         def __get__(self):
 *             return self._dib == NULL             # <<<<<<<<<<<<<<
 * 
 *     # **********************************************************************
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->_dib == NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.closed.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_15floodfill(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_14floodfill[] = "floodfill(red, green, blue) -> None\n\n        Fill the entire image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_15floodfill(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_red;
  int __pyx_v_green;
  int __pyx_v_blue;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__red,&__pyx_n_s__green,&__pyx_n_s__blue,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("floodfill (wrapper)", 0);
  {
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__red);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__green);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("floodfill", 1, 3, 3, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__blue);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("floodfill", 1, 3, 3, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "floodfill") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_red = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_red == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_green = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_green == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_blue = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_blue == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("floodfill", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.floodfill", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_14floodfill(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_red, __pyx_v_green, __pyx_v_blue);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1010
 *     # **********************************************************************
 *     # fill with colors
 *     def floodfill(self, int red, int green, int blue):             # <<<<<<<<<<<<<<
 *         """floodfill(red, green, blue) -> None
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_14floodfill(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_red, int __pyx_v_green, int __pyx_v_blue) {
  int __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("floodfill", 0);

  /* "smc/freeimage/_freeimage.pyx":1015
 *         Fill the entire image
 *         """
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         result = floodfill(self._dib, red, green, blue, 0)
 *         if result == ERR_ARG:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1016
 *         """
 *         self._check_closed()
 *         result = floodfill(self._dib, red, green, blue, 0)             # <<<<<<<<<<<<<<
 *         if result == ERR_ARG:
 *             raise ValueError("Wrong arguments, colors must be between 0% and 100%")
 */
  __pyx_v_result = __pyx_f_3smc_9freeimage_10_freeimage_floodfill(__pyx_v_self->_dib, __pyx_v_red, __pyx_v_green, __pyx_v_blue, 0);

  /* "smc/freeimage/_freeimage.pyx":1017
 *         self._check_closed()
 *         result = floodfill(self._dib, red, green, blue, 0)
 *         if result == ERR_ARG:             # <<<<<<<<<<<<<<
 *             raise ValueError("Wrong arguments, colors must be between 0% and 100%")
 *         if result == ERR_UNSUP:
 */
  __pyx_t_2 = (__pyx_v_result == -1);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1018
 *         result = floodfill(self._dib, red, green, blue, 0)
 *         if result == ERR_ARG:
 *             raise ValueError("Wrong arguments, colors must be between 0% and 100%")             # <<<<<<<<<<<<<<
 *         if result == ERR_UNSUP:
 *             raise NotImplementedError("floodfill for type: %i, bpp:  %i" %
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_77), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1019
 *         if result == ERR_ARG:
 *             raise ValueError("Wrong arguments, colors must be between 0% and 100%")
 *         if result == ERR_UNSUP:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError("floodfill for type: %i, bpp:  %i" %
 *                 (fi.FreeImage_GetImageType(self._dib), self.bpp))
 */
  __pyx_t_2 = (__pyx_v_result == -2);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1021
 *         if result == ERR_UNSUP:
 *             raise NotImplementedError("floodfill for type: %i, bpp:  %i" %
 *                 (fi.FreeImage_GetImageType(self._dib), self.bpp))             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_1 = PyInt_FromLong(FreeImage_GetImageType(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__bpp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_78), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.floodfill", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_17save(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_16save[] = "save(filename[, format=-1[, flags=0]])\n\n        Save image to file\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_17save(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  int __pyx_v_format;
  int __pyx_v_flags;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__format,&__pyx_n_s__flags,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("save (wrapper)", 0);
  {
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "save") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[1]) {
      } else {
        __pyx_v_format = ((int)-1);
      }
      if (values[2]) {
      } else {
        __pyx_v_flags = ((int)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_filename = values[0];
    if (values[1]) {
      __pyx_v_format = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_format == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_format = ((int)-1);
    }
    if (values[2]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("save", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.save", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_16save(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_filename, __pyx_v_format, __pyx_v_flags);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1026
 *     # **********************************************************************
 *     # save
 *     def save(self, filename, int format=-1, int flags=0):             # <<<<<<<<<<<<<<
 *         """save(filename[, format=-1[, flags=0]])
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_16save(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, PyObject *__pyx_v_filename, int __pyx_v_format, int __pyx_v_flags) {
  BOOL __pyx_v_result;
  char *__pyx_v_cfilename;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("save", 0);
  __Pyx_INCREF(__pyx_v_filename);

  /* "smc/freeimage/_freeimage.pyx":1033
 *         cdef fi.BOOL result
 *         cdef char* cfilename
 *         self._check_closed()             # <<<<<<<<<<<<<<
 * 
 *         filename = _decodeFilename(filename)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1035
 *         self._check_closed()
 * 
 *         filename = _decodeFilename(filename)             # <<<<<<<<<<<<<<
 *         cfilename = <char*>filename
 *         if format == -1:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_filename);
  __pyx_v_filename = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1036
 * 
 *         filename = _decodeFilename(filename)
 *         cfilename = <char*>filename             # <<<<<<<<<<<<<<
 *         if format == -1:
 *             format = fi.FreeImage_GetFIFFromFilename(cfilename)
 */
  __pyx_t_2 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cfilename = ((char *)__pyx_t_2);

  /* "smc/freeimage/_freeimage.pyx":1037
 *         filename = _decodeFilename(filename)
 *         cfilename = <char*>filename
 *         if format == -1:             # <<<<<<<<<<<<<<
 *             format = fi.FreeImage_GetFIFFromFilename(cfilename)
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() - 1:
 */
  __pyx_t_3 = (__pyx_v_format == -1);
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":1038
 *         cfilename = <char*>filename
 *         if format == -1:
 *             format = fi.FreeImage_GetFIFFromFilename(cfilename)             # <<<<<<<<<<<<<<
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() - 1:
 *             raise ValueError("Invalid format %i" % format)
 */
    __pyx_v_format = FreeImage_GetFIFFromFilename(__pyx_v_cfilename);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1039
 *         if format == -1:
 *             format = fi.FreeImage_GetFIFFromFilename(cfilename)
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() - 1:             # <<<<<<<<<<<<<<
 *             raise ValueError("Invalid format %i" % format)
 *         with nogil:
 */
  __pyx_t_3 = (__pyx_v_format < 0);
  if (!__pyx_t_3) {
    __pyx_t_4 = (__pyx_v_format > (FreeImage_GetFIFCount() - 1));
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_3;
  }
  if (__pyx_t_5) {

    /* "smc/freeimage/_freeimage.pyx":1040
 *             format = fi.FreeImage_GetFIFFromFilename(cfilename)
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() - 1:
 *             raise ValueError("Invalid format %i" % format)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = fi.FreeImage_Save(<fi.FREE_IMAGE_FORMAT>format, self._dib,
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_79), __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_6));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":1041
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() - 1:
 *             raise ValueError("Invalid format %i" % format)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = fi.FreeImage_Save(<fi.FREE_IMAGE_FORMAT>format, self._dib,
 *                                        cfilename, flags)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1043
 *         with nogil:
 *             result = fi.FreeImage_Save(<fi.FREE_IMAGE_FORMAT>format, self._dib,
 *                                        cfilename, flags)             # <<<<<<<<<<<<<<
 *         if not result:
 *             raise dispatchFIError(SaveError, "Failed to save image to file '%s'" % filename)
 */
        __pyx_v_result = FreeImage_Save(((enum FREE_IMAGE_FORMAT)__pyx_v_format), __pyx_v_self->_dib, __pyx_v_cfilename, __pyx_v_flags);
      }

      /* "smc/freeimage/_freeimage.pyx":1041
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() - 1:
 *             raise ValueError("Invalid format %i" % format)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = fi.FreeImage_Save(<fi.FREE_IMAGE_FORMAT>format, self._dib,
 *                                        cfilename, flags)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1044
 *             result = fi.FreeImage_Save(<fi.FREE_IMAGE_FORMAT>format, self._dib,
 *                                        cfilename, flags)
 *         if not result:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(SaveError, "Failed to save image to file '%s'" % filename)
 * 
 */
  __pyx_t_5 = (!__pyx_v_result);
  if (__pyx_t_5) {

    /* "smc/freeimage/_freeimage.pyx":1045
 *                                        cfilename, flags)
 *         if not result:
 *             raise dispatchFIError(SaveError, "Failed to save image to file '%s'" % filename)             # <<<<<<<<<<<<<<
 * 
 *     def toBuffer(self, int format=-1, int flags=0):
 */
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__SaveError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_80), __pyx_v_filename); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_7));
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_t_7));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
    __pyx_t_1 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.save", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_filename);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_19toBuffer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_18toBuffer[] = "toBuffer([format=-1[, flags=0]] -> _MemoryIO instance\n    \n        Access raw data of the image as read-only buffer or file like object\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_19toBuffer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_format;
  int __pyx_v_flags;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__format,&__pyx_n_s__flags,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("toBuffer (wrapper)", 0);
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "toBuffer") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[0]) {
      } else {
        __pyx_v_format = ((int)-1);
      }
      if (values[1]) {
      } else {
        __pyx_v_flags = ((int)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_format = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_format == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_format = ((int)-1);
    }
    if (values[1]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("toBuffer", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.toBuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_18toBuffer(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_format, __pyx_v_flags);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1047
 *             raise dispatchFIError(SaveError, "Failed to save image to file '%s'" % filename)
 * 
 *     def toBuffer(self, int format=-1, int flags=0):             # <<<<<<<<<<<<<<
 *         """toBuffer([format=-1[, flags=0]] -> _MemoryIO instance
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_18toBuffer(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_format, int __pyx_v_flags) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("toBuffer", 0);

  /* "smc/freeimage/_freeimage.pyx":1052
 *         Access raw data of the image as read-only buffer or file like object
 *         """
 *         if smc_fi.IS_PYTHON3:             # <<<<<<<<<<<<<<
 *             raise NotImplementedError("tuBuffer() not implemented for 3.x yet")
 *         return _MemoryIO(self, format, flags)
 */
  if (IS_PYTHON3) {

    /* "smc/freeimage/_freeimage.pyx":1053
 *         """
 *         if smc_fi.IS_PYTHON3:
 *             raise NotImplementedError("tuBuffer() not implemented for 3.x yet")             # <<<<<<<<<<<<<<
 *         return _MemoryIO(self, format, flags)
 * 
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_82), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1054
 *         if smc_fi.IS_PYTHON3:
 *             raise NotImplementedError("tuBuffer() not implemented for 3.x yet")
 *         return _MemoryIO(self, format, flags)             # <<<<<<<<<<<<<<
 * 
 *     def toPIL(self, int format=-1, int flags=0):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage__MemoryIO)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.toBuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_21toPIL(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_20toPIL[] = "toPIL([format=-1[, flags=0]] -> PIL image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_21toPIL(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_format;
  int __pyx_v_flags;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__format,&__pyx_n_s__flags,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("toPIL (wrapper)", 0);
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "toPIL") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[0]) {
      } else {
        __pyx_v_format = ((int)-1);
      }
      if (values[1]) {
      } else {
        __pyx_v_flags = ((int)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_format = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_format == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_format = ((int)-1);
    }
    if (values[1]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("toPIL", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.toPIL", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_20toPIL(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_format, __pyx_v_flags);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1056
 *         return _MemoryIO(self, format, flags)
 * 
 *     def toPIL(self, int format=-1, int flags=0):             # <<<<<<<<<<<<<<
 *         """toPIL([format=-1[, flags=0]] -> PIL image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_20toPIL(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_format, int __pyx_v_flags) {
  PyObject *__pyx_v_pil_open = NULL;
  PyObject *__pyx_v_buffer = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("toPIL", 0);

  /* "smc/freeimage/_freeimage.pyx":1059
 *         """toPIL([format=-1[, flags=0]] -> PIL image
 *         """
 *         from PIL.Image import open as pil_open             # <<<<<<<<<<<<<<
 *         buffer = self.toBuffer(format, flags)
 *         return pil_open(buffer)
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__open));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__open));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__open));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_83), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__open);
  if (__pyx_t_1 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__open);
    if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_pil_open = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":1060
 *         """
 *         from PIL.Image import open as pil_open
 *         buffer = self.toBuffer(format, flags)             # <<<<<<<<<<<<<<
 *         return pil_open(buffer)
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__toBuffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_v_buffer = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "smc/freeimage/_freeimage.pyx":1061
 *         from PIL.Image import open as pil_open
 *         buffer = self.toBuffer(format, flags)
 *         return pil_open(buffer)             # <<<<<<<<<<<<<<
 * 
 *     # **********************************************************************
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_buffer);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_buffer);
  __Pyx_GIVEREF(__pyx_v_buffer);
  __pyx_t_4 = PyObject_Call(__pyx_v_pil_open, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.toPIL", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pil_open);
  __Pyx_XDECREF(__pyx_v_buffer);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_23resize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_22resize[] = "resize(width: int, height: int[, filter=FILTER_BOX]) -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_23resize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_width;
  int __pyx_v_height;
  int __pyx_v_filter;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__width,&__pyx_n_s__height,&__pyx_n_s__filter,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("resize (wrapper)", 0);
  {
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__width);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__height);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("resize", 0, 2, 3, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filter);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "resize") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[2]) {
      } else {
        __pyx_v_filter = __pyx_k_84;
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_width = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_width == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_height = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_height == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[2]) {
      __pyx_v_filter = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_filter == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_filter = __pyx_k_84;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("resize", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.resize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_22resize(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_width, __pyx_v_height, __pyx_v_filter);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1065
 *     # **********************************************************************
 *     # scale
 *     def resize(self, int width, int height, int filter=fi.FILTER_BOX):             # <<<<<<<<<<<<<<
 *         """resize(width: int, height: int[, filter=FILTER_BOX]) -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_22resize(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_width, int __pyx_v_height, int __pyx_v_filter) {
  FIBITMAP *__pyx_v_dib;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("resize", 0);

  /* "smc/freeimage/_freeimage.pyx":1071
 *         cdef Image new
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             dib = fi.FreeImage_Rescale(self._dib, width, height, <fi.FREE_IMAGE_FILTER>filter)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1072
 * 
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Rescale(self._dib, width, height, <fi.FREE_IMAGE_FILTER>filter)
 *         if dib == NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1073
 *         self._check_closed()
 *         with nogil:
 *             dib = fi.FreeImage_Rescale(self._dib, width, height, <fi.FREE_IMAGE_FILTER>filter)             # <<<<<<<<<<<<<<
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to resize image")
 */
        __pyx_v_dib = FreeImage_Rescale(__pyx_v_self->_dib, __pyx_v_width, __pyx_v_height, ((enum FREE_IMAGE_FILTER)__pyx_v_filter));
      }

      /* "smc/freeimage/_freeimage.pyx":1072
 * 
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Rescale(self._dib, width, height, <fi.FREE_IMAGE_FILTER>filter)
 *         if dib == NULL:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1074
 *         with nogil:
 *             dib = fi.FreeImage_Rescale(self._dib, width, height, <fi.FREE_IMAGE_FILTER>filter)
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to resize image")
 *         return Image(_bitmap=DibWrapper(dib, self))
 */
  __pyx_t_2 = (__pyx_v_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1075
 *             dib = fi.FreeImage_Rescale(self._dib, width, height, <fi.FREE_IMAGE_FILTER>filter)
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to resize image")             # <<<<<<<<<<<<<<
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_85));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_85));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_85));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":1076
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to resize image")
 *         return Image(_bitmap=DibWrapper(dib, self))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, ((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.resize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_25paste(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_24paste[] = "paste(src: Image, left: int, top: int[, alpha=256]) -> None\n\n        Paste source image into this image.\n\n        alpha: 0 to 255 for alpha blending or 256 for combination.\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_25paste(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_src = 0;
  unsigned int __pyx_v_left;
  unsigned int __pyx_v_top;
  unsigned int __pyx_v_alpha;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__src,&__pyx_n_s__left,&__pyx_n_s__top,&__pyx_n_s__alpha,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("paste (wrapper)", 0);
  {
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__src);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__left);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("paste", 0, 3, 4, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__top);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("paste", 0, 3, 4, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "paste") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[3]) {
      } else {
        __pyx_v_alpha = ((unsigned int)256);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_src = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)values[0]);
    __pyx_v_left = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_left == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_top = __Pyx_PyInt_AsUnsignedInt(values[2]); if (unlikely((__pyx_v_top == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[3]) {
      __pyx_v_alpha = __Pyx_PyInt_AsUnsignedInt(values[3]); if (unlikely((__pyx_v_alpha == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_alpha = ((unsigned int)256);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("paste", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.paste", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_src), __pyx_ptype_3smc_9freeimage_10_freeimage_Image, 0, "src", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_24paste(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_src, __pyx_v_left, __pyx_v_top, __pyx_v_alpha);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1082
 *     # Copy / Paste / Crop
 * 
 *     def paste(self, Image src not None, unsigned left, unsigned top, unsigned alpha = 256):             # <<<<<<<<<<<<<<
 *         """paste(src: Image, left: int, top: int[, alpha=256]) -> None
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_24paste(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_src, unsigned int __pyx_v_left, unsigned int __pyx_v_top, unsigned int __pyx_v_alpha) {
  int __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("paste", 0);

  /* "smc/freeimage/_freeimage.pyx":1090
 *         """
 *         cdef int result
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         if src._dib == NULL:
 *             raise IOError("Operation on closed source image")
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1091
 *         cdef int result
 *         self._check_closed()
 *         if src._dib == NULL:             # <<<<<<<<<<<<<<
 *             raise IOError("Operation on closed source image")
 *         with nogil:
 */
  __pyx_t_2 = (__pyx_v_src->_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1092
 *         self._check_closed()
 *         if src._dib == NULL:
 *             raise IOError("Operation on closed source image")             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = fi.FreeImage_Paste(self._dib, src._dib, left, top, alpha)
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_87), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1093
 *         if src._dib == NULL:
 *             raise IOError("Operation on closed source image")
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = fi.FreeImage_Paste(self._dib, src._dib, left, top, alpha)
 *         if not result:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1094
 *             raise IOError("Operation on closed source image")
 *         with nogil:
 *             result = fi.FreeImage_Paste(self._dib, src._dib, left, top, alpha)             # <<<<<<<<<<<<<<
 *         if not result:
 *             raise dispatchFIError(OperationError, "Failed to paste image")
 */
        __pyx_v_result = FreeImage_Paste(__pyx_v_self->_dib, __pyx_v_src->_dib, __pyx_v_left, __pyx_v_top, __pyx_v_alpha);
      }

      /* "smc/freeimage/_freeimage.pyx":1093
 *         if src._dib == NULL:
 *             raise IOError("Operation on closed source image")
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = fi.FreeImage_Paste(self._dib, src._dib, left, top, alpha)
 *         if not result:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1095
 *         with nogil:
 *             result = fi.FreeImage_Paste(self._dib, src._dib, left, top, alpha)
 *         if not result:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to paste image")
 * 
 */
  __pyx_t_2 = (!__pyx_v_result);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1096
 *             result = fi.FreeImage_Paste(self._dib, src._dib, left, top, alpha)
 *         if not result:
 *             raise dispatchFIError(OperationError, "Failed to paste image")             # <<<<<<<<<<<<<<
 * 
 *     def clone(self):
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_88));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_88));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_88));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.paste", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_27clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_26clone[] = "clone() -> new image\n\n        @note: clone uses low level FI functions to clone metadata and ICC, too.\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_27clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clone (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_26clone(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1098
 *             raise dispatchFIError(OperationError, "Failed to paste image")
 * 
 *     def clone(self):             # <<<<<<<<<<<<<<
 *         """clone() -> new image
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_26clone(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  FIBITMAP *__pyx_v_dib;
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_clone = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clone", 0);

  /* "smc/freeimage/_freeimage.pyx":1105
 *         cdef fi.FIBITMAP* dib
 *         cdef Image clone
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             dib = fi.FreeImage_Clone(self._dib)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1106
 *         cdef Image clone
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Clone(self._dib)
 *         if dib == NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1107
 *         self._check_closed()
 *         with nogil:
 *             dib = fi.FreeImage_Clone(self._dib)             # <<<<<<<<<<<<<<
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to clone image")
 */
        __pyx_v_dib = FreeImage_Clone(__pyx_v_self->_dib);
      }

      /* "smc/freeimage/_freeimage.pyx":1106
 *         cdef Image clone
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Clone(self._dib)
 *         if dib == NULL:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1108
 *         with nogil:
 *             dib = fi.FreeImage_Clone(self._dib)
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to clone image")
 *         clone = Image(_bitmap=DibWrapper(dib, self))
 */
  __pyx_t_2 = (__pyx_v_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1109
 *             dib = fi.FreeImage_Clone(self._dib)
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to clone image")             # <<<<<<<<<<<<<<
 *         clone = Image(_bitmap=DibWrapper(dib, self))
 *         clone._filename = self._filename
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_89));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_89));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_89));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":1110
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to clone image")
 *         clone = Image(_bitmap=DibWrapper(dib, self))             # <<<<<<<<<<<<<<
 *         clone._filename = self._filename
 *         return clone
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, ((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_clone = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "smc/freeimage/_freeimage.pyx":1111
 *             raise dispatchFIError(OperationError, "Failed to clone image")
 *         clone = Image(_bitmap=DibWrapper(dib, self))
 *         clone._filename = self._filename             # <<<<<<<<<<<<<<
 *         return clone
 * 
 */
  __pyx_v_clone->_filename = __pyx_v_self->_filename;

  /* "smc/freeimage/_freeimage.pyx":1112
 *         clone = Image(_bitmap=DibWrapper(dib, self))
 *         clone._filename = self._filename
 *         return clone             # <<<<<<<<<<<<<<
 * 
 *     def crop(self, int left, int top, int right, int bottom):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_clone));
  __pyx_r = ((PyObject *)__pyx_v_clone);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_clone);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_29crop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_28crop[] = "crop(left: int, top: int, right: int, bottom: int) -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_29crop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_left;
  int __pyx_v_top;
  int __pyx_v_right;
  int __pyx_v_bottom;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__left,&__pyx_n_s__top,&__pyx_n_s__right,&__pyx_n_s__bottom,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("crop (wrapper)", 0);
  {
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__left);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__top);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("crop", 1, 4, 4, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__right);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("crop", 1, 4, 4, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bottom);
        if (likely(values[3])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("crop", 1, 4, 4, 3); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "crop") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_left = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_left == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_top = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_top == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_right = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_right == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_bottom = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_bottom == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("crop", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.crop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_28crop(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_left, __pyx_v_top, __pyx_v_right, __pyx_v_bottom);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1114
 *         return clone
 * 
 *     def crop(self, int left, int top, int right, int bottom):             # <<<<<<<<<<<<<<
 *         """crop(left: int, top: int, right: int, bottom: int) -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_28crop(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_left, int __pyx_v_top, int __pyx_v_right, int __pyx_v_bottom) {
  FIBITMAP *__pyx_v_dib;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("crop", 0);

  /* "smc/freeimage/_freeimage.pyx":1120
 *         cdef Image new
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         if right == -1 and bottom == -1:
 *             right = self.width
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1121
 * 
 *         self._check_closed()
 *         if right == -1 and bottom == -1:             # <<<<<<<<<<<<<<
 *             right = self.width
 *             bottom = self.height
 */
  __pyx_t_2 = (__pyx_v_right == -1);
  if (__pyx_t_2) {
    __pyx_t_3 = (__pyx_v_bottom == -1);
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1122
 *         self._check_closed()
 *         if right == -1 and bottom == -1:
 *             right = self.width             # <<<<<<<<<<<<<<
 *             bottom = self.height
 *         if left < 0 or top < 0 or right < 0 or bottom < 0:
 */
    __pyx_v_right = __pyx_v_self->width;

    /* "smc/freeimage/_freeimage.pyx":1123
 *         if right == -1 and bottom == -1:
 *             right = self.width
 *             bottom = self.height             # <<<<<<<<<<<<<<
 *         if left < 0 or top < 0 or right < 0 or bottom < 0:
 *             raise ValueError("Boundaries must be larger than 0")
 */
    __pyx_v_bottom = __pyx_v_self->height;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1124
 *             right = self.width
 *             bottom = self.height
 *         if left < 0 or top < 0 or right < 0 or bottom < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("Boundaries must be larger than 0")
 *         # XXX more checks
 */
  __pyx_t_4 = (__pyx_v_left < 0);
  if (!__pyx_t_4) {
    __pyx_t_2 = (__pyx_v_top < 0);
    if (!__pyx_t_2) {
      __pyx_t_3 = (__pyx_v_right < 0);
      if (!__pyx_t_3) {
        __pyx_t_5 = (__pyx_v_bottom < 0);
        __pyx_t_6 = __pyx_t_5;
      } else {
        __pyx_t_6 = __pyx_t_3;
      }
      __pyx_t_3 = __pyx_t_6;
    } else {
      __pyx_t_3 = __pyx_t_2;
    }
    __pyx_t_2 = __pyx_t_3;
  } else {
    __pyx_t_2 = __pyx_t_4;
  }
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1125
 *             bottom = self.height
 *         if left < 0 or top < 0 or right < 0 or bottom < 0:
 *             raise ValueError("Boundaries must be larger than 0")             # <<<<<<<<<<<<<<
 *         # XXX more checks
 *         with nogil:
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_91), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":1127
 *             raise ValueError("Boundaries must be larger than 0")
 *         # XXX more checks
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Copy(self._dib, left, top, right, bottom)
 *         if dib == NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1128
 *         # XXX more checks
 *         with nogil:
 *             dib = fi.FreeImage_Copy(self._dib, left, top, right, bottom)             # <<<<<<<<<<<<<<
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to copy image")
 */
        __pyx_v_dib = FreeImage_Copy(__pyx_v_self->_dib, __pyx_v_left, __pyx_v_top, __pyx_v_right, __pyx_v_bottom);
      }

      /* "smc/freeimage/_freeimage.pyx":1127
 *             raise ValueError("Boundaries must be larger than 0")
 *         # XXX more checks
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Copy(self._dib, left, top, right, bottom)
 *         if dib == NULL:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1129
 *         with nogil:
 *             dib = fi.FreeImage_Copy(self._dib, left, top, right, bottom)
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to copy image")
 *         # we are not interested in ICC profiles in cropped images
 */
  __pyx_t_2 = (__pyx_v_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1130
 *             dib = fi.FreeImage_Copy(self._dib, left, top, right, bottom)
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to copy image")             # <<<<<<<<<<<<<<
 *         # we are not interested in ICC profiles in cropped images
 *         removeAllMetadata(dib);
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_92));
    PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_kp_s_92));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_92));
    __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "smc/freeimage/_freeimage.pyx":1132
 *             raise dispatchFIError(OperationError, "Failed to copy image")
 *         # we are not interested in ICC profiles in cropped images
 *         removeAllMetadata(dib);             # <<<<<<<<<<<<<<
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 */
  __pyx_f_3smc_9freeimage_10_freeimage_removeAllMetadata(__pyx_v_dib);

  /* "smc/freeimage/_freeimage.pyx":1133
 *         # we are not interested in ICC profiles in cropped images
 *         removeAllMetadata(dib);
 *         return Image(_bitmap=DibWrapper(dib, self))             # <<<<<<<<<<<<<<
 * 
 *     # **********************************************************************
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  __pyx_t_8 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, ((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_8;
  __pyx_t_8 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.crop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1138
 *     # convert
 * 
 *     cdef Image convert_helper(self, FI_ConvertFunction conv):             # <<<<<<<<<<<<<<
 *         cdef fi.FIBITMAP* dib
 *         cdef Image new
 */

static struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_f_3smc_9freeimage_10_freeimage_5Image_convert_helper(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, FI_ConvertFunction __pyx_v_conv) {
  FIBITMAP *__pyx_v_dib;
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_helper", 0);

  /* "smc/freeimage/_freeimage.pyx":1142
 *         cdef Image new
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             dib = conv(self._dib)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1143
 * 
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = conv(self._dib)
 *         if dib == NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1144
 *         self._check_closed()
 *         with nogil:
 *             dib = conv(self._dib)             # <<<<<<<<<<<<<<
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to convert image")
 */
        __pyx_v_dib = __pyx_v_conv(__pyx_v_self->_dib);
      }

      /* "smc/freeimage/_freeimage.pyx":1143
 * 
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = conv(self._dib)
 *         if dib == NULL:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1145
 *         with nogil:
 *             dib = conv(self._dib)
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to convert image")
 *         return Image(_bitmap=DibWrapper(dib, self))
 */
  __pyx_t_2 = (__pyx_v_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1146
 *             dib = conv(self._dib)
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to convert image")             # <<<<<<<<<<<<<<
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_93));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_93));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_93));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":1147
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to convert image")
 *         return Image(_bitmap=DibWrapper(dib, self))             # <<<<<<<<<<<<<<
 * 
 *     def convert_4bits(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, ((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.convert_helper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_31convert_4bits(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_30convert_4bits[] = "convert_4bits() -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_31convert_4bits(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convert_4bits (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_30convert_4bits(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1149
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 *     def convert_4bits(self):             # <<<<<<<<<<<<<<
 *         """convert_4bits() -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_30convert_4bits(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_4bits", 0);

  /* "smc/freeimage/_freeimage.pyx":1152
 *         """convert_4bits() -> new image
 *         """
 *         return self.convert_helper(fi.FreeImage_ConvertTo4Bits)             # <<<<<<<<<<<<<<
 * 
 *     def convert_8bits(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->convert_helper(__pyx_v_self, FreeImage_ConvertTo4Bits)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.convert_4bits", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_33convert_8bits(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_32convert_8bits[] = "convert_8bits() -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_33convert_8bits(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convert_8bits (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_32convert_8bits(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1154
 *         return self.convert_helper(fi.FreeImage_ConvertTo4Bits)
 * 
 *     def convert_8bits(self):             # <<<<<<<<<<<<<<
 *         """convert_8bits() -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_32convert_8bits(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_8bits", 0);

  /* "smc/freeimage/_freeimage.pyx":1157
 *         """convert_8bits() -> new image
 *         """
 *         return self.convert_helper(fi.FreeImage_ConvertTo8Bits)             # <<<<<<<<<<<<<<
 * 
 *     def greyscale(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->convert_helper(__pyx_v_self, FreeImage_ConvertTo8Bits)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.convert_8bits", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_35greyscale(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_34greyscale[] = "greyscale() -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_35greyscale(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("greyscale (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_34greyscale(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1159
 *         return self.convert_helper(fi.FreeImage_ConvertTo8Bits)
 * 
 *     def greyscale(self):             # <<<<<<<<<<<<<<
 *         """greyscale() -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_34greyscale(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("greyscale", 0);

  /* "smc/freeimage/_freeimage.pyx":1162
 *         """greyscale() -> new image
 *         """
 *         return self.convert_helper(fi.FreeImage_ConvertToGreyscale)             # <<<<<<<<<<<<<<
 * 
 *     def convert_16bits555(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->convert_helper(__pyx_v_self, FreeImage_ConvertToGreyscale)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.greyscale", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_37convert_16bits555(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_36convert_16bits555[] = "convert_16bits555() -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_37convert_16bits555(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convert_16bits555 (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_36convert_16bits555(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1164
 *         return self.convert_helper(fi.FreeImage_ConvertToGreyscale)
 * 
 *     def convert_16bits555(self):             # <<<<<<<<<<<<<<
 *         """convert_16bits555() -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_36convert_16bits555(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_16bits555", 0);

  /* "smc/freeimage/_freeimage.pyx":1167
 *         """convert_16bits555() -> new image
 *         """
 *         return self.convert_helper(fi.FreeImage_ConvertTo16Bits555)             # <<<<<<<<<<<<<<
 * 
 *     def convert_16bits565(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->convert_helper(__pyx_v_self, FreeImage_ConvertTo16Bits555)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.convert_16bits555", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_39convert_16bits565(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_38convert_16bits565[] = "convert_16bits565() -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_39convert_16bits565(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convert_16bits565 (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_38convert_16bits565(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1169
 *         return self.convert_helper(fi.FreeImage_ConvertTo16Bits555)
 * 
 *     def convert_16bits565(self):             # <<<<<<<<<<<<<<
 *         """convert_16bits565() -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_38convert_16bits565(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_16bits565", 0);

  /* "smc/freeimage/_freeimage.pyx":1172
 *         """convert_16bits565() -> new image
 *         """
 *         return self.convert_helper(fi.FreeImage_ConvertTo16Bits565)             # <<<<<<<<<<<<<<
 * 
 *     def convert_24bits(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->convert_helper(__pyx_v_self, FreeImage_ConvertTo16Bits565)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.convert_16bits565", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_41convert_24bits(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_40convert_24bits[] = "convert_24bits() -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_41convert_24bits(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convert_24bits (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_40convert_24bits(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1174
 *         return self.convert_helper(fi.FreeImage_ConvertTo16Bits565)
 * 
 *     def convert_24bits(self):             # <<<<<<<<<<<<<<
 *         """convert_24bits() -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_40convert_24bits(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_24bits", 0);

  /* "smc/freeimage/_freeimage.pyx":1177
 *         """convert_24bits() -> new image
 *         """
 *         return self.convert_helper(fi.FreeImage_ConvertTo24Bits)             # <<<<<<<<<<<<<<
 * 
 *     def convert_32bits(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->convert_helper(__pyx_v_self, FreeImage_ConvertTo24Bits)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.convert_24bits", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_43convert_32bits(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_42convert_32bits[] = "convert_32bits() -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_43convert_32bits(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convert_32bits (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_42convert_32bits(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1179
 *         return self.convert_helper(fi.FreeImage_ConvertTo24Bits)
 * 
 *     def convert_32bits(self):             # <<<<<<<<<<<<<<
 *         """convert_32bits() -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_42convert_32bits(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_32bits", 0);

  /* "smc/freeimage/_freeimage.pyx":1182
 *         """convert_32bits() -> new image
 *         """
 *         return self.convert_helper(fi.FreeImage_ConvertTo32Bits)             # <<<<<<<<<<<<<<
 * 
 *     def convert_rgbf(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->convert_helper(__pyx_v_self, FreeImage_ConvertTo32Bits)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.convert_32bits", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_45convert_rgbf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_44convert_rgbf[] = "convert_rgbf() -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_45convert_rgbf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convert_rgbf (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_44convert_rgbf(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1184
 *         return self.convert_helper(fi.FreeImage_ConvertTo32Bits)
 * 
 *     def convert_rgbf(self):             # <<<<<<<<<<<<<<
 *         """convert_rgbf() -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_44convert_rgbf(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_rgbf", 0);

  /* "smc/freeimage/_freeimage.pyx":1187
 *         """convert_rgbf() -> new image
 *         """
 *         return self.convert_helper(fi.FreeImage_ConvertToRGBF)             # <<<<<<<<<<<<<<
 * 
 *     def to_standard(self, bint scale_linear=True):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->convert_helper(__pyx_v_self, FreeImage_ConvertToRGBF)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.convert_rgbf", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_47to_standard(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_46to_standard[] = "to_standard([scale_linear=True]) -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_47to_standard(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_scale_linear;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__scale_linear,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_standard (wrapper)", 0);
  {
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scale_linear);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "to_standard") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[0]) {
      } else {

        /* "smc/freeimage/_freeimage.pyx":1189
 *         return self.convert_helper(fi.FreeImage_ConvertToRGBF)
 * 
 *     def to_standard(self, bint scale_linear=True):             # <<<<<<<<<<<<<<
 *         """to_standard([scale_linear=True]) -> new image
 *         """
 */
        __pyx_v_scale_linear = ((int)1);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_scale_linear = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_scale_linear == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_scale_linear = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("to_standard", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.to_standard", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_46to_standard(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_scale_linear);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_46to_standard(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_scale_linear) {
  FIBITMAP *__pyx_v_dib;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_standard", 0);

  /* "smc/freeimage/_freeimage.pyx":1195
 *         cdef Image new
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             dib = fi.FreeImage_ConvertToStandardType(self._dib, scale_linear)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1196
 * 
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_ConvertToStandardType(self._dib, scale_linear)
 *         if dib == NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1197
 *         self._check_closed()
 *         with nogil:
 *             dib = fi.FreeImage_ConvertToStandardType(self._dib, scale_linear)             # <<<<<<<<<<<<<<
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to convert image")
 */
        __pyx_v_dib = FreeImage_ConvertToStandardType(__pyx_v_self->_dib, __pyx_v_scale_linear);
      }

      /* "smc/freeimage/_freeimage.pyx":1196
 * 
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_ConvertToStandardType(self._dib, scale_linear)
 *         if dib == NULL:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1198
 *         with nogil:
 *             dib = fi.FreeImage_ConvertToStandardType(self._dib, scale_linear)
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to convert image")
 *         return Image(_bitmap=DibWrapper(dib, self))
 */
  __pyx_t_2 = (__pyx_v_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1199
 *             dib = fi.FreeImage_ConvertToStandardType(self._dib, scale_linear)
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to convert image")             # <<<<<<<<<<<<<<
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_93));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_93));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_93));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":1200
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to convert image")
 *         return Image(_bitmap=DibWrapper(dib, self))             # <<<<<<<<<<<<<<
 * 
 *     def to_type(self, unsigned dst_type, bint scale_linear=True):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, ((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.to_standard", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_49to_type(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_48to_type[] = "to_type(dst_type[, scale_linear=True]) -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_49to_type(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  unsigned int __pyx_v_dst_type;
  int __pyx_v_scale_linear;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__dst_type,&__pyx_n_s__scale_linear,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("to_type (wrapper)", 0);
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dst_type);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scale_linear);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "to_type") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[1]) {
      } else {

        /* "smc/freeimage/_freeimage.pyx":1202
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 *     def to_type(self, unsigned dst_type, bint scale_linear=True):             # <<<<<<<<<<<<<<
 *         """to_type(dst_type[, scale_linear=True]) -> new image
 *         """
 */
        __pyx_v_scale_linear = ((int)1);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dst_type = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_dst_type == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[1]) {
      __pyx_v_scale_linear = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_scale_linear == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_scale_linear = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("to_type", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.to_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_48to_type(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_dst_type, __pyx_v_scale_linear);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_48to_type(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_dst_type, int __pyx_v_scale_linear) {
  FIBITMAP *__pyx_v_dib;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_type", 0);

  /* "smc/freeimage/_freeimage.pyx":1208
 *         cdef Image new
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             dib = fi.FreeImage_ConvertToType(self._dib, <fi.FREE_IMAGE_TYPE>dst_type, scale_linear)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1209
 * 
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_ConvertToType(self._dib, <fi.FREE_IMAGE_TYPE>dst_type, scale_linear)
 *         if dib == NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1210
 *         self._check_closed()
 *         with nogil:
 *             dib = fi.FreeImage_ConvertToType(self._dib, <fi.FREE_IMAGE_TYPE>dst_type, scale_linear)             # <<<<<<<<<<<<<<
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to convert image")
 */
        __pyx_v_dib = FreeImage_ConvertToType(__pyx_v_self->_dib, ((enum FREE_IMAGE_TYPE)__pyx_v_dst_type), __pyx_v_scale_linear);
      }

      /* "smc/freeimage/_freeimage.pyx":1209
 * 
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_ConvertToType(self._dib, <fi.FREE_IMAGE_TYPE>dst_type, scale_linear)
 *         if dib == NULL:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1211
 *         with nogil:
 *             dib = fi.FreeImage_ConvertToType(self._dib, <fi.FREE_IMAGE_TYPE>dst_type, scale_linear)
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to convert image")
 *         return Image(_bitmap=DibWrapper(dib, self))
 */
  __pyx_t_2 = (__pyx_v_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1212
 *             dib = fi.FreeImage_ConvertToType(self._dib, <fi.FREE_IMAGE_TYPE>dst_type, scale_linear)
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to convert image")             # <<<<<<<<<<<<<<
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_93));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_93));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_93));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":1213
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to convert image")
 *         return Image(_bitmap=DibWrapper(dib, self))             # <<<<<<<<<<<<<<
 * 
 *     def dither(self, unsigned dither_alg):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, ((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.to_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_51dither(PyObject *__pyx_v_self, PyObject *__pyx_arg_dither_alg); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_50dither[] = "dither(dither_alg) -> new image\n\n        Converts a bitmap to 1-bit monochrome bitmap using a dithering algorithm.\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_51dither(PyObject *__pyx_v_self, PyObject *__pyx_arg_dither_alg) {
  unsigned int __pyx_v_dither_alg;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dither (wrapper)", 0);
  assert(__pyx_arg_dither_alg); {
    __pyx_v_dither_alg = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_dither_alg); if (unlikely((__pyx_v_dither_alg == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dither", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_50dither(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), ((unsigned int)__pyx_v_dither_alg));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1215
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 *     def dither(self, unsigned dither_alg):             # <<<<<<<<<<<<<<
 *         """dither(dither_alg) -> new image
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_50dither(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_dither_alg) {
  FIBITMAP *__pyx_v_dib;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dither", 0);

  /* "smc/freeimage/_freeimage.pyx":1223
 *         cdef Image new
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             dib = fi.FreeImage_Dither(self._dib, <fi.FREE_IMAGE_DITHER>dither_alg)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1224
 * 
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Dither(self._dib, <fi.FREE_IMAGE_DITHER>dither_alg)
 *         if dib == NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1225
 *         self._check_closed()
 *         with nogil:
 *             dib = fi.FreeImage_Dither(self._dib, <fi.FREE_IMAGE_DITHER>dither_alg)             # <<<<<<<<<<<<<<
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to dither image")
 */
        __pyx_v_dib = FreeImage_Dither(__pyx_v_self->_dib, ((enum FREE_IMAGE_DITHER)__pyx_v_dither_alg));
      }

      /* "smc/freeimage/_freeimage.pyx":1224
 * 
 *         self._check_closed()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Dither(self._dib, <fi.FREE_IMAGE_DITHER>dither_alg)
 *         if dib == NULL:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1226
 *         with nogil:
 *             dib = fi.FreeImage_Dither(self._dib, <fi.FREE_IMAGE_DITHER>dither_alg)
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to dither image")
 *         return Image(_bitmap=DibWrapper(dib, self))
 */
  __pyx_t_2 = (__pyx_v_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1227
 *             dib = fi.FreeImage_Dither(self._dib, <fi.FREE_IMAGE_DITHER>dither_alg)
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to dither image")             # <<<<<<<<<<<<<<
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_94));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_94));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_94));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":1228
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to dither image")
 *         return Image(_bitmap=DibWrapper(dib, self))             # <<<<<<<<<<<<<<
 * 
 *     def threshold(self, unsigned threshold):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, ((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.dither", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_53threshold(PyObject *__pyx_v_self, PyObject *__pyx_arg_threshold); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_52threshold[] = "threshold(threshold: int) -> new image\n\n        Converts a bitmap to 1-bit monochrome bitmap\n\n        @param threshold: 0 to 255\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_53threshold(PyObject *__pyx_v_self, PyObject *__pyx_arg_threshold) {
  unsigned int __pyx_v_threshold;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("threshold (wrapper)", 0);
  assert(__pyx_arg_threshold); {
    __pyx_v_threshold = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_threshold); if (unlikely((__pyx_v_threshold == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1230; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.threshold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_52threshold(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), ((unsigned int)__pyx_v_threshold));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1230
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 *     def threshold(self, unsigned threshold):             # <<<<<<<<<<<<<<
 *         """threshold(threshold: int) -> new image
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_52threshold(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_threshold) {
  FIBITMAP *__pyx_v_dib;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("threshold", 0);

  /* "smc/freeimage/_freeimage.pyx":1240
 *         cdef Image new
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         if threshold > 255:
 *             raise ValueError("Threshold must be between 0 and 255")
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1241
 * 
 *         self._check_closed()
 *         if threshold > 255:             # <<<<<<<<<<<<<<
 *             raise ValueError("Threshold must be between 0 and 255")
 *         with nogil:
 */
  __pyx_t_2 = (__pyx_v_threshold > 255);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1242
 *         self._check_closed()
 *         if threshold > 255:
 *             raise ValueError("Threshold must be between 0 and 255")             # <<<<<<<<<<<<<<
 *         with nogil:
 *             dib = fi.FreeImage_Threshold(self._dib, <fi.BYTE>threshold)
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_96), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1243
 *         if threshold > 255:
 *             raise ValueError("Threshold must be between 0 and 255")
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Threshold(self._dib, <fi.BYTE>threshold)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1244
 *             raise ValueError("Threshold must be between 0 and 255")
 *         with nogil:
 *             dib = fi.FreeImage_Threshold(self._dib, <fi.BYTE>threshold)             # <<<<<<<<<<<<<<
 * 
 *         if dib == NULL:
 */
        __pyx_v_dib = FreeImage_Threshold(__pyx_v_self->_dib, ((BYTE)__pyx_v_threshold));
      }

      /* "smc/freeimage/_freeimage.pyx":1243
 *         if threshold > 255:
 *             raise ValueError("Threshold must be between 0 and 255")
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Threshold(self._dib, <fi.BYTE>threshold)
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1246
 *             dib = fi.FreeImage_Threshold(self._dib, <fi.BYTE>threshold)
 * 
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to applying threshold to image")
 *         return Image(_bitmap=DibWrapper(dib, self))
 */
  __pyx_t_2 = (__pyx_v_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1247
 * 
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to applying threshold to image")             # <<<<<<<<<<<<<<
 *         return Image(_bitmap=DibWrapper(dib, self))
 *     # **********************************************************************
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_97));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_97));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_97));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "smc/freeimage/_freeimage.pyx":1248
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to applying threshold to image")
 *         return Image(_bitmap=DibWrapper(dib, self))             # <<<<<<<<<<<<<<
 *     # **********************************************************************
 *     # Rotation / mirroring
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, ((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.threshold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_55flipHorizontal(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_54flipHorizontal[] = "flipHorizontal() -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_55flipHorizontal(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("flipHorizontal (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_54flipHorizontal(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1252
 *     # Rotation / mirroring
 * 
 *     def flipHorizontal(self):             # <<<<<<<<<<<<<<
 *         """flipHorizontal() -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_54flipHorizontal(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_copy = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("flipHorizontal", 0);

  /* "smc/freeimage/_freeimage.pyx":1256
 *         """
 *         cdef Image copy
 *         copy = self.clone()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             fi.FreeImage_FlipHorizontal(copy._dib)
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__clone); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_3smc_9freeimage_10_freeimage_Image))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_copy = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":1257
 *         cdef Image copy
 *         copy = self.clone()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             fi.FreeImage_FlipHorizontal(copy._dib)
 *         return copy
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1258
 *         copy = self.clone()
 *         with nogil:
 *             fi.FreeImage_FlipHorizontal(copy._dib)             # <<<<<<<<<<<<<<
 *         return copy
 * 
 */
        FreeImage_FlipHorizontal(__pyx_v_copy->_dib);
      }

      /* "smc/freeimage/_freeimage.pyx":1257
 *         cdef Image copy
 *         copy = self.clone()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             fi.FreeImage_FlipHorizontal(copy._dib)
 *         return copy
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1259
 *         with nogil:
 *             fi.FreeImage_FlipHorizontal(copy._dib)
 *         return copy             # <<<<<<<<<<<<<<
 * 
 *     def flipVertical(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_copy));
  __pyx_r = ((PyObject *)__pyx_v_copy);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.flipHorizontal", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_copy);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_57flipVertical(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_56flipVertical[] = "flipVertical() -> new image\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_57flipVertical(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("flipVertical (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_56flipVertical(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1261
 *         return copy
 * 
 *     def flipVertical(self):             # <<<<<<<<<<<<<<
 *         """flipVertical() -> new image
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_56flipVertical(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_copy = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("flipVertical", 0);

  /* "smc/freeimage/_freeimage.pyx":1265
 *         """
 *         cdef Image copy
 *         copy = self.clone()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             fi.FreeImage_FlipVertical(copy._dib)
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__clone); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_3smc_9freeimage_10_freeimage_Image))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_copy = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":1266
 *         cdef Image copy
 *         copy = self.clone()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             fi.FreeImage_FlipVertical(copy._dib)
 *         return copy
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1267
 *         copy = self.clone()
 *         with nogil:
 *             fi.FreeImage_FlipVertical(copy._dib)             # <<<<<<<<<<<<<<
 *         return copy
 * 
 */
        FreeImage_FlipVertical(__pyx_v_copy->_dib);
      }

      /* "smc/freeimage/_freeimage.pyx":1266
 *         cdef Image copy
 *         copy = self.clone()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             fi.FreeImage_FlipVertical(copy._dib)
 *         return copy
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1268
 *         with nogil:
 *             fi.FreeImage_FlipVertical(copy._dib)
 *         return copy             # <<<<<<<<<<<<<<
 * 
 *     def rotate(self, int angle):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_copy));
  __pyx_r = ((PyObject *)__pyx_v_copy);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.flipVertical", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_copy);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_59rotate(PyObject *__pyx_v_self, PyObject *__pyx_arg_angle); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_58rotate[] = "rotate(angle: int) -> new image\n\n        Only angles 90, 180 and 270 degrees are supported\n\n        Warning: rotation will result in loose of metadata\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_59rotate(PyObject *__pyx_v_self, PyObject *__pyx_arg_angle) {
  int __pyx_v_angle;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rotate (wrapper)", 0);
  assert(__pyx_arg_angle); {
    __pyx_v_angle = __Pyx_PyInt_AsInt(__pyx_arg_angle); if (unlikely((__pyx_v_angle == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.rotate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_58rotate(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), ((int)__pyx_v_angle));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1270
 *         return copy
 * 
 *     def rotate(self, int angle):             # <<<<<<<<<<<<<<
 *         """rotate(angle: int) -> new image
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_58rotate(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_angle) {
  FIBITMAP *__pyx_v_dib;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rotate", 0);

  /* "smc/freeimage/_freeimage.pyx":1279
 *         cdef fi.FIBITMAP* dib
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         if angle == -90:
 *             angle = 270
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1280
 * 
 *         self._check_closed()
 *         if angle == -90:             # <<<<<<<<<<<<<<
 *             angle = 270
 *         if angle not in (90, 180, 270):
 */
  __pyx_t_2 = (__pyx_v_angle == -90);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1281
 *         self._check_closed()
 *         if angle == -90:
 *             angle = 270             # <<<<<<<<<<<<<<
 *         if angle not in (90, 180, 270):
 *             raise ValueError("Only -90, 90, 180, 270 are supported")
 */
    __pyx_v_angle = 270;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1282
 *         if angle == -90:
 *             angle = 270
 *         if angle not in (90, 180, 270):             # <<<<<<<<<<<<<<
 *             raise ValueError("Only -90, 90, 180, 270 are supported")
 *         # FreeImage uses CCW angle, but we prefer CW angle
 */
  __pyx_t_3 = __pyx_v_angle;
  switch (__pyx_v_angle) {
    case 90:
    case 180:
    case 270:
    __pyx_t_2 = 0;
    break;
    default:
    __pyx_t_2 = 1;
    break;
  }
  __pyx_t_4 = __pyx_t_2;
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1283
 *             angle = 270
 *         if angle not in (90, 180, 270):
 *             raise ValueError("Only -90, 90, 180, 270 are supported")             # <<<<<<<<<<<<<<
 *         # FreeImage uses CCW angle, but we prefer CW angle
 *         if angle == 90:
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_99), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":1287
 *         if angle == 90:
 *             angle = 270
 *         elif angle == 270:             # <<<<<<<<<<<<<<
 *             angle = 90
 * 
 */
  switch (__pyx_v_angle) {

    /* "smc/freeimage/_freeimage.pyx":1285
 *             raise ValueError("Only -90, 90, 180, 270 are supported")
 *         # FreeImage uses CCW angle, but we prefer CW angle
 *         if angle == 90:             # <<<<<<<<<<<<<<
 *             angle = 270
 *         elif angle == 270:
 */
    case 90:

    /* "smc/freeimage/_freeimage.pyx":1286
 *         # FreeImage uses CCW angle, but we prefer CW angle
 *         if angle == 90:
 *             angle = 270             # <<<<<<<<<<<<<<
 *         elif angle == 270:
 *             angle = 90
 */
    __pyx_v_angle = 270;
    break;

    /* "smc/freeimage/_freeimage.pyx":1287
 *         if angle == 90:
 *             angle = 270
 *         elif angle == 270:             # <<<<<<<<<<<<<<
 *             angle = 90
 * 
 */
    case 270:

    /* "smc/freeimage/_freeimage.pyx":1288
 *             angle = 270
 *         elif angle == 270:
 *             angle = 90             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_v_angle = 90;
    break;
  }

  /* "smc/freeimage/_freeimage.pyx":1290
 *             angle = 90
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Rotate(self._dib, angle, NULL)
 *         if dib == NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1291
 * 
 *         with nogil:
 *             dib = fi.FreeImage_Rotate(self._dib, angle, NULL)             # <<<<<<<<<<<<<<
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to rotate image")
 */
        __pyx_v_dib = FreeImage_Rotate(__pyx_v_self->_dib, __pyx_v_angle, NULL);
      }

      /* "smc/freeimage/_freeimage.pyx":1290
 *             angle = 90
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_Rotate(self._dib, angle, NULL)
 *         if dib == NULL:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1292
 *         with nogil:
 *             dib = fi.FreeImage_Rotate(self._dib, angle, NULL)
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to rotate image")
 *         cloneICCProfile(self._dib, dib)
 */
  __pyx_t_4 = (__pyx_v_dib == NULL);
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1293
 *             dib = fi.FreeImage_Rotate(self._dib, angle, NULL)
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to rotate image")             # <<<<<<<<<<<<<<
 *         cloneICCProfile(self._dib, dib)
 *         fi.FreeImage_CloneMetadata(dib, self._dib)
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_100));
    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_kp_s_100));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_100));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "smc/freeimage/_freeimage.pyx":1294
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to rotate image")
 *         cloneICCProfile(self._dib, dib)             # <<<<<<<<<<<<<<
 *         fi.FreeImage_CloneMetadata(dib, self._dib)
 *         return Image(_bitmap=DibWrapper(dib, self))
 */
  __pyx_f_3smc_9freeimage_10_freeimage_cloneICCProfile(__pyx_v_self->_dib, __pyx_v_dib);

  /* "smc/freeimage/_freeimage.pyx":1295
 *             raise dispatchFIError(OperationError, "Failed to rotate image")
 *         cloneICCProfile(self._dib, dib)
 *         fi.FreeImage_CloneMetadata(dib, self._dib)             # <<<<<<<<<<<<<<
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 */
  FreeImage_CloneMetadata(__pyx_v_dib, __pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1296
 *         cloneICCProfile(self._dib, dib)
 *         fi.FreeImage_CloneMetadata(dib, self._dib)
 *         return Image(_bitmap=DibWrapper(dib, self))             # <<<<<<<<<<<<<<
 * 
 *     def rotateEx(self, double angle, double x_shift=0, double y_shift=0,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __pyx_t_6 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, ((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.rotate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_61rotateEx(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_60rotateEx[] = " rotate(angle: double, ...) -> new image\n\n        wrapper around fi.FreeImage_RotateEx\n\n        angle: angle in degree\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_61rotateEx(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_angle;
  double __pyx_v_x_shift;
  double __pyx_v_y_shift;
  double __pyx_v_x_origin;
  double __pyx_v_y_origin;
  int __pyx_v_use_mask;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__angle,&__pyx_n_s__x_shift,&__pyx_n_s__y_shift,&__pyx_n_s__x_origin,&__pyx_n_s__y_origin,&__pyx_n_s__use_mask,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rotateEx (wrapper)", 0);
  {
    PyObject* values[6] = {0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__angle);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_shift);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y_shift);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_origin);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y_origin);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_mask);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rotateEx") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[1]) {
      } else {

        /* "smc/freeimage/_freeimage.pyx":1298
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 *     def rotateEx(self, double angle, double x_shift=0, double y_shift=0,             # <<<<<<<<<<<<<<
 *                     double x_origin=0, double y_origin=0, bint use_mask=True):
 *         """ rotate(angle: double, ...) -> new image
 */
        __pyx_v_x_shift = ((double)0.0);
      }
      if (values[2]) {
      } else {
        __pyx_v_y_shift = ((double)0.0);
      }
      if (values[3]) {
      } else {

        /* "smc/freeimage/_freeimage.pyx":1299
 * 
 *     def rotateEx(self, double angle, double x_shift=0, double y_shift=0,
 *                     double x_origin=0, double y_origin=0, bint use_mask=True):             # <<<<<<<<<<<<<<
 *         """ rotate(angle: double, ...) -> new image
 * 
 */
        __pyx_v_x_origin = ((double)0.0);
      }
      if (values[4]) {
      } else {
        __pyx_v_y_origin = ((double)0.0);
      }
      if (values[5]) {
      } else {
        __pyx_v_use_mask = ((int)1);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_angle = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_angle == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[1]) {
      __pyx_v_x_shift = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_x_shift == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "smc/freeimage/_freeimage.pyx":1298
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 *     def rotateEx(self, double angle, double x_shift=0, double y_shift=0,             # <<<<<<<<<<<<<<
 *                     double x_origin=0, double y_origin=0, bint use_mask=True):
 *         """ rotate(angle: double, ...) -> new image
 */
      __pyx_v_x_shift = ((double)0.0);
    }
    if (values[2]) {
      __pyx_v_y_shift = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_y_shift == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_y_shift = ((double)0.0);
    }
    if (values[3]) {
      __pyx_v_x_origin = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_x_origin == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "smc/freeimage/_freeimage.pyx":1299
 * 
 *     def rotateEx(self, double angle, double x_shift=0, double y_shift=0,
 *                     double x_origin=0, double y_origin=0, bint use_mask=True):             # <<<<<<<<<<<<<<
 *         """ rotate(angle: double, ...) -> new image
 * 
 */
      __pyx_v_x_origin = ((double)0.0);
    }
    if (values[4]) {
      __pyx_v_y_origin = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_y_origin == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_y_origin = ((double)0.0);
    }
    if (values[5]) {
      __pyx_v_use_mask = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_use_mask == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_use_mask = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rotateEx", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.rotateEx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_60rotateEx(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_angle, __pyx_v_x_shift, __pyx_v_y_shift, __pyx_v_x_origin, __pyx_v_y_origin, __pyx_v_use_mask);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1298
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 *     def rotateEx(self, double angle, double x_shift=0, double y_shift=0,             # <<<<<<<<<<<<<<
 *                     double x_origin=0, double y_origin=0, bint use_mask=True):
 *         """ rotate(angle: double, ...) -> new image
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_60rotateEx(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, double __pyx_v_angle, double __pyx_v_x_shift, double __pyx_v_y_shift, double __pyx_v_x_origin, double __pyx_v_y_origin, int __pyx_v_use_mask) {
  FIBITMAP *__pyx_v_dib;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rotateEx", 0);

  /* "smc/freeimage/_freeimage.pyx":1308
 *         cdef fi.FIBITMAP* dib
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1310
 *         self._check_closed()
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_RotateEx(self._dib, angle, x_shift, y_shift,
 *                                         x_origin, y_origin, use_mask)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1312
 *         with nogil:
 *             dib = fi.FreeImage_RotateEx(self._dib, angle, x_shift, y_shift,
 *                                         x_origin, y_origin, use_mask)             # <<<<<<<<<<<<<<
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to rotate image")
 */
        __pyx_v_dib = FreeImage_RotateEx(__pyx_v_self->_dib, __pyx_v_angle, __pyx_v_x_shift, __pyx_v_y_shift, __pyx_v_x_origin, __pyx_v_y_origin, __pyx_v_use_mask);
      }

      /* "smc/freeimage/_freeimage.pyx":1310
 *         self._check_closed()
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             dib = fi.FreeImage_RotateEx(self._dib, angle, x_shift, y_shift,
 *                                         x_origin, y_origin, use_mask)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1313
 *             dib = fi.FreeImage_RotateEx(self._dib, angle, x_shift, y_shift,
 *                                         x_origin, y_origin, use_mask)
 *         if dib == NULL:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to rotate image")
 *         cloneICCProfile(self._dib, dib)
 */
  __pyx_t_2 = (__pyx_v_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1314
 *                                         x_origin, y_origin, use_mask)
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to rotate image")             # <<<<<<<<<<<<<<
 *         cloneICCProfile(self._dib, dib)
 *         fi.FreeImage_CloneMetadata(dib, self._dib)
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_100));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_100));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_100));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":1315
 *         if dib == NULL:
 *             raise dispatchFIError(OperationError, "Failed to rotate image")
 *         cloneICCProfile(self._dib, dib)             # <<<<<<<<<<<<<<
 *         fi.FreeImage_CloneMetadata(dib, self._dib)
 *         return Image(_bitmap=DibWrapper(dib, self))
 */
  __pyx_f_3smc_9freeimage_10_freeimage_cloneICCProfile(__pyx_v_self->_dib, __pyx_v_dib);

  /* "smc/freeimage/_freeimage.pyx":1316
 *             raise dispatchFIError(OperationError, "Failed to rotate image")
 *         cloneICCProfile(self._dib, dib)
 *         fi.FreeImage_CloneMetadata(dib, self._dib)             # <<<<<<<<<<<<<<
 *         return Image(_bitmap=DibWrapper(dib, self))
 * 
 */
  FreeImage_CloneMetadata(__pyx_v_dib, __pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1317
 *         cloneICCProfile(self._dib, dib)
 *         fi.FreeImage_CloneMetadata(dib, self._dib)
 *         return Image(_bitmap=DibWrapper(dib, self))             # <<<<<<<<<<<<<<
 * 
 *     # **********************************************************************
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_DibWrapper(__pyx_v_dib, ((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s___bitmap), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_Image)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.rotateEx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_63getICC(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_62getICC[] = "getICC() -> str\n\n        Return ICC profile a byte string\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_63getICC(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getICC (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_62getICC(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1322
 *     # ICC
 * 
 *     def getICC(self):             # <<<<<<<<<<<<<<
 *         """getICC() -> str
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_62getICC(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getICC", 0);

  /* "smc/freeimage/_freeimage.pyx":1328
 *         """
 *         cdef fi.FIICCPROFILE* icc
 *         if not self.has_icc:             # <<<<<<<<<<<<<<
 *             return None
 *         return cpython.PyBytes_FromStringAndSize(<char *>self._icc.data,
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__has_icc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (!__pyx_t_2);
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":1329
 *         cdef fi.FIICCPROFILE* icc
 *         if not self.has_icc:
 *             return None             # <<<<<<<<<<<<<<
 *         return cpython.PyBytes_FromStringAndSize(<char *>self._icc.data,
 *                                                  self._icc.size)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1330
 *         if not self.has_icc:
 *             return None
 *         return cpython.PyBytes_FromStringAndSize(<char *>self._icc.data,             # <<<<<<<<<<<<<<
 *                                                  self._icc.size)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "smc/freeimage/_freeimage.pyx":1331
 *             return None
 *         return cpython.PyBytes_FromStringAndSize(<char *>self._icc.data,
 *                                                  self._icc.size)             # <<<<<<<<<<<<<<
 * 
 *     #def setICC(self, str profile):
 */
  __pyx_t_1 = ((PyObject *)PyBytes_FromStringAndSize(((char *)__pyx_v_self->_icc->data), __pyx_v_self->_icc->size)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.getICC", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_65removeICC(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_64removeICC[] = "Remove ICC profile\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_65removeICC(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("removeICC (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_64removeICC(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1342
 * 
 * 
 *     def removeICC(self):             # <<<<<<<<<<<<<<
 *         """Remove ICC profile
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_64removeICC(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("removeICC", 0);

  /* "smc/freeimage/_freeimage.pyx":1345
 *         """Remove ICC profile
 *         """
 *         self._icc = NULL             # <<<<<<<<<<<<<<
 *         fi.FreeImage_DestroyICCProfile(self._dib)
 * 
 */
  __pyx_v_self->_icc = NULL;

  /* "smc/freeimage/_freeimage.pyx":1346
 *         """
 *         self._icc = NULL
 *         fi.FreeImage_DestroyICCProfile(self._dib)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  FreeImage_DestroyICCProfile(__pyx_v_self->_dib);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_67iccTransform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_66iccTransform[] = "Apply an LCMS transformation\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_67iccTransform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_trafo = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__trafo,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iccTransform (wrapper)", 0);
  {
    PyObject* values[1] = {0};

    /* "smc/freeimage/_freeimage.pyx":1349
 * 
 * 
 *     def iccTransform(self, LCMSTransformation trafo=None):             # <<<<<<<<<<<<<<
 *         """Apply an LCMS transformation
 *         """
 */
    values[0] = (PyObject *)((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trafo);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "iccTransform") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1349; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_trafo = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iccTransform", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1349; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.iccTransform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trafo), __pyx_ptype_3smc_9freeimage_10_freeimage_LCMSTransformation, 1, "trafo", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_66iccTransform(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_trafo);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_66iccTransform(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *__pyx_v_trafo) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iccTransform", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_trafo);

  /* "smc/freeimage/_freeimage.pyx":1352
 *         """Apply an LCMS transformation
 *         """
 *         if trafo is None:             # <<<<<<<<<<<<<<
 *             trafo = LCMSTransformation(self.getICC(), b"sRGB")
 *         lcmsFI(self, trafo)
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_trafo) == Py_None);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":1353
 *         """
 *         if trafo is None:
 *             trafo = LCMSTransformation(self.getICC(), b"sRGB")             # <<<<<<<<<<<<<<
 *         lcmsFI(self, trafo)
 * 
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__getICC); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_n_b__sRGB));
    PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_b__sRGB));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_b__sRGB));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3smc_9freeimage_10_freeimage_LCMSTransformation)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_trafo));
    __pyx_v_trafo = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1354
 *         if trafo is None:
 *             trafo = LCMSTransformation(self.getICC(), b"sRGB")
 *         lcmsFI(self, trafo)             # <<<<<<<<<<<<<<
 * 
 *     # **********************************************************************
 */
  __pyx_t_4 = __pyx_f_3smc_9freeimage_10_freeimage_lcmsFI(__pyx_v_self, __pyx_v_trafo); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.iccTransform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_trafo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_69getMetadataCount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_68getMetadataCount[] = "getMetadataCount() -> dict\n\n        Count number of metadata for each model\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_69getMetadataCount(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getMetadataCount (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_68getMetadataCount(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1359
 *     # Metadata
 * 
 *     def getMetadataCount(self):             # <<<<<<<<<<<<<<
 *         """getMetadataCount() -> dict
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_68getMetadataCount(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_v_counts = NULL;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_model = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  enum FREE_IMAGE_MDMODEL __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getMetadataCount", 0);

  /* "smc/freeimage/_freeimage.pyx":1364
 *         Count number of metadata for each model
 *         """
 *         counts = {}             # <<<<<<<<<<<<<<
 *         self._check_closed()
 *         for name, model in _META_MODELS.items():
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_counts = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1365
 *         """
 *         counts = {}
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         for name, model in _META_MODELS.items():
 *             counts[name] = int(fi.FreeImage_GetMetadataCount(model, self._dib))
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1366
 *         counts = {}
 *         self._check_closed()
 *         for name, model in _META_MODELS.items():             # <<<<<<<<<<<<<<
 *             counts[name] = int(fi.FreeImage_GetMetadataCount(model, self._dib))
 *         return counts
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___META_MODELS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      if (likely(PyTuple_CheckExact(sequence))) {
        if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
          if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
          else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
          if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
          else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
      if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_name);
    __pyx_v_name = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_model);
    __pyx_v_model = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "smc/freeimage/_freeimage.pyx":1367
 *         self._check_closed()
 *         for name, model in _META_MODELS.items():
 *             counts[name] = int(fi.FreeImage_GetMetadataCount(model, self._dib))             # <<<<<<<<<<<<<<
 *         return counts
 * 
 */
    __pyx_t_9 = ((enum FREE_IMAGE_MDMODEL)PyInt_AsLong(__pyx_v_model)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyLong_FromUnsignedLong(FreeImage_GetMetadataCount(__pyx_t_9, __pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    if (PyDict_SetItem(((PyObject *)__pyx_v_counts), __pyx_v_name, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":1368
 *         for name, model in _META_MODELS.items():
 *             counts[name] = int(fi.FreeImage_GetMetadataCount(model, self._dib))
 *         return counts             # <<<<<<<<<<<<<<
 * 
 *     def getMetadata(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_counts));
  __pyx_r = ((PyObject *)__pyx_v_counts);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.getMetadataCount", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_counts);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_model);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_71getMetadata(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_70getMetadata[] = "getMetadata() -> dict\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_71getMetadata(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getMetadata (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_70getMetadata(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1370
 *         return counts
 * 
 *     def getMetadata(self):             # <<<<<<<<<<<<<<
 *         """getMetadata() -> dict
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_70getMetadata(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  FIMETADATA *__pyx_v_handle;
  FITAG *__pyx_v_tag;
  char *__pyx_v_key;
  char *__pyx_v_string;
  char *__pyx_v_descr;
  PyObject *__pyx_v_metas = NULL;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_model = NULL;
  PyObject *__pyx_v_meta = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  enum FREE_IMAGE_MDMODEL __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getMetadata", 0);

  /* "smc/freeimage/_freeimage.pyx":1373
 *         """getMetadata() -> dict
 *         """
 *         cdef fi.FIMETADATA *handle = NULL             # <<<<<<<<<<<<<<
 *         cdef fi.FITAG *tag
 *         cdef char *key, *string, *descr
 */
  __pyx_v_handle = NULL;

  /* "smc/freeimage/_freeimage.pyx":1376
 *         cdef fi.FITAG *tag
 *         cdef char *key, *string, *descr
 *         metas = {}             # <<<<<<<<<<<<<<
 * 
 *         self._check_closed()
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_metas = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1378
 *         metas = {}
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         for name, model in _META_MODELS.items():
 *             handle = fi.FreeImage_FindFirstMetadata(model, self._dib, &tag)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1379
 * 
 *         self._check_closed()
 *         for name, model in _META_MODELS.items():             # <<<<<<<<<<<<<<
 *             handle = fi.FreeImage_FindFirstMetadata(model, self._dib, &tag)
 *             if handle == NULL:
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___META_MODELS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      if (likely(PyTuple_CheckExact(sequence))) {
        if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
          if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
          else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
          if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
          else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
      if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_name);
    __pyx_v_name = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_model);
    __pyx_v_model = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "smc/freeimage/_freeimage.pyx":1380
 *         self._check_closed()
 *         for name, model in _META_MODELS.items():
 *             handle = fi.FreeImage_FindFirstMetadata(model, self._dib, &tag)             # <<<<<<<<<<<<<<
 *             if handle == NULL:
 *                 continue
 */
    __pyx_t_9 = ((enum FREE_IMAGE_MDMODEL)PyInt_AsLong(__pyx_v_model)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_handle = FreeImage_FindFirstMetadata(__pyx_t_9, __pyx_v_self->_dib, (&__pyx_v_tag));

    /* "smc/freeimage/_freeimage.pyx":1381
 *         for name, model in _META_MODELS.items():
 *             handle = fi.FreeImage_FindFirstMetadata(model, self._dib, &tag)
 *             if handle == NULL:             # <<<<<<<<<<<<<<
 *                 continue
 *             meta = metas.setdefault(name, {})
 */
    __pyx_t_10 = (__pyx_v_handle == NULL);
    if (__pyx_t_10) {

      /* "smc/freeimage/_freeimage.pyx":1382
 *             handle = fi.FreeImage_FindFirstMetadata(model, self._dib, &tag)
 *             if handle == NULL:
 *                 continue             # <<<<<<<<<<<<<<
 *             meta = metas.setdefault(name, {})
 *             while 1:
 */
      goto __pyx_L3_continue;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "smc/freeimage/_freeimage.pyx":1383
 *             if handle == NULL:
 *                 continue
 *             meta = metas.setdefault(name, {})             # <<<<<<<<<<<<<<
 *             while 1:
 *                 key = <char *>fi.FreeImage_GetTagKey(tag)
 */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_6 = __Pyx_PyDict_SetDefault(((PyObject *)__pyx_v_metas), __pyx_v_name, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_meta);
    __pyx_v_meta = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "smc/freeimage/_freeimage.pyx":1384
 *                 continue
 *             meta = metas.setdefault(name, {})
 *             while 1:             # <<<<<<<<<<<<<<
 *                 key = <char *>fi.FreeImage_GetTagKey(tag)
 *                 string = <char *>fi.FreeImage_TagToString(model, tag, NULL)
 */
    while (1) {
      if (!1) break;

      /* "smc/freeimage/_freeimage.pyx":1385
 *             meta = metas.setdefault(name, {})
 *             while 1:
 *                 key = <char *>fi.FreeImage_GetTagKey(tag)             # <<<<<<<<<<<<<<
 *                 string = <char *>fi.FreeImage_TagToString(model, tag, NULL)
 *                 descr = <char *>fi.FreeImage_GetTagDescription(tag)
 */
      __pyx_v_key = ((char *)FreeImage_GetTagKey(__pyx_v_tag));

      /* "smc/freeimage/_freeimage.pyx":1386
 *             while 1:
 *                 key = <char *>fi.FreeImage_GetTagKey(tag)
 *                 string = <char *>fi.FreeImage_TagToString(model, tag, NULL)             # <<<<<<<<<<<<<<
 *                 descr = <char *>fi.FreeImage_GetTagDescription(tag)
 *                 if descr != NULL:
 */
      __pyx_t_9 = ((enum FREE_IMAGE_MDMODEL)PyInt_AsLong(__pyx_v_model)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_string = ((char *)FreeImage_TagToString(__pyx_t_9, __pyx_v_tag, NULL));

      /* "smc/freeimage/_freeimage.pyx":1387
 *                 key = <char *>fi.FreeImage_GetTagKey(tag)
 *                 string = <char *>fi.FreeImage_TagToString(model, tag, NULL)
 *                 descr = <char *>fi.FreeImage_GetTagDescription(tag)             # <<<<<<<<<<<<<<
 *                 if descr != NULL:
 *                     meta[funicode(key)] = funicode(string), funicode(descr)
 */
      __pyx_v_descr = ((char *)FreeImage_GetTagDescription(__pyx_v_tag));

      /* "smc/freeimage/_freeimage.pyx":1388
 *                 string = <char *>fi.FreeImage_TagToString(model, tag, NULL)
 *                 descr = <char *>fi.FreeImage_GetTagDescription(tag)
 *                 if descr != NULL:             # <<<<<<<<<<<<<<
 *                     meta[funicode(key)] = funicode(string), funicode(descr)
 *                 else:
 */
      __pyx_t_10 = (__pyx_v_descr != NULL);
      if (__pyx_t_10) {

        /* "smc/freeimage/_freeimage.pyx":1389
 *                 descr = <char *>fi.FreeImage_GetTagDescription(tag)
 *                 if descr != NULL:
 *                     meta[funicode(key)] = funicode(string), funicode(descr)             # <<<<<<<<<<<<<<
 *                 else:
 *                     meta[funicode(key)] = funicode(string), None
 */
        __pyx_t_6 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(__pyx_v_string); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(__pyx_v_descr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_6 = 0;
        __pyx_t_1 = 0;
        __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(__pyx_v_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        if (PyObject_SetItem(__pyx_v_meta, __pyx_t_1, ((PyObject *)__pyx_t_5)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
        goto __pyx_L10;
      }
      /*else*/ {

        /* "smc/freeimage/_freeimage.pyx":1391
 *                     meta[funicode(key)] = funicode(string), funicode(descr)
 *                 else:
 *                     meta[funicode(key)] = funicode(string), None             # <<<<<<<<<<<<<<
 *                 if not fi.FreeImage_FindNextMetadata(handle, &tag):
 *                     fi.FreeImage_FindCloseMetadata(handle)
 */
        __pyx_t_5 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(__pyx_v_string); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __Pyx_INCREF(Py_None);
        PyTuple_SET_ITEM(__pyx_t_1, 1, Py_None);
        __Pyx_GIVEREF(Py_None);
        __pyx_t_5 = 0;
        __pyx_t_5 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(__pyx_v_key); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        if (PyObject_SetItem(__pyx_v_meta, __pyx_t_5, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      }
      __pyx_L10:;

      /* "smc/freeimage/_freeimage.pyx":1392
 *                 else:
 *                     meta[funicode(key)] = funicode(string), None
 *                 if not fi.FreeImage_FindNextMetadata(handle, &tag):             # <<<<<<<<<<<<<<
 *                     fi.FreeImage_FindCloseMetadata(handle)
 *                     break
 */
      __pyx_t_10 = (!FreeImage_FindNextMetadata(__pyx_v_handle, (&__pyx_v_tag)));
      if (__pyx_t_10) {

        /* "smc/freeimage/_freeimage.pyx":1393
 *                     meta[funicode(key)] = funicode(string), None
 *                 if not fi.FreeImage_FindNextMetadata(handle, &tag):
 *                     fi.FreeImage_FindCloseMetadata(handle)             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
        FreeImage_FindCloseMetadata(__pyx_v_handle);

        /* "smc/freeimage/_freeimage.pyx":1394
 *                 if not fi.FreeImage_FindNextMetadata(handle, &tag):
 *                     fi.FreeImage_FindCloseMetadata(handle)
 *                     break             # <<<<<<<<<<<<<<
 * 
 *         return metas
 */
        goto __pyx_L9_break;
        goto __pyx_L11;
      }
      __pyx_L11:;
    }
    __pyx_L9_break:;
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":1396
 *                     break
 * 
 *         return metas             # <<<<<<<<<<<<<<
 * 
 *     def copyMetadataFrom(self, Image src not None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_metas));
  __pyx_r = ((PyObject *)__pyx_v_metas);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.getMetadata", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_metas);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_model);
  __Pyx_XDECREF(__pyx_v_meta);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_73copyMetadataFrom(PyObject *__pyx_v_self, PyObject *__pyx_v_src); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_73copyMetadataFrom(PyObject *__pyx_v_self, PyObject *__pyx_v_src) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copyMetadataFrom (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_src), __pyx_ptype_3smc_9freeimage_10_freeimage_Image, 0, "src", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_72copyMetadataFrom(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_src));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1398
 *         return metas
 * 
 *     def copyMetadataFrom(self, Image src not None):             # <<<<<<<<<<<<<<
 *         self._check_closed()
 *         if src._dib == NULL:
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_72copyMetadataFrom(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_src) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("copyMetadataFrom", 0);

  /* "smc/freeimage/_freeimage.pyx":1399
 * 
 *     def copyMetadataFrom(self, Image src not None):
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         if src._dib == NULL:
 *             raise IOError("Operation on closed source image")
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1400
 *     def copyMetadataFrom(self, Image src not None):
 *         self._check_closed()
 *         if src._dib == NULL:             # <<<<<<<<<<<<<<
 *             raise IOError("Operation on closed source image")
 *         if not fi.FreeImage_CloneMetadata(self._dib, src._dib):
 */
  __pyx_t_2 = (__pyx_v_src->_dib == NULL);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1401
 *         self._check_closed()
 *         if src._dib == NULL:
 *             raise IOError("Operation on closed source image")             # <<<<<<<<<<<<<<
 *         if not fi.FreeImage_CloneMetadata(self._dib, src._dib):
 *             raise dispatchFIError(OperationError, "Failed to copy metadata")
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_101), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1402
 *         if src._dib == NULL:
 *             raise IOError("Operation on closed source image")
 *         if not fi.FreeImage_CloneMetadata(self._dib, src._dib):             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to copy metadata")
 * 
 */
  __pyx_t_2 = (!FreeImage_CloneMetadata(__pyx_v_self->_dib, __pyx_v_src->_dib));
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1403
 *             raise IOError("Operation on closed source image")
 *         if not fi.FreeImage_CloneMetadata(self._dib, src._dib):
 *             raise dispatchFIError(OperationError, "Failed to copy metadata")             # <<<<<<<<<<<<<<
 * 
 *     def clearMetadata(self):
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_102));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_102));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_102));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.copyMetadataFrom", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_75clearMetadata(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_75clearMetadata(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clearMetadata (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_74clearMetadata(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1405
 *             raise dispatchFIError(OperationError, "Failed to copy metadata")
 * 
 *     def clearMetadata(self):             # <<<<<<<<<<<<<<
 *         self._check_closed()
 *         for name, model in _META_MODELS.items():
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_74clearMetadata(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_model = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  enum FREE_IMAGE_MDMODEL __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clearMetadata", 0);

  /* "smc/freeimage/_freeimage.pyx":1406
 * 
 *     def clearMetadata(self):
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         for name, model in _META_MODELS.items():
 *             if not fi.FreeImage_SetMetadata(model, self._dib, NULL, NULL):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1407
 *     def clearMetadata(self):
 *         self._check_closed()
 *         for name, model in _META_MODELS.items():             # <<<<<<<<<<<<<<
 *             if not fi.FreeImage_SetMetadata(model, self._dib, NULL, NULL):
 *                 raise dispatchFIError(OperationError, "Failed to delete metadata model %s" % name)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___META_MODELS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      if (likely(PyTuple_CheckExact(sequence))) {
        if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
          if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
          else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
          if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
          else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
      if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_name);
    __pyx_v_name = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_model);
    __pyx_v_model = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "smc/freeimage/_freeimage.pyx":1408
 *         self._check_closed()
 *         for name, model in _META_MODELS.items():
 *             if not fi.FreeImage_SetMetadata(model, self._dib, NULL, NULL):             # <<<<<<<<<<<<<<
 *                 raise dispatchFIError(OperationError, "Failed to delete metadata model %s" % name)
 * 
 */
    __pyx_t_9 = ((enum FREE_IMAGE_MDMODEL)PyInt_AsLong(__pyx_v_model)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = (!FreeImage_SetMetadata(__pyx_t_9, __pyx_v_self->_dib, NULL, NULL));
    if (__pyx_t_10) {

      /* "smc/freeimage/_freeimage.pyx":1409
 *         for name, model in _META_MODELS.items():
 *             if not fi.FreeImage_SetMetadata(model, self._dib, NULL, NULL):
 *                 raise dispatchFIError(OperationError, "Failed to delete metadata model %s" % name)             # <<<<<<<<<<<<<<
 * 
 *     def getInfoHeader(self):
 */
      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_103), __pyx_v_name); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_t_5));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
      __pyx_t_6 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.clearMetadata", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_model);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_77getInfoHeader(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_76getInfoHeader[] = "getInfoHeader() -> BitmapInfo instance\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_77getInfoHeader(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getInfoHeader (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_76getInfoHeader(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1411
 *                 raise dispatchFIError(OperationError, "Failed to delete metadata model %s" % name)
 * 
 *     def getInfoHeader(self):             # <<<<<<<<<<<<<<
 *         """getInfoHeader() -> BitmapInfo instance
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_76getInfoHeader(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  BITMAPINFOHEADER *__pyx_v_header;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getInfoHeader", 0);

  /* "smc/freeimage/_freeimage.pyx":1415
 *         """
 *         cdef fi.BITMAPINFOHEADER *header
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         header = fi.FreeImage_GetInfoHeader(self._dib)
 *         return BitmapInfo(header)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1416
 *         cdef fi.BITMAPINFOHEADER *header
 *         self._check_closed()
 *         header = fi.FreeImage_GetInfoHeader(self._dib)             # <<<<<<<<<<<<<<
 *         return BitmapInfo(header)
 * 
 */
  __pyx_v_header = FreeImage_GetInfoHeader(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1417
 *         self._check_closed()
 *         header = fi.FreeImage_GetInfoHeader(self._dib)
 *         return BitmapInfo(header)             # <<<<<<<<<<<<<<
 * 
 *     # **********************************************************************
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage_BitmapInfo(__pyx_v_header)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.getInfoHeader", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_79adjustColors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_78adjustColors[] = "adjustColors(brightness=0.0, contrast=0.0, gamma=1.0,\n                        invert=False) -> None\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_79adjustColors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_brightness;
  float __pyx_v_contrast;
  float __pyx_v_gamma;
  PyObject *__pyx_v_invert = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__brightness,&__pyx_n_s__contrast,&__pyx_n_s__gamma,&__pyx_n_s__invert,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("adjustColors (wrapper)", 0);
  {
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__brightness);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__contrast);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__gamma);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__invert);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "adjustColors") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[0]) {
      } else {

        /* "smc/freeimage/_freeimage.pyx":1422
 *     # Color adjustment
 * 
 *     def adjustColors(self, float brightness=0.0, float contrast=0.0,             # <<<<<<<<<<<<<<
 *                     float gamma=1.0, invert=0):
 *         """adjustColors(brightness=0.0, contrast=0.0, gamma=1.0,
 */
        __pyx_v_brightness = ((float)0.0);
      }
      if (values[1]) {
      } else {
        __pyx_v_contrast = ((float)0.0);
      }
      if (values[2]) {
      } else {

        /* "smc/freeimage/_freeimage.pyx":1423
 * 
 *     def adjustColors(self, float brightness=0.0, float contrast=0.0,
 *                     float gamma=1.0, invert=0):             # <<<<<<<<<<<<<<
 *         """adjustColors(brightness=0.0, contrast=0.0, gamma=1.0,
 *                         invert=False) -> None
 */
        __pyx_v_gamma = ((float)1.0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_brightness = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_brightness == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "smc/freeimage/_freeimage.pyx":1422
 *     # Color adjustment
 * 
 *     def adjustColors(self, float brightness=0.0, float contrast=0.0,             # <<<<<<<<<<<<<<
 *                     float gamma=1.0, invert=0):
 *         """adjustColors(brightness=0.0, contrast=0.0, gamma=1.0,
 */
      __pyx_v_brightness = ((float)0.0);
    }
    if (values[1]) {
      __pyx_v_contrast = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_contrast == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_contrast = ((float)0.0);
    }
    if (values[2]) {
      __pyx_v_gamma = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_gamma == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "smc/freeimage/_freeimage.pyx":1423
 * 
 *     def adjustColors(self, float brightness=0.0, float contrast=0.0,
 *                     float gamma=1.0, invert=0):             # <<<<<<<<<<<<<<
 *         """adjustColors(brightness=0.0, contrast=0.0, gamma=1.0,
 *                         invert=False) -> None
 */
      __pyx_v_gamma = ((float)1.0);
    }
    __pyx_v_invert = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("adjustColors", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.adjustColors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_78adjustColors(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_brightness, __pyx_v_contrast, __pyx_v_gamma, __pyx_v_invert);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1422
 *     # Color adjustment
 * 
 *     def adjustColors(self, float brightness=0.0, float contrast=0.0,             # <<<<<<<<<<<<<<
 *                     float gamma=1.0, invert=0):
 *         """adjustColors(brightness=0.0, contrast=0.0, gamma=1.0,
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_78adjustColors(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_brightness, float __pyx_v_contrast, float __pyx_v_gamma, PyObject *__pyx_v_invert) {
  CYTHON_UNUSED int __pyx_v__invert;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  BOOL __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("adjustColors", 0);

  /* "smc/freeimage/_freeimage.pyx":1429
 *         cdef int _invert
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 * 
 *         _invert = cpython.PyObject_IsTrue(invert)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1431
 *         self._check_closed()
 * 
 *         _invert = cpython.PyObject_IsTrue(invert)             # <<<<<<<<<<<<<<
 *         if brightness < -100.0 or brightness > +100.0:
 *             raise ValueError("Brightness must be between -100. and +100. "
 */
  __pyx_t_2 = PyObject_IsTrue(__pyx_v_invert); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v__invert = __pyx_t_2;

  /* "smc/freeimage/_freeimage.pyx":1432
 * 
 *         _invert = cpython.PyObject_IsTrue(invert)
 *         if brightness < -100.0 or brightness > +100.0:             # <<<<<<<<<<<<<<
 *             raise ValueError("Brightness must be between -100. and +100. "
 *                              "(percentage)")
 */
  __pyx_t_2 = (__pyx_v_brightness < -100.0);
  if (!__pyx_t_2) {
    __pyx_t_3 = (__pyx_v_brightness > 100.0);
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1433
 *         _invert = cpython.PyObject_IsTrue(invert)
 *         if brightness < -100.0 or brightness > +100.0:
 *             raise ValueError("Brightness must be between -100. and +100. "             # <<<<<<<<<<<<<<
 *                              "(percentage)")
 *         if contrast < -100.0 or contrast > +100.0:
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_105), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1435
 *             raise ValueError("Brightness must be between -100. and +100. "
 *                              "(percentage)")
 *         if contrast < -100.0 or contrast > +100.0:             # <<<<<<<<<<<<<<
 *             raise ValueError("Contrast must be between -100 and +100 "
 *                              "(percentage)")
 */
  __pyx_t_4 = (__pyx_v_contrast < -100.0);
  if (!__pyx_t_4) {
    __pyx_t_2 = (__pyx_v_contrast > 100.0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_4;
  }
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":1436
 *                              "(percentage)")
 *         if contrast < -100.0 or contrast > +100.0:
 *             raise ValueError("Contrast must be between -100 and +100 "             # <<<<<<<<<<<<<<
 *                              "(percentage)")
 *         if gamma <= 0.0:
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_107), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":1438
 *             raise ValueError("Contrast must be between -100 and +100 "
 *                              "(percentage)")
 *         if gamma <= 0.0:             # <<<<<<<<<<<<<<
 *             raise ValueError("Gamma must be greater than 0.")
 * 
 */
  __pyx_t_3 = (__pyx_v_gamma <= 0.0);
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":1439
 *                              "(percentage)")
 *         if gamma <= 0.0:
 *             raise ValueError("Gamma must be greater than 0.")             # <<<<<<<<<<<<<<
 * 
 *         if not fi.FreeImage_AdjustColors(self._dib, brightness, contrast,
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_109), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "smc/freeimage/_freeimage.pyx":1442
 * 
 *         if not fi.FreeImage_AdjustColors(self._dib, brightness, contrast,
 *                                       gamma, invert):             # <<<<<<<<<<<<<<
 *             raise dispatchFIError( OperationError, "Failed to adjust color.")
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_from_py_int32_t(__pyx_v_invert); if (unlikely((__pyx_t_5 == (BOOL)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = (!FreeImage_AdjustColors(__pyx_v_self->_dib, __pyx_v_brightness, __pyx_v_contrast, __pyx_v_gamma, __pyx_t_5));
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":1443
 *         if not fi.FreeImage_AdjustColors(self._dib, brightness, contrast,
 *                                       gamma, invert):
 *             raise dispatchFIError( OperationError, "Failed to adjust color.")             # <<<<<<<<<<<<<<
 * 
 *     def adjustGamma(self, float gamma=1.0):
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_110));
    PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_kp_s_110));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_110));
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.adjustColors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_81adjustGamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_80adjustGamma[] = "adjustGamma(gamma=1.0) -> None\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_81adjustGamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_gamma;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__gamma,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("adjustGamma (wrapper)", 0);
  {
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__gamma);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "adjustGamma") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[0]) {
      } else {

        /* "smc/freeimage/_freeimage.pyx":1445
 *             raise dispatchFIError( OperationError, "Failed to adjust color.")
 * 
 *     def adjustGamma(self, float gamma=1.0):             # <<<<<<<<<<<<<<
 *         """adjustGamma(gamma=1.0) -> None
 *         """
 */
        __pyx_v_gamma = ((float)1.0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_gamma = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_gamma == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_gamma = ((float)1.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("adjustGamma", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.adjustGamma", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_80adjustGamma(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_gamma);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_80adjustGamma(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_gamma) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("adjustGamma", 0);

  /* "smc/freeimage/_freeimage.pyx":1448
 *         """adjustGamma(gamma=1.0) -> None
 *         """
 *         self.adjustColors(gamma=gamma)             # <<<<<<<<<<<<<<
 * 
 *     def adjustBrightness(self, float brigthness=0.0):
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__adjustColors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_gamma); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__gamma), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.adjustGamma", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_83adjustBrightness(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_82adjustBrightness[] = "adjustBrightness(brigthness=0.0) -> None\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_83adjustBrightness(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_brigthness;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__brigthness,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("adjustBrightness (wrapper)", 0);
  {
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__brigthness);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "adjustBrightness") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1450; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[0]) {
      } else {

        /* "smc/freeimage/_freeimage.pyx":1450
 *         self.adjustColors(gamma=gamma)
 * 
 *     def adjustBrightness(self, float brigthness=0.0):             # <<<<<<<<<<<<<<
 *         """adjustBrightness(brigthness=0.0) -> None
 *         """
 */
        __pyx_v_brigthness = ((float)0.0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_brigthness = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_brigthness == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1450; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_brigthness = ((float)0.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("adjustBrightness", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1450; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.adjustBrightness", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_82adjustBrightness(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_brigthness);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_82adjustBrightness(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_brigthness) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("adjustBrightness", 0);

  /* "smc/freeimage/_freeimage.pyx":1453
 *         """adjustBrightness(brigthness=0.0) -> None
 *         """
 *         self.adjustColors(brigthness=brigthness)             # <<<<<<<<<<<<<<
 * 
 *     def adjustContrast(self, float contrast=0.0):
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__adjustColors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_brigthness); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__brigthness), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.adjustBrightness", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_85adjustContrast(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_84adjustContrast[] = "adjustContrast(contrast=0.0) -> None\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_85adjustContrast(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_contrast;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__contrast,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("adjustContrast (wrapper)", 0);
  {
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__contrast);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "adjustContrast") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[0]) {
      } else {

        /* "smc/freeimage/_freeimage.pyx":1455
 *         self.adjustColors(brigthness=brigthness)
 * 
 *     def adjustContrast(self, float contrast=0.0):             # <<<<<<<<<<<<<<
 *         """adjustContrast(contrast=0.0) -> None
 *         """
 */
        __pyx_v_contrast = ((float)0.0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_contrast = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_contrast == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_contrast = ((float)0.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("adjustContrast", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1455; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.adjustContrast", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_84adjustContrast(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_contrast);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_84adjustContrast(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, float __pyx_v_contrast) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("adjustContrast", 0);

  /* "smc/freeimage/_freeimage.pyx":1458
 *         """adjustContrast(contrast=0.0) -> None
 *         """
 *         self.adjustColors(contrast=contrast)             # <<<<<<<<<<<<<<
 * 
 *     def invert(self):
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__adjustColors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_contrast); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__contrast), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.adjustContrast", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_87invert(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_86invert[] = "invert() -> None\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_87invert(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("invert (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_86invert(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1460
 *         self.adjustColors(contrast=contrast)
 * 
 *     def invert(self):             # <<<<<<<<<<<<<<
 *         """invert() -> None
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_86invert(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("invert", 0);

  /* "smc/freeimage/_freeimage.pyx":1463
 *         """invert() -> None
 *         """
 *         self.adjustColors(invert=1)             # <<<<<<<<<<<<<<
 * 
 *     def getHistogram(self, int channel=fi.FICC_BLACK):
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__adjustColors); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__invert), __pyx_int_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.invert", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_89getHistogram(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_5Image_88getHistogram[] = "getHistogramm([channel=fi.FICC_BLACK]) -> list[256]\n        ";
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_89getHistogram(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_channel;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__channel,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getHistogram (wrapper)", 0);
  {
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__channel);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getHistogram") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[0]) {
      } else {
        __pyx_v_channel = __pyx_k_111;
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_channel = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_channel == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_channel = __pyx_k_111;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getHistogram", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.getHistogram", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_88getHistogram(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_channel);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1465
 *         self.adjustColors(invert=1)
 * 
 *     def getHistogram(self, int channel=fi.FICC_BLACK):             # <<<<<<<<<<<<<<
 *         """getHistogramm([channel=fi.FICC_BLACK]) -> list[256]
 *         """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_88getHistogram(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, int __pyx_v_channel) {
  int __pyx_v_bpp;
  int __pyx_v_i;
  DWORD __pyx_v_hist[256];
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getHistogram", 0);

  /* "smc/freeimage/_freeimage.pyx":1471
 *         cdef fi.DWORD hist[256]
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         bpp = fi.FreeImage_GetBPP(self._dib)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1472
 * 
 *         self._check_closed()
 *         bpp = fi.FreeImage_GetBPP(self._dib)             # <<<<<<<<<<<<<<
 * 
 *         if bpp == 24 or bpp == 32:
 */
  __pyx_v_bpp = FreeImage_GetBPP(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1480
 *                                  "green, blue or black channels only, got %i."
 *                                  % (bpp, channel))
 *         elif bpp == 8:             # <<<<<<<<<<<<<<
 *             if channel != fi.FICC_BLACK:
 *                 raise ValueError("8 bpp image supports histogram for black "
 */
  switch (__pyx_v_bpp) {

    /* "smc/freeimage/_freeimage.pyx":1474
 *         bpp = fi.FreeImage_GetBPP(self._dib)
 * 
 *         if bpp == 24 or bpp == 32:             # <<<<<<<<<<<<<<
 *             if not (channel == fi.FICC_BLACK or channel == fi.FICC_RED or
 *                     channel == fi.FICC_GREEN or channel == fi.FICC_BLUE):
 */
    case 24:
    case 32:

    /* "smc/freeimage/_freeimage.pyx":1475
 * 
 *         if bpp == 24 or bpp == 32:
 *             if not (channel == fi.FICC_BLACK or channel == fi.FICC_RED or             # <<<<<<<<<<<<<<
 *                     channel == fi.FICC_GREEN or channel == fi.FICC_BLUE):
 *                 raise ValueError("%i bpp image supports histogram for red, "
 */
    __pyx_t_2 = (__pyx_v_channel == FICC_BLACK);
    if (!__pyx_t_2) {
      __pyx_t_3 = (__pyx_v_channel == FICC_RED);
      if (!__pyx_t_3) {

        /* "smc/freeimage/_freeimage.pyx":1476
 *         if bpp == 24 or bpp == 32:
 *             if not (channel == fi.FICC_BLACK or channel == fi.FICC_RED or
 *                     channel == fi.FICC_GREEN or channel == fi.FICC_BLUE):             # <<<<<<<<<<<<<<
 *                 raise ValueError("%i bpp image supports histogram for red, "
 *                                  "green, blue or black channels only, got %i."
 */
        __pyx_t_4 = (__pyx_v_channel == FICC_GREEN);
        if (!__pyx_t_4) {
          __pyx_t_5 = (__pyx_v_channel == FICC_BLUE);
          __pyx_t_6 = __pyx_t_5;
        } else {
          __pyx_t_6 = __pyx_t_4;
        }
        __pyx_t_4 = __pyx_t_6;
      } else {
        __pyx_t_4 = __pyx_t_3;
      }
      __pyx_t_3 = __pyx_t_4;
    } else {
      __pyx_t_3 = __pyx_t_2;
    }
    __pyx_t_2 = (!__pyx_t_3);
    if (__pyx_t_2) {

      /* "smc/freeimage/_freeimage.pyx":1479
 *                 raise ValueError("%i bpp image supports histogram for red, "
 *                                  "green, blue or black channels only, got %i."
 *                                  % (bpp, channel))             # <<<<<<<<<<<<<<
 *         elif bpp == 8:
 *             if channel != fi.FICC_BLACK:
 */
      __pyx_t_1 = PyInt_FromLong(__pyx_v_bpp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyInt_FromLong(__pyx_v_channel); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_t_1 = 0;
      __pyx_t_7 = 0;
      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_112), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_7));
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
      __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L3;
    }
    __pyx_L3:;
    break;

    /* "smc/freeimage/_freeimage.pyx":1480
 *                                  "green, blue or black channels only, got %i."
 *                                  % (bpp, channel))
 *         elif bpp == 8:             # <<<<<<<<<<<<<<
 *             if channel != fi.FICC_BLACK:
 *                 raise ValueError("8 bpp image supports histogram for black "
 */
    case 8:

    /* "smc/freeimage/_freeimage.pyx":1481
 *                                  % (bpp, channel))
 *         elif bpp == 8:
 *             if channel != fi.FICC_BLACK:             # <<<<<<<<<<<<<<
 *                 raise ValueError("8 bpp image supports histogram for black "
 *                                 "channel only, got %i." % channel)
 */
    __pyx_t_2 = (__pyx_v_channel != FICC_BLACK);
    if (__pyx_t_2) {

      /* "smc/freeimage/_freeimage.pyx":1483
 *             if channel != fi.FICC_BLACK:
 *                 raise ValueError("8 bpp image supports histogram for black "
 *                                 "channel only, got %i." % channel)             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("%i bpp is not supported by histogram function."
 */
      __pyx_t_7 = PyInt_FromLong(__pyx_v_channel); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_113), __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_8));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L4;
    }
    __pyx_L4:;
    break;
    default:

    /* "smc/freeimage/_freeimage.pyx":1486
 *         else:
 *             raise ValueError("%i bpp is not supported by histogram function."
 *                              % bpp)             # <<<<<<<<<<<<<<
 *         if not fi.FreeImage_GetHistogram(self._dib, hist,
 *                                       <fi.FREE_IMAGE_COLOR_CHANNEL>channel):
 */
    __pyx_t_8 = PyInt_FromLong(__pyx_v_bpp); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_114), __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_7));
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
    __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  /* "smc/freeimage/_freeimage.pyx":1488
 *                              % bpp)
 *         if not fi.FreeImage_GetHistogram(self._dib, hist,
 *                                       <fi.FREE_IMAGE_COLOR_CHANNEL>channel):             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Failed to retrieve histogram.")
 * 
 */
  __pyx_t_2 = (!FreeImage_GetHistogram(__pyx_v_self->_dib, __pyx_v_hist, ((enum FREE_IMAGE_COLOR_CHANNEL)__pyx_v_channel)));
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1489
 *         if not fi.FreeImage_GetHistogram(self._dib, hist,
 *                                       <fi.FREE_IMAGE_COLOR_CHANNEL>channel):
 *             raise dispatchFIError(OperationError, "Failed to retrieve histogram.")             # <<<<<<<<<<<<<<
 * 
 *         # TODO: use PyList_New?
 */
    __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_115));
    PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_kp_s_115));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_115));
    __pyx_t_8 = 0;
    __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "smc/freeimage/_freeimage.pyx":1492
 * 
 *         # TODO: use PyList_New?
 *         result = []             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < 256:
 *             result.append(int(hist[i]))
 */
  __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_result = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "smc/freeimage/_freeimage.pyx":1493
 *         # TODO: use PyList_New?
 *         result = []
 *         for i from 0 <= i < 256:             # <<<<<<<<<<<<<<
 *             result.append(int(hist[i]))
 * 
 */
  for (__pyx_v_i = 0; __pyx_v_i < 256; __pyx_v_i++) {

    /* "smc/freeimage/_freeimage.pyx":1494
 *         result = []
 *         for i from 0 <= i < 256:
 *             result.append(int(hist[i]))             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    __pyx_t_8 = __Pyx_PyInt_to_py_uint32_t((__pyx_v_hist[__pyx_v_i])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_9 = PyList_Append(__pyx_v_result, __pyx_t_8); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }

  /* "smc/freeimage/_freeimage.pyx":1496
 *             result.append(int(hist[i]))
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     # **********************************************************************
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.getHistogram", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_91hline(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_91hline(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  unsigned int __pyx_v_y;
  unsigned int __pyx_v_xstart;
  signed int __pyx_v_xend;
  unsigned int __pyx_v_linewidth;
  unsigned int __pyx_v_red;
  unsigned int __pyx_v_green;
  unsigned int __pyx_v_blue;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__y,&__pyx_n_s__xstart,&__pyx_n_s__xend,&__pyx_n_s__linewidth,&__pyx_n_s__red,&__pyx_n_s__green,&__pyx_n_s__blue,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("hline (wrapper)", 0);
  {
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__xstart);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("hline", 0, 3, 7, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1500; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__xend);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("hline", 0, 3, 7, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1500; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__linewidth);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__red);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__green);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__blue);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "hline") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1500; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[3]) {
      } else {
        __pyx_v_linewidth = ((unsigned int)1);
      }
      if (values[4]) {
      } else {
        __pyx_v_red = ((unsigned int)0);
      }
      if (values[5]) {
      } else {
        __pyx_v_green = ((unsigned int)0);
      }
      if (values[6]) {
      } else {
        __pyx_v_blue = ((unsigned int)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_y = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_y == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1500; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_xstart = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_xstart == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1500; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_xend = __Pyx_PyInt_AsSignedInt(values[2]); if (unlikely((__pyx_v_xend == (signed int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1500; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[3]) {
      __pyx_v_linewidth = __Pyx_PyInt_AsUnsignedInt(values[3]); if (unlikely((__pyx_v_linewidth == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1500; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_linewidth = ((unsigned int)1);
    }
    if (values[4]) {
      __pyx_v_red = __Pyx_PyInt_AsUnsignedInt(values[4]); if (unlikely((__pyx_v_red == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_red = ((unsigned int)0);
    }
    if (values[5]) {
      __pyx_v_green = __Pyx_PyInt_AsUnsignedInt(values[5]); if (unlikely((__pyx_v_green == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_green = ((unsigned int)0);
    }
    if (values[6]) {
      __pyx_v_blue = __Pyx_PyInt_AsUnsignedInt(values[6]); if (unlikely((__pyx_v_blue == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_blue = ((unsigned int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("hline", 0, 3, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1500; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.hline", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_90hline(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_y, __pyx_v_xstart, __pyx_v_xend, __pyx_v_linewidth, __pyx_v_red, __pyx_v_green, __pyx_v_blue);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1500
 *     # **********************************************************************
 *     # draw
 *     def hline(self, unsigned y, unsigned xstart, signed xend, unsigned linewidth=1,             # <<<<<<<<<<<<<<
 *               unsigned red=0, unsigned green=0, unsigned blue=0):
 *         cdef fi.FREE_IMAGE_TYPE image_type
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_90hline(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_y, unsigned int __pyx_v_xstart, signed int __pyx_v_xend, unsigned int __pyx_v_linewidth, unsigned int __pyx_v_red, unsigned int __pyx_v_green, unsigned int __pyx_v_blue) {
  enum FREE_IMAGE_TYPE __pyx_v_image_type;
  unsigned int __pyx_v_width;
  unsigned int __pyx_v_height;
  unsigned int __pyx_v_bpp;
  RGBQUAD __pyx_v_color;
  int __pyx_v_ys;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("hline", 0);

  /* "smc/freeimage/_freeimage.pyx":1507
 *         cdef int ys
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         image_type = fi.FreeImage_GetImageType(self._dib)
 *         width = fi.FreeImage_GetWidth(self._dib)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1508
 * 
 *         self._check_closed()
 *         image_type = fi.FreeImage_GetImageType(self._dib)             # <<<<<<<<<<<<<<
 *         width = fi.FreeImage_GetWidth(self._dib)
 *         height = fi.FreeImage_GetHeight(self._dib)
 */
  __pyx_v_image_type = FreeImage_GetImageType(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1509
 *         self._check_closed()
 *         image_type = fi.FreeImage_GetImageType(self._dib)
 *         width = fi.FreeImage_GetWidth(self._dib)             # <<<<<<<<<<<<<<
 *         height = fi.FreeImage_GetHeight(self._dib)
 *         bpp = fi.FreeImage_GetBPP(self._dib)
 */
  __pyx_v_width = FreeImage_GetWidth(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1510
 *         image_type = fi.FreeImage_GetImageType(self._dib)
 *         width = fi.FreeImage_GetWidth(self._dib)
 *         height = fi.FreeImage_GetHeight(self._dib)             # <<<<<<<<<<<<<<
 *         bpp = fi.FreeImage_GetBPP(self._dib)
 * 
 */
  __pyx_v_height = FreeImage_GetHeight(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1511
 *         width = fi.FreeImage_GetWidth(self._dib)
 *         height = fi.FreeImage_GetHeight(self._dib)
 *         bpp = fi.FreeImage_GetBPP(self._dib)             # <<<<<<<<<<<<<<
 * 
 *         if y > height:
 */
  __pyx_v_bpp = FreeImage_GetBPP(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1513
 *         bpp = fi.FreeImage_GetBPP(self._dib)
 * 
 *         if y > height:             # <<<<<<<<<<<<<<
 *             raise ValueError("y must be smaller than height of image")
 *         if xend == -1:
 */
  __pyx_t_2 = (__pyx_v_y > __pyx_v_height);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1514
 * 
 *         if y > height:
 *             raise ValueError("y must be smaller than height of image")             # <<<<<<<<<<<<<<
 *         if xend == -1:
 *             xend = width
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_117), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1515
 *         if y > height:
 *             raise ValueError("y must be smaller than height of image")
 *         if xend == -1:             # <<<<<<<<<<<<<<
 *             xend = width
 *         if xstart >= xend:
 */
  __pyx_t_2 = (__pyx_v_xend == -1);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1516
 *             raise ValueError("y must be smaller than height of image")
 *         if xend == -1:
 *             xend = width             # <<<<<<<<<<<<<<
 *         if xstart >= xend:
 *             raise ValueError("x start must be smaller than x end")
 */
    __pyx_v_xend = __pyx_v_width;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":1517
 *         if xend == -1:
 *             xend = width
 *         if xstart >= xend:             # <<<<<<<<<<<<<<
 *             raise ValueError("x start must be smaller than x end")
 *         if linewidth < 0 or linewidth >= height:
 */
  __pyx_t_2 = (__pyx_v_xstart >= __pyx_v_xend);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1518
 *             xend = width
 *         if xstart >= xend:
 *             raise ValueError("x start must be smaller than x end")             # <<<<<<<<<<<<<<
 *         if linewidth < 0 or linewidth >= height:
 *             raise ValueError("Invalid line height")
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_119), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "smc/freeimage/_freeimage.pyx":1519
 *         if xstart >= xend:
 *             raise ValueError("x start must be smaller than x end")
 *         if linewidth < 0 or linewidth >= height:             # <<<<<<<<<<<<<<
 *             raise ValueError("Invalid line height")
 * 
 */
  __pyx_t_2 = (__pyx_v_linewidth < 0);
  if (!__pyx_t_2) {
    __pyx_t_3 = (__pyx_v_linewidth >= __pyx_v_height);
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1520
 *             raise ValueError("x start must be smaller than x end")
 *         if linewidth < 0 or linewidth >= height:
 *             raise ValueError("Invalid line height")             # <<<<<<<<<<<<<<
 * 
 *         ys = y
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_121), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":1522
 *             raise ValueError("Invalid line height")
 * 
 *         ys = y             # <<<<<<<<<<<<<<
 *         if linewidth > 2:
 *             ys -= linewidth / 2
 */
  __pyx_v_ys = __pyx_v_y;

  /* "smc/freeimage/_freeimage.pyx":1523
 * 
 *         ys = y
 *         if linewidth > 2:             # <<<<<<<<<<<<<<
 *             ys -= linewidth / 2
 *         if ys < 0:
 */
  __pyx_t_4 = (__pyx_v_linewidth > 2);
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1524
 *         ys = y
 *         if linewidth > 2:
 *             ys -= linewidth / 2             # <<<<<<<<<<<<<<
 *         if ys < 0:
 *             ys = 0
 */
    __pyx_v_ys = (__pyx_v_ys - __Pyx_div_long(__pyx_v_linewidth, 2));
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "smc/freeimage/_freeimage.pyx":1525
 *         if linewidth > 2:
 *             ys -= linewidth / 2
 *         if ys < 0:             # <<<<<<<<<<<<<<
 *             ys = 0
 *         if ys + linewidth > height:
 */
  __pyx_t_4 = (__pyx_v_ys < 0);
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1526
 *             ys -= linewidth / 2
 *         if ys < 0:
 *             ys = 0             # <<<<<<<<<<<<<<
 *         if ys + linewidth > height:
 *             ys -= (ys + linewidth) - height
 */
    __pyx_v_ys = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "smc/freeimage/_freeimage.pyx":1527
 *         if ys < 0:
 *             ys = 0
 *         if ys + linewidth > height:             # <<<<<<<<<<<<<<
 *             ys -= (ys + linewidth) - height
 * 
 */
  __pyx_t_4 = ((__pyx_v_ys + __pyx_v_linewidth) > __pyx_v_height);
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1528
 *             ys = 0
 *         if ys + linewidth > height:
 *             ys -= (ys + linewidth) - height             # <<<<<<<<<<<<<<
 * 
 *         if image_type == fi.FIT_BITMAP and bpp == 24:
 */
    __pyx_v_ys = (__pyx_v_ys - ((__pyx_v_ys + __pyx_v_linewidth) - __pyx_v_height));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "smc/freeimage/_freeimage.pyx":1530
 *             ys -= (ys + linewidth) - height
 * 
 *         if image_type == fi.FIT_BITMAP and bpp == 24:             # <<<<<<<<<<<<<<
 *             color.rgbBlue = blue
 *             color.rgbRed = red
 */
  __pyx_t_4 = (__pyx_v_image_type == FIT_BITMAP);
  if (__pyx_t_4) {
    __pyx_t_2 = (__pyx_v_bpp == 24);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_4;
  }
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":1531
 * 
 *         if image_type == fi.FIT_BITMAP and bpp == 24:
 *             color.rgbBlue = blue             # <<<<<<<<<<<<<<
 *             color.rgbRed = red
 *             color.rgbGreen = green
 */
    __pyx_v_color.rgbBlue = __pyx_v_blue;

    /* "smc/freeimage/_freeimage.pyx":1532
 *         if image_type == fi.FIT_BITMAP and bpp == 24:
 *             color.rgbBlue = blue
 *             color.rgbRed = red             # <<<<<<<<<<<<<<
 *             color.rgbGreen = green
 *             color.rgbReserved = 0
 */
    __pyx_v_color.rgbRed = __pyx_v_red;

    /* "smc/freeimage/_freeimage.pyx":1533
 *             color.rgbBlue = blue
 *             color.rgbRed = red
 *             color.rgbGreen = green             # <<<<<<<<<<<<<<
 *             color.rgbReserved = 0
 *             #_sys.stderr.write("%s- %s-%s" % (ys, ys+linewidth, xstart, xend))
 */
    __pyx_v_color.rgbGreen = __pyx_v_green;

    /* "smc/freeimage/_freeimage.pyx":1534
 *             color.rgbRed = red
 *             color.rgbGreen = green
 *             color.rgbReserved = 0             # <<<<<<<<<<<<<<
 *             #_sys.stderr.write("%s- %s-%s" % (ys, ys+linewidth, xstart, xend))
 *             self.hline_rgb24(&color, linewidth, ys, xstart, xend)
 */
    __pyx_v_color.rgbReserved = 0;

    /* "smc/freeimage/_freeimage.pyx":1536
 *             color.rgbReserved = 0
 *             #_sys.stderr.write("%s- %s-%s" % (ys, ys+linewidth, xstart, xend))
 *             self.hline_rgb24(&color, linewidth, ys, xstart, xend)             # <<<<<<<<<<<<<<
 *         #elif image_type == fi.FIT_BITMAP and bpp == 1:
 *         #    # bitonal bitmap
 */
    ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->hline_rgb24(__pyx_v_self, (&__pyx_v_color), __pyx_v_linewidth, __pyx_v_ys, __pyx_v_xstart, __pyx_v_xend);
    goto __pyx_L10;
  }

  /* "smc/freeimage/_freeimage.pyx":1540
 *         #    # bitonal bitmap
 *         #    self.hline_1bpp(red, linewidth, ys, xstart, xend)
 *         elif image_type == fi.FIT_BITMAP and bpp == 8:             # <<<<<<<<<<<<<<
 *             # monochrome 8bit bitmap
 *             self.hline_mono(red & 0xff, linewidth, ys, xstart, xend)
 */
  __pyx_t_3 = (__pyx_v_image_type == FIT_BITMAP);
  if (__pyx_t_3) {
    __pyx_t_4 = (__pyx_v_bpp == 8);
    __pyx_t_2 = __pyx_t_4;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1542
 *         elif image_type == fi.FIT_BITMAP and bpp == 8:
 *             # monochrome 8bit bitmap
 *             self.hline_mono(red & 0xff, linewidth, ys, xstart, xend)             # <<<<<<<<<<<<<<
 *         else:
 *             raise NotImplementedError("hline for type: %i, bpp:  %i" %
 */
    ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->hline_mono(__pyx_v_self, (__pyx_v_red & 0xff), __pyx_v_linewidth, __pyx_v_ys, __pyx_v_xstart, __pyx_v_xend);
    goto __pyx_L10;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":1545
 *         else:
 *             raise NotImplementedError("hline for type: %i, bpp:  %i" %
 *                  (fi.FreeImage_GetImageType(self._dib), self.bpp))             # <<<<<<<<<<<<<<
 * 
 *     cdef int hline_rgb24(self, fi.RGBQUAD *color, unsigned linewidth,
 */
    __pyx_t_1 = PyInt_FromLong(FreeImage_GetImageType(__pyx_v_self->_dib)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__bpp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_122), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L10:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.hline", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1547
 *                  (fi.FreeImage_GetImageType(self._dib), self.bpp))
 * 
 *     cdef int hline_rgb24(self, fi.RGBQUAD *color, unsigned linewidth,             # <<<<<<<<<<<<<<
 *                    unsigned y0, unsigned xs, unsigned xe):
 *         """Horizontal line for RGB images
 */

static int __pyx_f_3smc_9freeimage_10_freeimage_5Image_hline_rgb24(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, RGBQUAD *__pyx_v_color, unsigned int __pyx_v_linewidth, unsigned int __pyx_v_y0, unsigned int __pyx_v_xs, unsigned int __pyx_v_xe) {
  BYTE *__pyx_v_pixel;
  CYTHON_UNUSED unsigned int __pyx_v_x;
  unsigned int __pyx_v_y;
  FIBITMAP *__pyx_v_dib;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  unsigned int __pyx_t_2;
  __Pyx_RefNannySetupContext("hline_rgb24", 0);

  /* "smc/freeimage/_freeimage.pyx":1555
 *         cdef fi.BYTE *pixel
 *         cdef unsigned x, y
 *         cdef fi.FIBITMAP* dib = self._dib             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_v_dib = __pyx_v_self->_dib;

  /* "smc/freeimage/_freeimage.pyx":1557
 *         cdef fi.FIBITMAP* dib = self._dib
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             for y from y0 <= y < y0+linewidth:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1558
 * 
 *         with nogil:
 *             for y from y0 <= y < y0+linewidth:             # <<<<<<<<<<<<<<
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 for x from 0 <= x < xe - xs:
 */
        __pyx_t_1 = (__pyx_v_y0 + __pyx_v_linewidth);
        for (__pyx_v_y = __pyx_v_y0; __pyx_v_y < __pyx_t_1; __pyx_v_y++) {

          /* "smc/freeimage/_freeimage.pyx":1559
 *         with nogil:
 *             for y from y0 <= y < y0+linewidth:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)             # <<<<<<<<<<<<<<
 *                 for x from 0 <= x < xe - xs:
 *                         pixel[fi.FI_RGBA_BLUE] = color.rgbBlue
 */
          __pyx_v_pixel = FreeImage_GetScanLine(__pyx_v_dib, __pyx_v_y);

          /* "smc/freeimage/_freeimage.pyx":1560
 *             for y from y0 <= y < y0+linewidth:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 for x from 0 <= x < xe - xs:             # <<<<<<<<<<<<<<
 *                         pixel[fi.FI_RGBA_BLUE] = color.rgbBlue
 *                         pixel[fi.FI_RGBA_GREEN] = color.rgbGreen
 */
          __pyx_t_2 = (__pyx_v_xe - __pyx_v_xs);
          for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {

            /* "smc/freeimage/_freeimage.pyx":1561
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 for x from 0 <= x < xe - xs:
 *                         pixel[fi.FI_RGBA_BLUE] = color.rgbBlue             # <<<<<<<<<<<<<<
 *                         pixel[fi.FI_RGBA_GREEN] = color.rgbGreen
 *                         pixel[fi.FI_RGBA_RED] = color.rgbRed
 */
            (__pyx_v_pixel[FI_RGBA_BLUE]) = __pyx_v_color->rgbBlue;

            /* "smc/freeimage/_freeimage.pyx":1562
 *                 for x from 0 <= x < xe - xs:
 *                         pixel[fi.FI_RGBA_BLUE] = color.rgbBlue
 *                         pixel[fi.FI_RGBA_GREEN] = color.rgbGreen             # <<<<<<<<<<<<<<
 *                         pixel[fi.FI_RGBA_RED] = color.rgbRed
 *                         pixel += 3
 */
            (__pyx_v_pixel[FI_RGBA_GREEN]) = __pyx_v_color->rgbGreen;

            /* "smc/freeimage/_freeimage.pyx":1563
 *                         pixel[fi.FI_RGBA_BLUE] = color.rgbBlue
 *                         pixel[fi.FI_RGBA_GREEN] = color.rgbGreen
 *                         pixel[fi.FI_RGBA_RED] = color.rgbRed             # <<<<<<<<<<<<<<
 *                         pixel += 3
 *         return 0
 */
            (__pyx_v_pixel[FI_RGBA_RED]) = __pyx_v_color->rgbRed;

            /* "smc/freeimage/_freeimage.pyx":1564
 *                         pixel[fi.FI_RGBA_GREEN] = color.rgbGreen
 *                         pixel[fi.FI_RGBA_RED] = color.rgbRed
 *                         pixel += 3             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
            __pyx_v_pixel = (__pyx_v_pixel + 3);
          }
        }
      }

      /* "smc/freeimage/_freeimage.pyx":1557
 *         cdef fi.FIBITMAP* dib = self._dib
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             for y from y0 <= y < y0+linewidth:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1565
 *                         pixel[fi.FI_RGBA_RED] = color.rgbRed
 *                         pixel += 3
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int hline_mono(self, fi.BYTE color, unsigned linewidth,
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1567
 *         return 0
 * 
 *     cdef int hline_mono(self, fi.BYTE color, unsigned linewidth,             # <<<<<<<<<<<<<<
 *                    unsigned y0, unsigned xs, unsigned xe):
 *         """Horizontal line for mono color images
 */

static int __pyx_f_3smc_9freeimage_10_freeimage_5Image_hline_mono(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, BYTE __pyx_v_color, unsigned int __pyx_v_linewidth, unsigned int __pyx_v_y0, unsigned int __pyx_v_xs, unsigned int __pyx_v_xe) {
  BYTE *__pyx_v_pixel;
  CYTHON_UNUSED unsigned int __pyx_v_x;
  unsigned int __pyx_v_y;
  FIBITMAP *__pyx_v_dib;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  unsigned int __pyx_t_2;
  __Pyx_RefNannySetupContext("hline_mono", 0);

  /* "smc/freeimage/_freeimage.pyx":1575
 *         cdef fi.BYTE *pixel
 *         cdef unsigned x, y
 *         cdef fi.FIBITMAP* dib = self._dib             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_v_dib = __pyx_v_self->_dib;

  /* "smc/freeimage/_freeimage.pyx":1577
 *         cdef fi.FIBITMAP* dib = self._dib
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             for y from y0 <= y < y0+linewidth:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1578
 * 
 *         with nogil:
 *             for y from y0 <= y < y0+linewidth:             # <<<<<<<<<<<<<<
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 for x from 0 <= x < xe - xs:
 */
        __pyx_t_1 = (__pyx_v_y0 + __pyx_v_linewidth);
        for (__pyx_v_y = __pyx_v_y0; __pyx_v_y < __pyx_t_1; __pyx_v_y++) {

          /* "smc/freeimage/_freeimage.pyx":1579
 *         with nogil:
 *             for y from y0 <= y < y0+linewidth:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)             # <<<<<<<<<<<<<<
 *                 for x from 0 <= x < xe - xs:
 *                         pixel[0] = color
 */
          __pyx_v_pixel = FreeImage_GetScanLine(__pyx_v_dib, __pyx_v_y);

          /* "smc/freeimage/_freeimage.pyx":1580
 *             for y from y0 <= y < y0+linewidth:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 for x from 0 <= x < xe - xs:             # <<<<<<<<<<<<<<
 *                         pixel[0] = color
 *                         pixel += 1
 */
          __pyx_t_2 = (__pyx_v_xe - __pyx_v_xs);
          for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {

            /* "smc/freeimage/_freeimage.pyx":1581
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 for x from 0 <= x < xe - xs:
 *                         pixel[0] = color             # <<<<<<<<<<<<<<
 *                         pixel += 1
 *         return 0
 */
            (__pyx_v_pixel[0]) = __pyx_v_color;

            /* "smc/freeimage/_freeimage.pyx":1582
 *                 for x from 0 <= x < xe - xs:
 *                         pixel[0] = color
 *                         pixel += 1             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
            __pyx_v_pixel = (__pyx_v_pixel + 1);
          }
        }
      }

      /* "smc/freeimage/_freeimage.pyx":1577
 *         cdef fi.FIBITMAP* dib = self._dib
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             for y from y0 <= y < y0+linewidth:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1583
 *                         pixel[0] = color
 *                         pixel += 1
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * #    cdef int hline_1bpp(self, fi.BYTE color, unsigned linewidth,
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_93vline(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_93vline(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  unsigned int __pyx_v_x;
  unsigned int __pyx_v_ystart;
  signed int __pyx_v_yend;
  unsigned int __pyx_v_linewidth;
  unsigned int __pyx_v_red;
  unsigned int __pyx_v_green;
  unsigned int __pyx_v_blue;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__ystart,&__pyx_n_s__yend,&__pyx_n_s__linewidth,&__pyx_n_s__red,&__pyx_n_s__green,&__pyx_n_s__blue,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("vline (wrapper)", 0);
  {
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ystart);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("vline", 0, 3, 7, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__yend);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("vline", 0, 3, 7, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__linewidth);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__red);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__green);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__blue);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "vline") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[3]) {
      } else {
        __pyx_v_linewidth = ((unsigned int)1);
      }
      if (values[4]) {
      } else {
        __pyx_v_red = ((unsigned int)0);
      }
      if (values[5]) {
      } else {
        __pyx_v_green = ((unsigned int)0);
      }
      if (values[6]) {
      } else {
        __pyx_v_blue = ((unsigned int)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_x = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_x == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_ystart = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_ystart == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_yend = __Pyx_PyInt_AsSignedInt(values[2]); if (unlikely((__pyx_v_yend == (signed int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[3]) {
      __pyx_v_linewidth = __Pyx_PyInt_AsUnsignedInt(values[3]); if (unlikely((__pyx_v_linewidth == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_linewidth = ((unsigned int)1);
    }
    if (values[4]) {
      __pyx_v_red = __Pyx_PyInt_AsUnsignedInt(values[4]); if (unlikely((__pyx_v_red == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_red = ((unsigned int)0);
    }
    if (values[5]) {
      __pyx_v_green = __Pyx_PyInt_AsUnsignedInt(values[5]); if (unlikely((__pyx_v_green == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_green = ((unsigned int)0);
    }
    if (values[6]) {
      __pyx_v_blue = __Pyx_PyInt_AsUnsignedInt(values[6]); if (unlikely((__pyx_v_blue == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_blue = ((unsigned int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("vline", 0, 3, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.vline", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_92vline(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self), __pyx_v_x, __pyx_v_ystart, __pyx_v_yend, __pyx_v_linewidth, __pyx_v_red, __pyx_v_green, __pyx_v_blue);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1607
 * 
 * 
 *     def vline(self, unsigned x, unsigned ystart, signed yend, unsigned linewidth=1,             # <<<<<<<<<<<<<<
 *               unsigned red=0, unsigned green=0, unsigned blue=0):
 *         cdef fi.FREE_IMAGE_TYPE image_type
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_92vline(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, unsigned int __pyx_v_x, unsigned int __pyx_v_ystart, signed int __pyx_v_yend, unsigned int __pyx_v_linewidth, unsigned int __pyx_v_red, unsigned int __pyx_v_green, unsigned int __pyx_v_blue) {
  enum FREE_IMAGE_TYPE __pyx_v_image_type;
  unsigned int __pyx_v_width;
  unsigned int __pyx_v_height;
  unsigned int __pyx_v_bpp;
  RGBQUAD __pyx_v_color;
  int __pyx_v_xs;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("vline", 0);

  /* "smc/freeimage/_freeimage.pyx":1614
 *         cdef int xs
 * 
 *         self._check_closed()             # <<<<<<<<<<<<<<
 *         image_type = fi.FreeImage_GetImageType(self._dib)
 *         width = fi.FreeImage_GetWidth(self._dib)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->_check_closed(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1615
 * 
 *         self._check_closed()
 *         image_type = fi.FreeImage_GetImageType(self._dib)             # <<<<<<<<<<<<<<
 *         width = fi.FreeImage_GetWidth(self._dib)
 *         height = fi.FreeImage_GetHeight(self._dib)
 */
  __pyx_v_image_type = FreeImage_GetImageType(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1616
 *         self._check_closed()
 *         image_type = fi.FreeImage_GetImageType(self._dib)
 *         width = fi.FreeImage_GetWidth(self._dib)             # <<<<<<<<<<<<<<
 *         height = fi.FreeImage_GetHeight(self._dib)
 *         bpp = fi.FreeImage_GetBPP(self._dib)
 */
  __pyx_v_width = FreeImage_GetWidth(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1617
 *         image_type = fi.FreeImage_GetImageType(self._dib)
 *         width = fi.FreeImage_GetWidth(self._dib)
 *         height = fi.FreeImage_GetHeight(self._dib)             # <<<<<<<<<<<<<<
 *         bpp = fi.FreeImage_GetBPP(self._dib)
 * 
 */
  __pyx_v_height = FreeImage_GetHeight(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1618
 *         width = fi.FreeImage_GetWidth(self._dib)
 *         height = fi.FreeImage_GetHeight(self._dib)
 *         bpp = fi.FreeImage_GetBPP(self._dib)             # <<<<<<<<<<<<<<
 * 
 *         if x > width:
 */
  __pyx_v_bpp = FreeImage_GetBPP(__pyx_v_self->_dib);

  /* "smc/freeimage/_freeimage.pyx":1620
 *         bpp = fi.FreeImage_GetBPP(self._dib)
 * 
 *         if x > width:             # <<<<<<<<<<<<<<
 *             raise ValueError("x must be smaller than width of image")
 *         if yend == -1:
 */
  __pyx_t_2 = (__pyx_v_x > __pyx_v_width);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1621
 * 
 *         if x > width:
 *             raise ValueError("x must be smaller than width of image")             # <<<<<<<<<<<<<<
 *         if yend == -1:
 *             yend = height
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_124), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1622
 *         if x > width:
 *             raise ValueError("x must be smaller than width of image")
 *         if yend == -1:             # <<<<<<<<<<<<<<
 *             yend = height
 *         if ystart >= yend:
 */
  __pyx_t_2 = (__pyx_v_yend == -1);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1623
 *             raise ValueError("x must be smaller than width of image")
 *         if yend == -1:
 *             yend = height             # <<<<<<<<<<<<<<
 *         if ystart >= yend:
 *             raise ValueError("y start must be smaller than y end")
 */
    __pyx_v_yend = __pyx_v_height;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":1624
 *         if yend == -1:
 *             yend = height
 *         if ystart >= yend:             # <<<<<<<<<<<<<<
 *             raise ValueError("y start must be smaller than y end")
 *         if linewidth < 0 or linewidth >= width:
 */
  __pyx_t_2 = (__pyx_v_ystart >= __pyx_v_yend);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1625
 *             yend = height
 *         if ystart >= yend:
 *             raise ValueError("y start must be smaller than y end")             # <<<<<<<<<<<<<<
 *         if linewidth < 0 or linewidth >= width:
 *             raise ValueError("Invalid line width")
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_126), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "smc/freeimage/_freeimage.pyx":1626
 *         if ystart >= yend:
 *             raise ValueError("y start must be smaller than y end")
 *         if linewidth < 0 or linewidth >= width:             # <<<<<<<<<<<<<<
 *             raise ValueError("Invalid line width")
 * 
 */
  __pyx_t_2 = (__pyx_v_linewidth < 0);
  if (!__pyx_t_2) {
    __pyx_t_3 = (__pyx_v_linewidth >= __pyx_v_width);
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1627
 *             raise ValueError("y start must be smaller than y end")
 *         if linewidth < 0 or linewidth >= width:
 *             raise ValueError("Invalid line width")             # <<<<<<<<<<<<<<
 * 
 *         xs = x
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_128), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "smc/freeimage/_freeimage.pyx":1629
 *             raise ValueError("Invalid line width")
 * 
 *         xs = x             # <<<<<<<<<<<<<<
 *         if linewidth > 2:
 *             xs -= linewidth / 2
 */
  __pyx_v_xs = __pyx_v_x;

  /* "smc/freeimage/_freeimage.pyx":1630
 * 
 *         xs = x
 *         if linewidth > 2:             # <<<<<<<<<<<<<<
 *             xs -= linewidth / 2
 *         if xs < 0:
 */
  __pyx_t_4 = (__pyx_v_linewidth > 2);
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1631
 *         xs = x
 *         if linewidth > 2:
 *             xs -= linewidth / 2             # <<<<<<<<<<<<<<
 *         if xs < 0:
 *             xs = 0
 */
    __pyx_v_xs = (__pyx_v_xs - __Pyx_div_long(__pyx_v_linewidth, 2));
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "smc/freeimage/_freeimage.pyx":1632
 *         if linewidth > 2:
 *             xs -= linewidth / 2
 *         if xs < 0:             # <<<<<<<<<<<<<<
 *             xs = 0
 *         if xs + linewidth > width:
 */
  __pyx_t_4 = (__pyx_v_xs < 0);
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1633
 *             xs -= linewidth / 2
 *         if xs < 0:
 *             xs = 0             # <<<<<<<<<<<<<<
 *         if xs + linewidth > width:
 *             xs -= (xs + linewidth) - width
 */
    __pyx_v_xs = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "smc/freeimage/_freeimage.pyx":1634
 *         if xs < 0:
 *             xs = 0
 *         if xs + linewidth > width:             # <<<<<<<<<<<<<<
 *             xs -= (xs + linewidth) - width
 * 
 */
  __pyx_t_4 = ((__pyx_v_xs + __pyx_v_linewidth) > __pyx_v_width);
  if (__pyx_t_4) {

    /* "smc/freeimage/_freeimage.pyx":1635
 *             xs = 0
 *         if xs + linewidth > width:
 *             xs -= (xs + linewidth) - width             # <<<<<<<<<<<<<<
 * 
 *         #if xs < 0 or (xs + linewidth) > width:
 */
    __pyx_v_xs = (__pyx_v_xs - ((__pyx_v_xs + __pyx_v_linewidth) - __pyx_v_width));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "smc/freeimage/_freeimage.pyx":1642
 *         #    raise ValueError
 * 
 *         if image_type == fi.FIT_BITMAP and bpp == 24:             # <<<<<<<<<<<<<<
 *             color.rgbBlue = blue
 *             color.rgbRed = red
 */
  __pyx_t_4 = (__pyx_v_image_type == FIT_BITMAP);
  if (__pyx_t_4) {
    __pyx_t_2 = (__pyx_v_bpp == 24);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_4;
  }
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":1643
 * 
 *         if image_type == fi.FIT_BITMAP and bpp == 24:
 *             color.rgbBlue = blue             # <<<<<<<<<<<<<<
 *             color.rgbRed = red
 *             color.rgbGreen = green
 */
    __pyx_v_color.rgbBlue = __pyx_v_blue;

    /* "smc/freeimage/_freeimage.pyx":1644
 *         if image_type == fi.FIT_BITMAP and bpp == 24:
 *             color.rgbBlue = blue
 *             color.rgbRed = red             # <<<<<<<<<<<<<<
 *             color.rgbGreen = green
 *             color.rgbReserved = 0
 */
    __pyx_v_color.rgbRed = __pyx_v_red;

    /* "smc/freeimage/_freeimage.pyx":1645
 *             color.rgbBlue = blue
 *             color.rgbRed = red
 *             color.rgbGreen = green             # <<<<<<<<<<<<<<
 *             color.rgbReserved = 0
 *             #_sys.stderr.write("%s-%s %s-%s" % (xs, xs+linewidth, ystart, yend))
 */
    __pyx_v_color.rgbGreen = __pyx_v_green;

    /* "smc/freeimage/_freeimage.pyx":1646
 *             color.rgbRed = red
 *             color.rgbGreen = green
 *             color.rgbReserved = 0             # <<<<<<<<<<<<<<
 *             #_sys.stderr.write("%s-%s %s-%s" % (xs, xs+linewidth, ystart, yend))
 *             self.vline_rgb24(&color, linewidth, xs, ystart, yend)
 */
    __pyx_v_color.rgbReserved = 0;

    /* "smc/freeimage/_freeimage.pyx":1648
 *             color.rgbReserved = 0
 *             #_sys.stderr.write("%s-%s %s-%s" % (xs, xs+linewidth, ystart, yend))
 *             self.vline_rgb24(&color, linewidth, xs, ystart, yend)             # <<<<<<<<<<<<<<
 *         #elif image_type == fi.FIT_BITMAP and bpp == 1:
 *         #    # bitonal bitmap
 */
    ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->vline_rgb24(__pyx_v_self, (&__pyx_v_color), __pyx_v_linewidth, __pyx_v_xs, __pyx_v_ystart, __pyx_v_yend);
    goto __pyx_L10;
  }

  /* "smc/freeimage/_freeimage.pyx":1652
 *         #    # bitonal bitmap
 *         #    self.vline_1bpp(red, linewidth, xs, ystart, yend)
 *         elif image_type == fi.FIT_BITMAP and bpp == 8:             # <<<<<<<<<<<<<<
 *             # monochrome 8bit bitmap
 *             self.vline_mono(red & 0xff, linewidth, xs, ystart, yend)
 */
  __pyx_t_3 = (__pyx_v_image_type == FIT_BITMAP);
  if (__pyx_t_3) {
    __pyx_t_4 = (__pyx_v_bpp == 8);
    __pyx_t_2 = __pyx_t_4;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1654
 *         elif image_type == fi.FIT_BITMAP and bpp == 8:
 *             # monochrome 8bit bitmap
 *             self.vline_mono(red & 0xff, linewidth, xs, ystart, yend)             # <<<<<<<<<<<<<<
 *         else:
 *             raise NotImplementedError("vline for type: %i, bpp:  %i" %
 */
    ((struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self->__pyx_vtab)->vline_mono(__pyx_v_self, (__pyx_v_red & 0xff), __pyx_v_linewidth, __pyx_v_xs, __pyx_v_ystart, __pyx_v_yend);
    goto __pyx_L10;
  }
  /*else*/ {

    /* "smc/freeimage/_freeimage.pyx":1657
 *         else:
 *             raise NotImplementedError("vline for type: %i, bpp:  %i" %
 *                                       (image_type, bpp))             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_image_type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyLong_FromUnsignedLong(__pyx_v_bpp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_129), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L10:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.vline", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1660
 * 
 * 
 *     cdef int vline_rgb24(self, fi.RGBQUAD *color, unsigned linewidth,             # <<<<<<<<<<<<<<
 *                    unsigned x0, unsigned ys, unsigned ye):
 *         """Vertical line for RGB images
 */

static int __pyx_f_3smc_9freeimage_10_freeimage_5Image_vline_rgb24(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, RGBQUAD *__pyx_v_color, unsigned int __pyx_v_linewidth, unsigned int __pyx_v_x0, unsigned int __pyx_v_ys, unsigned int __pyx_v_ye) {
  BYTE *__pyx_v_pixel;
  CYTHON_UNUSED unsigned int __pyx_v_x;
  unsigned int __pyx_v_y;
  FIBITMAP *__pyx_v_dib;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  unsigned int __pyx_t_2;
  __Pyx_RefNannySetupContext("vline_rgb24", 0);

  /* "smc/freeimage/_freeimage.pyx":1668
 *         cdef fi.BYTE *pixel
 *         cdef unsigned x, y
 *         cdef fi.FIBITMAP* dib = self._dib             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_v_dib = __pyx_v_self->_dib;

  /* "smc/freeimage/_freeimage.pyx":1670
 *         cdef fi.FIBITMAP* dib = self._dib
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             for y from ys <= y < ye:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1671
 * 
 *         with nogil:
 *             for y from ys <= y < ye:             # <<<<<<<<<<<<<<
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 pixel += x0 * 3
 */
        __pyx_t_1 = __pyx_v_ye;
        for (__pyx_v_y = __pyx_v_ys; __pyx_v_y < __pyx_t_1; __pyx_v_y++) {

          /* "smc/freeimage/_freeimage.pyx":1672
 *         with nogil:
 *             for y from ys <= y < ye:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)             # <<<<<<<<<<<<<<
 *                 pixel += x0 * 3
 *                 for x from 0 <= x < linewidth:
 */
          __pyx_v_pixel = FreeImage_GetScanLine(__pyx_v_dib, __pyx_v_y);

          /* "smc/freeimage/_freeimage.pyx":1673
 *             for y from ys <= y < ye:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 pixel += x0 * 3             # <<<<<<<<<<<<<<
 *                 for x from 0 <= x < linewidth:
 *                     pixel[fi.FI_RGBA_BLUE] = color.rgbBlue
 */
          __pyx_v_pixel = (__pyx_v_pixel + (__pyx_v_x0 * 3));

          /* "smc/freeimage/_freeimage.pyx":1674
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 pixel += x0 * 3
 *                 for x from 0 <= x < linewidth:             # <<<<<<<<<<<<<<
 *                     pixel[fi.FI_RGBA_BLUE] = color.rgbBlue
 *                     pixel[fi.FI_RGBA_GREEN] = color.rgbGreen
 */
          __pyx_t_2 = __pyx_v_linewidth;
          for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {

            /* "smc/freeimage/_freeimage.pyx":1675
 *                 pixel += x0 * 3
 *                 for x from 0 <= x < linewidth:
 *                     pixel[fi.FI_RGBA_BLUE] = color.rgbBlue             # <<<<<<<<<<<<<<
 *                     pixel[fi.FI_RGBA_GREEN] = color.rgbGreen
 *                     pixel[fi.FI_RGBA_RED] = color.rgbRed
 */
            (__pyx_v_pixel[FI_RGBA_BLUE]) = __pyx_v_color->rgbBlue;

            /* "smc/freeimage/_freeimage.pyx":1676
 *                 for x from 0 <= x < linewidth:
 *                     pixel[fi.FI_RGBA_BLUE] = color.rgbBlue
 *                     pixel[fi.FI_RGBA_GREEN] = color.rgbGreen             # <<<<<<<<<<<<<<
 *                     pixel[fi.FI_RGBA_RED] = color.rgbRed
 *                     pixel += 3
 */
            (__pyx_v_pixel[FI_RGBA_GREEN]) = __pyx_v_color->rgbGreen;

            /* "smc/freeimage/_freeimage.pyx":1677
 *                     pixel[fi.FI_RGBA_BLUE] = color.rgbBlue
 *                     pixel[fi.FI_RGBA_GREEN] = color.rgbGreen
 *                     pixel[fi.FI_RGBA_RED] = color.rgbRed             # <<<<<<<<<<<<<<
 *                     pixel += 3
 *         return 0
 */
            (__pyx_v_pixel[FI_RGBA_RED]) = __pyx_v_color->rgbRed;

            /* "smc/freeimage/_freeimage.pyx":1678
 *                     pixel[fi.FI_RGBA_GREEN] = color.rgbGreen
 *                     pixel[fi.FI_RGBA_RED] = color.rgbRed
 *                     pixel += 3             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
            __pyx_v_pixel = (__pyx_v_pixel + 3);
          }
        }
      }

      /* "smc/freeimage/_freeimage.pyx":1670
 *         cdef fi.FIBITMAP* dib = self._dib
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             for y from ys <= y < ye:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1679
 *                     pixel[fi.FI_RGBA_RED] = color.rgbRed
 *                     pixel += 3
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int vline_mono(self, fi.BYTE color, unsigned linewidth,
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1681
 *         return 0
 * 
 *     cdef int vline_mono(self, fi.BYTE color, unsigned linewidth,             # <<<<<<<<<<<<<<
 *                    unsigned x0, unsigned ys, unsigned ye):
 *         """Vertical line for mono color images
 */

static int __pyx_f_3smc_9freeimage_10_freeimage_5Image_vline_mono(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self, BYTE __pyx_v_color, unsigned int __pyx_v_linewidth, unsigned int __pyx_v_x0, unsigned int __pyx_v_ys, unsigned int __pyx_v_ye) {
  BYTE *__pyx_v_pixel;
  CYTHON_UNUSED unsigned int __pyx_v_x;
  unsigned int __pyx_v_y;
  FIBITMAP *__pyx_v_dib;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  unsigned int __pyx_t_1;
  unsigned int __pyx_t_2;
  __Pyx_RefNannySetupContext("vline_mono", 0);

  /* "smc/freeimage/_freeimage.pyx":1689
 *         cdef fi.BYTE *pixel
 *         cdef unsigned x, y
 *         cdef fi.FIBITMAP* dib = self._dib             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_v_dib = __pyx_v_self->_dib;

  /* "smc/freeimage/_freeimage.pyx":1691
 *         cdef fi.FIBITMAP* dib = self._dib
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             for y from ys <= y < ye:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1692
 * 
 *         with nogil:
 *             for y from ys <= y < ye:             # <<<<<<<<<<<<<<
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 pixel += x0
 */
        __pyx_t_1 = __pyx_v_ye;
        for (__pyx_v_y = __pyx_v_ys; __pyx_v_y < __pyx_t_1; __pyx_v_y++) {

          /* "smc/freeimage/_freeimage.pyx":1693
 *         with nogil:
 *             for y from ys <= y < ye:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)             # <<<<<<<<<<<<<<
 *                 pixel += x0
 *                 for x from 0 <= x < linewidth:
 */
          __pyx_v_pixel = FreeImage_GetScanLine(__pyx_v_dib, __pyx_v_y);

          /* "smc/freeimage/_freeimage.pyx":1694
 *             for y from ys <= y < ye:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 pixel += x0             # <<<<<<<<<<<<<<
 *                 for x from 0 <= x < linewidth:
 *                     pixel[0] = color
 */
          __pyx_v_pixel = (__pyx_v_pixel + __pyx_v_x0);

          /* "smc/freeimage/_freeimage.pyx":1695
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 *                 pixel += x0
 *                 for x from 0 <= x < linewidth:             # <<<<<<<<<<<<<<
 *                     pixel[0] = color
 *                     pixel += 1
 */
          __pyx_t_2 = __pyx_v_linewidth;
          for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {

            /* "smc/freeimage/_freeimage.pyx":1696
 *                 pixel += x0
 *                 for x from 0 <= x < linewidth:
 *                     pixel[0] = color             # <<<<<<<<<<<<<<
 *                     pixel += 1
 *         return 0
 */
            (__pyx_v_pixel[0]) = __pyx_v_color;

            /* "smc/freeimage/_freeimage.pyx":1697
 *                 for x from 0 <= x < linewidth:
 *                     pixel[0] = color
 *                     pixel += 1             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
            __pyx_v_pixel = (__pyx_v_pixel + 1);
          }
        }
      }

      /* "smc/freeimage/_freeimage.pyx":1691
 *         cdef fi.FIBITMAP* dib = self._dib
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             for y from ys <= y < ye:
 *                 pixel = fi.FreeImage_GetScanLine(dib, y)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1698
 *                     pixel[0] = color
 *                     pixel += 1
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * #    cdef int vline_1bpp(self, fi.BYTE color, unsigned linewidth,
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_5width_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_5width_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_5width___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":652
 *     Create a new Image. Either filename or buffer must applied.
 *     """
 *     cdef readonly unsigned int width             # <<<<<<<<<<<<<<
 *     cdef readonly unsigned int height
 *     cdef fi.FREE_IMAGE_FORMAT _format
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_5width___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.width.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_6height_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_5Image_6height_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_5Image_6height___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":653
 *     """
 *     cdef readonly unsigned int width
 *     cdef readonly unsigned int height             # <<<<<<<<<<<<<<
 *     cdef fi.FREE_IMAGE_FORMAT _format
 *     cdef char* _filename
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_5Image_6height___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.Image.height.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_15FormatInfo_from_filename(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_14FormatInfo_from_filename[] = "from_filename(filename) -> FormatInfo instance\n\n    Guess format from filename\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_15FormatInfo_from_filename = {__Pyx_NAMESTR("FormatInfo_from_filename"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_15FormatInfo_from_filename, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_14FormatInfo_from_filename)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_15FormatInfo_from_filename(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_filename = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__cls,&__pyx_n_s__filename,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("FormatInfo_from_filename (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cls);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("FormatInfo_from_filename", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "FormatInfo_from_filename") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_cls = values[0];
    __pyx_v_filename = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("FormatInfo_from_filename", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo_from_filename", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_14FormatInfo_from_filename(__pyx_self, __pyx_v_cls, __pyx_v_filename);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1724
 * # Format Info
 * 
 * def FormatInfo_from_filename(cls, filename):             # <<<<<<<<<<<<<<
 *     """from_filename(filename) -> FormatInfo instance
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_14FormatInfo_from_filename(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_filename) {
  PyObject *__pyx_v_format = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("FormatInfo_from_filename", 0);
  __Pyx_INCREF(__pyx_v_filename);

  /* "smc/freeimage/_freeimage.pyx":1729
 *     Guess format from filename
 *     """
 *     filename = _decodeFilename(filename)             # <<<<<<<<<<<<<<
 *     format = fi.FreeImage_GetFIFFromFilename(filename)
 *     return cls(format)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_filename);
  __pyx_v_filename = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1730
 *     """
 *     filename = _decodeFilename(filename)
 *     format = fi.FreeImage_GetFIFFromFilename(filename)             # <<<<<<<<<<<<<<
 *     return cls(format)
 * 
 */
  __pyx_t_2 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromLong(FreeImage_GetFIFFromFilename(__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_format = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1731
 *     filename = _decodeFilename(filename)
 *     format = fi.FreeImage_GetFIFFromFilename(filename)
 *     return cls(format)             # <<<<<<<<<<<<<<
 * 
 * def FormatInfo_from_file(cls, filename):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_format);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_format);
  __Pyx_GIVEREF(__pyx_v_format);
  __pyx_t_3 = PyObject_Call(__pyx_v_cls, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo_from_filename", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_format);
  __Pyx_XDECREF(__pyx_v_filename);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_17FormatInfo_from_file(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_16FormatInfo_from_file[] = "from_file(path) -> FormatInfo instance\n\n    Guess format from file\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_17FormatInfo_from_file = {__Pyx_NAMESTR("FormatInfo_from_file"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_17FormatInfo_from_file, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_16FormatInfo_from_file)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_17FormatInfo_from_file(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_filename = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__cls,&__pyx_n_s__filename,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("FormatInfo_from_file (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cls);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("FormatInfo_from_file", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "FormatInfo_from_file") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_cls = values[0];
    __pyx_v_filename = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("FormatInfo_from_file", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo_from_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_16FormatInfo_from_file(__pyx_self, __pyx_v_cls, __pyx_v_filename);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1733
 *     return cls(format)
 * 
 * def FormatInfo_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *     """from_file(path) -> FormatInfo instance
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_16FormatInfo_from_file(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_filename) {
  PyObject *__pyx_v_format = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("FormatInfo_from_file", 0);
  __Pyx_INCREF(__pyx_v_filename);

  /* "smc/freeimage/_freeimage.pyx":1738
 *     Guess format from file
 *     """
 *     filename = _decodeFilename(filename)             # <<<<<<<<<<<<<<
 *     format = fi.FreeImage_GetFileType(filename, 0)
 *     return cls(format)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_filename);
  __pyx_v_filename = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1739
 *     """
 *     filename = _decodeFilename(filename)
 *     format = fi.FreeImage_GetFileType(filename, 0)             # <<<<<<<<<<<<<<
 *     return cls(format)
 * 
 */
  __pyx_t_2 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromLong(FreeImage_GetFileType(__pyx_t_2, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_format = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1740
 *     filename = _decodeFilename(filename)
 *     format = fi.FreeImage_GetFileType(filename, 0)
 *     return cls(format)             # <<<<<<<<<<<<<<
 * 
 * def FormatInfo_from_mimetype(cls, mime):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_format);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_format);
  __Pyx_GIVEREF(__pyx_v_format);
  __pyx_t_3 = PyObject_Call(__pyx_v_cls, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo_from_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_format);
  __Pyx_XDECREF(__pyx_v_filename);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_19FormatInfo_from_mimetype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_18FormatInfo_from_mimetype[] = "from_mimetype(mime) -> FormatInfo instance\n\n    Guess format from mime type string\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_19FormatInfo_from_mimetype = {__Pyx_NAMESTR("FormatInfo_from_mimetype"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_19FormatInfo_from_mimetype, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_18FormatInfo_from_mimetype)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_19FormatInfo_from_mimetype(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_mime = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__cls,&__pyx_n_s__mime,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("FormatInfo_from_mimetype (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cls);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mime);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("FormatInfo_from_mimetype", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "FormatInfo_from_mimetype") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_cls = values[0];
    __pyx_v_mime = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("FormatInfo_from_mimetype", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo_from_mimetype", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_18FormatInfo_from_mimetype(__pyx_self, __pyx_v_cls, __pyx_v_mime);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1742
 *     return cls(format)
 * 
 * def FormatInfo_from_mimetype(cls, mime):             # <<<<<<<<<<<<<<
 *     """from_mimetype(mime) -> FormatInfo instance
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_18FormatInfo_from_mimetype(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_mime) {
  PyObject *__pyx_v_format = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("FormatInfo_from_mimetype", 0);
  __Pyx_INCREF(__pyx_v_mime);

  /* "smc/freeimage/_freeimage.pyx":1747
 *     Guess format from mime type string
 *     """
 *     mime = _decodeFilename(mime)             # <<<<<<<<<<<<<<
 *     format = fi.FreeImage_GetFIFFromMime(mime)
 *     return cls(format)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(__pyx_v_mime)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_mime);
  __pyx_v_mime = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1748
 *     """
 *     mime = _decodeFilename(mime)
 *     format = fi.FreeImage_GetFIFFromMime(mime)             # <<<<<<<<<<<<<<
 *     return cls(format)
 * 
 */
  __pyx_t_2 = PyBytes_AsString(__pyx_v_mime); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromLong(FreeImage_GetFIFFromMime(__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_format = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1749
 *     mime = _decodeFilename(mime)
 *     format = fi.FreeImage_GetFIFFromMime(mime)
 *     return cls(format)             # <<<<<<<<<<<<<<
 * 
 * cdef class FormatInfo:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_format);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_format);
  __Pyx_GIVEREF(__pyx_v_format);
  __pyx_t_3 = PyObject_Call(__pyx_v_cls, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo_from_mimetype", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_format);
  __Pyx_XDECREF(__pyx_v_mime);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_format;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__format,0};
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_format = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_format == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo___init__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self), __pyx_v_format);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1754
 *     cdef fi.FREE_IMAGE_FORMAT _format
 * 
 *     def __init__(self, int format):             # <<<<<<<<<<<<<<
 *         if format == fi.FIF_UNKNOWN:
 *             raise dispatchFIError(OperationError, "Unable to detect format.")
 */

static int __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo___init__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self, int __pyx_v_format) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "smc/freeimage/_freeimage.pyx":1755
 * 
 *     def __init__(self, int format):
 *         if format == fi.FIF_UNKNOWN:             # <<<<<<<<<<<<<<
 *             raise dispatchFIError(OperationError, "Unable to detect format.")
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() +1:
 */
  __pyx_t_1 = (__pyx_v_format == FIF_UNKNOWN);
  if (__pyx_t_1) {

    /* "smc/freeimage/_freeimage.pyx":1756
 *     def __init__(self, int format):
 *         if format == fi.FIF_UNKNOWN:
 *             raise dispatchFIError(OperationError, "Unable to detect format.")             # <<<<<<<<<<<<<<
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() +1:
 *             raise ValueError("Invalid format %i" % format)
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_130));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_kp_s_130));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_130));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1757
 *         if format == fi.FIF_UNKNOWN:
 *             raise dispatchFIError(OperationError, "Unable to detect format.")
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() +1:             # <<<<<<<<<<<<<<
 *             raise ValueError("Invalid format %i" % format)
 *         self._format = <fi.FREE_IMAGE_FORMAT>format
 */
  __pyx_t_1 = (__pyx_v_format < 0);
  if (!__pyx_t_1) {
    __pyx_t_5 = (__pyx_v_format > (FreeImage_GetFIFCount() + 1));
    __pyx_t_6 = __pyx_t_5;
  } else {
    __pyx_t_6 = __pyx_t_1;
  }
  if (__pyx_t_6) {

    /* "smc/freeimage/_freeimage.pyx":1758
 *             raise dispatchFIError(OperationError, "Unable to detect format.")
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() +1:
 *             raise ValueError("Invalid format %i" % format)             # <<<<<<<<<<<<<<
 *         self._format = <fi.FREE_IMAGE_FORMAT>format
 * 
 */
    __pyx_t_3 = PyInt_FromLong(__pyx_v_format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_79), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "smc/freeimage/_freeimage.pyx":1759
 *         if format < 0 or format > fi.FreeImage_GetFIFCount() +1:
 *             raise ValueError("Invalid format %i" % format)
 *         self._format = <fi.FREE_IMAGE_FORMAT>format             # <<<<<<<<<<<<<<
 * 
 *     from_filename = classmethod(FormatInfo_from_filename)
 */
  __pyx_v_self->_format = ((enum FREE_IMAGE_FORMAT)__pyx_v_format);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_3__int__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_3__int__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__int__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_2__int__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1765
 *     from_mimetype = classmethod(FormatInfo_from_mimetype)
 * 
 *     def __int__(self):             # <<<<<<<<<<<<<<
 *         return self._format
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_2__int__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__int__", 0);

  /* "smc/freeimage/_freeimage.pyx":1766
 * 
 *     def __int__(self):
 *         return self._format             # <<<<<<<<<<<<<<
 * 
 *     property format:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.__int__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_6format_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_6format_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_6format___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1769
 * 
 *     property format:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._format
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_6format___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1770
 *     property format:
 *         def __get__(self):
 *             return self._format             # <<<<<<<<<<<<<<
 * 
 *     property mimetype:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.format.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_8mimetype_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_8mimetype_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_8mimetype___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1773
 * 
 *     property mimetype:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return funicode(fi.FreeImage_GetFIFMimeType(self._format))
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_8mimetype___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1774
 *     property mimetype:
 *         def __get__(self):
 *             return funicode(fi.FreeImage_GetFIFMimeType(self._format))             # <<<<<<<<<<<<<<
 * 
 *     property name:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(FreeImage_GetFIFMimeType(__pyx_v_self->_format)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.mimetype.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_4name___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1777
 * 
 *     property name:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return funicode(fi.FreeImage_GetFormatFromFIF(self._format))
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_4name___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1778
 *     property name:
 *         def __get__(self):
 *             return funicode(fi.FreeImage_GetFormatFromFIF(self._format))             # <<<<<<<<<<<<<<
 * 
 *     property description:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(FreeImage_GetFormatFromFIF(__pyx_v_self->_format)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.name.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_11description_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_11description_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_11description___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1781
 * 
 *     property description:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return funicode(fi.FreeImage_GetFIFDescription(self._format))
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_11description___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1782
 *     property description:
 *         def __get__(self):
 *             return funicode(fi.FreeImage_GetFIFDescription(self._format))             # <<<<<<<<<<<<<<
 * 
 *     property magic_reg_expr:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(FreeImage_GetFIFDescription(__pyx_v_self->_format)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.description.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_14magic_reg_expr_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_14magic_reg_expr_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_14magic_reg_expr___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1785
 * 
 *     property magic_reg_expr:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_GetFIFRegExpr(self._format)
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_14magic_reg_expr___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1786
 *     property magic_reg_expr:
 *         def __get__(self):
 *             return fi.FreeImage_GetFIFRegExpr(self._format)             # <<<<<<<<<<<<<<
 * 
 *     property supports_reading:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_FromString(FreeImage_GetFIFRegExpr(__pyx_v_self->_format)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.magic_reg_expr.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_reading_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_reading_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_reading___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1789
 * 
 *     property supports_reading:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_FIFSupportsReading(self._format)
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_reading___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1790
 *     property supports_reading:
 *         def __get__(self):
 *             return fi.FreeImage_FIFSupportsReading(self._format)             # <<<<<<<<<<<<<<
 * 
 *     property supports_writing:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(FreeImage_FIFSupportsReading(__pyx_v_self->_format)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.supports_reading.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_writing_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_writing_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_writing___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1793
 * 
 *     property supports_writing:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_FIFSupportsWriting(self._format)
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_writing___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1794
 *     property supports_writing:
 *         def __get__(self):
 *             return fi.FreeImage_FIFSupportsWriting(self._format)             # <<<<<<<<<<<<<<
 * 
 *     property supports_icc:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(FreeImage_FIFSupportsWriting(__pyx_v_self->_format)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.supports_writing.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_12supports_icc_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_12supports_icc_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_12supports_icc___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1797
 * 
 *     property supports_icc:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_FIFSupportsICCProfiles(self._format)
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_12supports_icc___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1798
 *     property supports_icc:
 *         def __get__(self):
 *             return fi.FreeImage_FIFSupportsICCProfiles(self._format)             # <<<<<<<<<<<<<<
 * 
 *     property supports_nopixels:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(FreeImage_FIFSupportsICCProfiles(__pyx_v_self->_format)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.supports_icc.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_17supports_nopixels_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_17supports_nopixels_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_17supports_nopixels___get__(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1801
 * 
 *     property supports_nopixels:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return fi.FreeImage_FIFSupportsNoPixels(self._format)
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_17supports_nopixels___get__(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "smc/freeimage/_freeimage.pyx":1802
 *     property supports_nopixels:
 *         def __get__(self):
 *             return fi.FreeImage_FIFSupportsNoPixels(self._format)             # <<<<<<<<<<<<<<
 * 
 *     def getExtensions(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(FreeImage_FIFSupportsNoPixels(__pyx_v_self->_format)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.supports_nopixels.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_5getExtensions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_5getExtensions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getExtensions (wrapper)", 0);
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_4getExtensions(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1804
 *             return fi.FreeImage_FIFSupportsNoPixels(self._format)
 * 
 *     def getExtensions(self):             # <<<<<<<<<<<<<<
 *         exts = fi.FreeImage_GetFIFExtensionList(self._format)
 *         return [funicode(ext) for ext in exts.split(b',')]
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_4getExtensions(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self) {
  char *__pyx_v_exts;
  PyObject *__pyx_v_ext = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  const char* __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getExtensions", 0);

  /* "smc/freeimage/_freeimage.pyx":1805
 * 
 *     def getExtensions(self):
 *         exts = fi.FreeImage_GetFIFExtensionList(self._format)             # <<<<<<<<<<<<<<
 *         return [funicode(ext) for ext in exts.split(b',')]
 * 
 */
  __pyx_v_exts = FreeImage_GetFIFExtensionList(__pyx_v_self->_format);

  /* "smc/freeimage/_freeimage.pyx":1806
 *     def getExtensions(self):
 *         exts = fi.FreeImage_GetFIFExtensionList(self._format)
 *         return [funicode(ext) for ext in exts.split(b',')]             # <<<<<<<<<<<<<<
 * 
 *     def getSupportsExportType(self, int type):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyBytes_FromString(__pyx_v_exts); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_t_2), __pyx_n_s__split); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_132), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_ext);
    __pyx_v_ext = __pyx_t_2;
    __pyx_t_2 = 0;
    __pyx_t_6 = PyBytes_AsString(__pyx_v_ext); if (unlikely((__pyx_t_6 == (const char*)NULL) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.getExtensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ext);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_7getSupportsExportType(PyObject *__pyx_v_self, PyObject *__pyx_arg_type); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_7getSupportsExportType(PyObject *__pyx_v_self, PyObject *__pyx_arg_type) {
  int __pyx_v_type;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getSupportsExportType (wrapper)", 0);
  assert(__pyx_arg_type); {
    __pyx_v_type = __Pyx_PyInt_AsInt(__pyx_arg_type); if (unlikely((__pyx_v_type == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1808; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.getSupportsExportType", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_6getSupportsExportType(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self), ((int)__pyx_v_type));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1808
 *         return [funicode(ext) for ext in exts.split(b',')]
 * 
 *     def getSupportsExportType(self, int type):             # <<<<<<<<<<<<<<
 *         if type < 0 or type > fi.FIT_RGBAF:
 *             raise ValueError("Invalid type %i" % type)
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_6getSupportsExportType(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self, int __pyx_v_type) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getSupportsExportType", 0);

  /* "smc/freeimage/_freeimage.pyx":1809
 * 
 *     def getSupportsExportType(self, int type):
 *         if type < 0 or type > fi.FIT_RGBAF:             # <<<<<<<<<<<<<<
 *             raise ValueError("Invalid type %i" % type)
 *         return fi.FreeImage_FIFSupportsExportType(self._format,
 */
  __pyx_t_1 = (__pyx_v_type < 0);
  if (!__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_type > FIT_RGBAF);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":1810
 *     def getSupportsExportType(self, int type):
 *         if type < 0 or type > fi.FIT_RGBAF:
 *             raise ValueError("Invalid type %i" % type)             # <<<<<<<<<<<<<<
 *         return fi.FreeImage_FIFSupportsExportType(self._format,
 *                                                   <fi.FREE_IMAGE_TYPE>type)
 */
    __pyx_t_4 = PyInt_FromLong(__pyx_v_type); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_133), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1811
 *         if type < 0 or type > fi.FIT_RGBAF:
 *             raise ValueError("Invalid type %i" % type)
 *         return fi.FreeImage_FIFSupportsExportType(self._format,             # <<<<<<<<<<<<<<
 *                                                   <fi.FREE_IMAGE_TYPE>type)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "smc/freeimage/_freeimage.pyx":1812
 *             raise ValueError("Invalid type %i" % type)
 *         return fi.FreeImage_FIFSupportsExportType(self._format,
 *                                                   <fi.FREE_IMAGE_TYPE>type)             # <<<<<<<<<<<<<<
 * 
 *     def getSupportsExportBPP(self, int bpp):
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_int32_t(FreeImage_FIFSupportsExportType(__pyx_v_self->_format, ((enum FREE_IMAGE_TYPE)__pyx_v_type))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.getSupportsExportType", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_9getSupportsExportBPP(PyObject *__pyx_v_self, PyObject *__pyx_arg_bpp); /*proto*/
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_9getSupportsExportBPP(PyObject *__pyx_v_self, PyObject *__pyx_arg_bpp) {
  int __pyx_v_bpp;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getSupportsExportBPP (wrapper)", 0);
  assert(__pyx_arg_bpp); {
    __pyx_v_bpp = __Pyx_PyInt_AsInt(__pyx_arg_bpp); if (unlikely((__pyx_v_bpp == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.getSupportsExportBPP", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_8getSupportsExportBPP(((struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *)__pyx_v_self), ((int)__pyx_v_bpp));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1814
 *                                                   <fi.FREE_IMAGE_TYPE>type)
 * 
 *     def getSupportsExportBPP(self, int bpp):             # <<<<<<<<<<<<<<
 *         return fi.FreeImage_FIFSupportsExportBPP(self._format, bpp)
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_10FormatInfo_8getSupportsExportBPP(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo *__pyx_v_self, int __pyx_v_bpp) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getSupportsExportBPP", 0);

  /* "smc/freeimage/_freeimage.pyx":1815
 * 
 *     def getSupportsExportBPP(self, int bpp):
 *         return fi.FreeImage_FIFSupportsExportBPP(self._format, bpp)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(FreeImage_FIFSupportsExportBPP(__pyx_v_self->_format, __pyx_v_bpp)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.FormatInfo.getSupportsExportBPP", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_21getVersion(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_20getVersion[] = "getVersion() -> str\n\n    Get version of loaded freeimage library\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_21getVersion = {__Pyx_NAMESTR("getVersion"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_21getVersion, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_20getVersion)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_21getVersion(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getVersion (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_20getVersion(__pyx_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1819
 * 
 * #--- module functions
 * def getVersion():             # <<<<<<<<<<<<<<
 *     """getVersion() -> str
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_20getVersion(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getVersion", 0);

  /* "smc/freeimage/_freeimage.pyx":1824
 *     Get version of loaded freeimage library
 *     """
 *     return funicode(fi.FreeImage_GetVersion())             # <<<<<<<<<<<<<<
 * 
 * def getCompiledFor():
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(FreeImage_GetVersion()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.getVersion", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_23getCompiledFor(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_22getCompiledFor[] = "getCompiledFor() -> tuple(major, minor, serial)\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_23getCompiledFor = {__Pyx_NAMESTR("getCompiledFor"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_23getCompiledFor, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_22getCompiledFor)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_23getCompiledFor(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getCompiledFor (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_22getCompiledFor(__pyx_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1826
 *     return funicode(fi.FreeImage_GetVersion())
 * 
 * def getCompiledFor():             # <<<<<<<<<<<<<<
 *     """getCompiledFor() -> tuple(major, minor, serial)
 *     """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_22getCompiledFor(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getCompiledFor", 0);

  /* "smc/freeimage/_freeimage.pyx":1829
 *     """getCompiledFor() -> tuple(major, minor, serial)
 *     """
 *     return (fi.FREEIMAGE_MAJOR_VERSION,             # <<<<<<<<<<<<<<
 *             fi.FREEIMAGE_MINOR_VERSION,
 *             fi.FREEIMAGE_RELEASE_SERIAL)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(FREEIMAGE_MAJOR_VERSION); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "smc/freeimage/_freeimage.pyx":1830
 *     """
 *     return (fi.FREEIMAGE_MAJOR_VERSION,
 *             fi.FREEIMAGE_MINOR_VERSION,             # <<<<<<<<<<<<<<
 *             fi.FREEIMAGE_RELEASE_SERIAL)
 * 
 */
  __pyx_t_2 = PyInt_FromLong(FREEIMAGE_MINOR_VERSION); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "smc/freeimage/_freeimage.pyx":1831
 *     return (fi.FREEIMAGE_MAJOR_VERSION,
 *             fi.FREEIMAGE_MINOR_VERSION,
 *             fi.FREEIMAGE_RELEASE_SERIAL)             # <<<<<<<<<<<<<<
 * 
 * def getCopyright():
 */
  __pyx_t_3 = PyInt_FromLong(FREEIMAGE_RELEASE_SERIAL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("smc.freeimage._freeimage.getCompiledFor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_25getCopyright(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_24getCopyright[] = "getCopyright() -> str\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_25getCopyright = {__Pyx_NAMESTR("getCopyright"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_25getCopyright, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_24getCopyright)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_25getCopyright(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getCopyright (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_24getCopyright(__pyx_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1833
 *             fi.FREEIMAGE_RELEASE_SERIAL)
 * 
 * def getCopyright():             # <<<<<<<<<<<<<<
 *     """getCopyright() -> str
 *     """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_24getCopyright(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getCopyright", 0);

  /* "smc/freeimage/_freeimage.pyx":1836
 *     """getCopyright() -> str
 *     """
 *     return funicode(fi.FreeImage_GetCopyrightMessage())             # <<<<<<<<<<<<<<
 * 
 * def getFormatCount():
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_funicode(FreeImage_GetCopyrightMessage()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.getCopyright", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_27getFormatCount(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_26getFormatCount[] = "getFormatCount() -> int\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_27getFormatCount = {__Pyx_NAMESTR("getFormatCount"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_27getFormatCount, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_26getFormatCount)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_27getFormatCount(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getFormatCount (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_26getFormatCount(__pyx_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1838
 *     return funicode(fi.FreeImage_GetCopyrightMessage())
 * 
 * def getFormatCount():             # <<<<<<<<<<<<<<
 *     """getFormatCount() -> int
 *     """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_26getFormatCount(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getFormatCount", 0);

  /* "smc/freeimage/_freeimage.pyx":1841
 *     """getFormatCount() -> int
 *     """
 *     return fi.FreeImage_GetFIFCount()             # <<<<<<<<<<<<<<
 * 
 * def lookupX11Color(name):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(FreeImage_GetFIFCount()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.getFormatCount", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_29lookupX11Color(PyObject *__pyx_self, PyObject *__pyx_v_name); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_28lookupX11Color[] = "lookupX11Color(name) -> (r, g, b)\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_29lookupX11Color = {__Pyx_NAMESTR("lookupX11Color"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_29lookupX11Color, METH_O, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_28lookupX11Color)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_29lookupX11Color(PyObject *__pyx_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lookupX11Color (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_28lookupX11Color(__pyx_self, ((PyObject *)__pyx_v_name));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1843
 *     return fi.FreeImage_GetFIFCount()
 * 
 * def lookupX11Color(name):             # <<<<<<<<<<<<<<
 *     """lookupX11Color(name) -> (r, g, b)
 *     """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_28lookupX11Color(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name) {
  BYTE __pyx_v_red;
  BYTE __pyx_v_green;
  BYTE __pyx_v_blue;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lookupX11Color", 0);
  __Pyx_INCREF(__pyx_v_name);

  /* "smc/freeimage/_freeimage.pyx":1847
 *     """
 *     cdef fi.BYTE red, green, blue
 *     name = _decodeFilename(name)             # <<<<<<<<<<<<<<
 *     if not fi.FreeImage_LookupX11Color(name, &red, &green, &blue):
 *         raise dispatchFIError(OperationError, "Cannot lookup X11 color %s" % name)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(__pyx_v_name)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_name);
  __pyx_v_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1848
 *     cdef fi.BYTE red, green, blue
 *     name = _decodeFilename(name)
 *     if not fi.FreeImage_LookupX11Color(name, &red, &green, &blue):             # <<<<<<<<<<<<<<
 *         raise dispatchFIError(OperationError, "Cannot lookup X11 color %s" % name)
 *     return (red, green, blue)
 */
  __pyx_t_2 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = (!FreeImage_LookupX11Color(__pyx_t_2, (&__pyx_v_red), (&__pyx_v_green), (&__pyx_v_blue)));
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":1849
 *     name = _decodeFilename(name)
 *     if not fi.FreeImage_LookupX11Color(name, &red, &green, &blue):
 *         raise dispatchFIError(OperationError, "Cannot lookup X11 color %s" % name)             # <<<<<<<<<<<<<<
 *     return (red, green, blue)
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_134), __pyx_v_name); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1850
 *     if not fi.FreeImage_LookupX11Color(name, &red, &green, &blue):
 *         raise dispatchFIError(OperationError, "Cannot lookup X11 color %s" % name)
 *     return (red, green, blue)             # <<<<<<<<<<<<<<
 * 
 * def lookupSVGColor(name):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_PyInt_to_py_uint8_t(__pyx_v_red); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_to_py_uint8_t(__pyx_v_green); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint8_t(__pyx_v_blue); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_1 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.lookupX11Color", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_31lookupSVGColor(PyObject *__pyx_self, PyObject *__pyx_v_name); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_30lookupSVGColor[] = "lookupSVGColor(name) -> (r, g, b)\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_31lookupSVGColor = {__Pyx_NAMESTR("lookupSVGColor"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_31lookupSVGColor, METH_O, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_30lookupSVGColor)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_31lookupSVGColor(PyObject *__pyx_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lookupSVGColor (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_30lookupSVGColor(__pyx_self, ((PyObject *)__pyx_v_name));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1852
 *     return (red, green, blue)
 * 
 * def lookupSVGColor(name):             # <<<<<<<<<<<<<<
 *     """lookupSVGColor(name) -> (r, g, b)
 *     """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_30lookupSVGColor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name) {
  BYTE __pyx_v_red;
  BYTE __pyx_v_green;
  BYTE __pyx_v_blue;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lookupSVGColor", 0);
  __Pyx_INCREF(__pyx_v_name);

  /* "smc/freeimage/_freeimage.pyx":1856
 *     """
 *     cdef fi.BYTE red, green, blue
 *     name = _decodeFilename(name)             # <<<<<<<<<<<<<<
 *     if not fi.FreeImage_LookupSVGColor(name, &red, &green, &blue):
 *         raise dispatchFIError(OperationError, "Cannot lookup SVG color %s" % name)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(__pyx_v_name)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_name);
  __pyx_v_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1857
 *     cdef fi.BYTE red, green, blue
 *     name = _decodeFilename(name)
 *     if not fi.FreeImage_LookupSVGColor(name, &red, &green, &blue):             # <<<<<<<<<<<<<<
 *         raise dispatchFIError(OperationError, "Cannot lookup SVG color %s" % name)
 *     return (red, green, blue)
 */
  __pyx_t_2 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = (!FreeImage_LookupSVGColor(__pyx_t_2, (&__pyx_v_red), (&__pyx_v_green), (&__pyx_v_blue)));
  if (__pyx_t_3) {

    /* "smc/freeimage/_freeimage.pyx":1858
 *     name = _decodeFilename(name)
 *     if not fi.FreeImage_LookupSVGColor(name, &red, &green, &blue):
 *         raise dispatchFIError(OperationError, "Cannot lookup SVG color %s" % name)             # <<<<<<<<<<<<<<
 *     return (red, green, blue)
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_135), __pyx_v_name); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1859
 *     if not fi.FreeImage_LookupSVGColor(name, &red, &green, &blue):
 *         raise dispatchFIError(OperationError, "Cannot lookup SVG color %s" % name)
 *     return (red, green, blue)             # <<<<<<<<<<<<<<
 * 
 * def jpegTransform(src, dst, unsigned int op, unsigned int perfect=0):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_PyInt_to_py_uint8_t(__pyx_v_red); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_to_py_uint8_t(__pyx_v_green); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint8_t(__pyx_v_blue); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_1 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.lookupSVGColor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_33jpegTransform(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_32jpegTransform[] = "jpegTransform(source: str, destination: str, op: int) -> None\n\n    Perform lossless rotation or flipping on a JPEG image\n\n    @param src: path to source image\n    @type src: str\n    @param dst: path to destination file, can be the same file as src\n    @typ dst: str\n    @param op: a FIJPEG_OP_* constant\n    @param perfect: if true raises an exception if image has odd iMCU\n        aligned (see PDF)\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_33jpegTransform = {__Pyx_NAMESTR("jpegTransform"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_33jpegTransform, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_32jpegTransform)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_33jpegTransform(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_src = 0;
  PyObject *__pyx_v_dst = 0;
  unsigned int __pyx_v_op;
  unsigned int __pyx_v_perfect;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__src,&__pyx_n_s__dst,&__pyx_n_s__op,&__pyx_n_s__perfect,0};
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("jpegTransform (wrapper)", 0);
  __pyx_self = __pyx_self;
  {
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__src);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dst);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("jpegTransform", 0, 3, 4, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__op);
        if (likely(values[2])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("jpegTransform", 0, 3, 4, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__perfect);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jpegTransform") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (values[3]) {
      } else {
        __pyx_v_perfect = ((unsigned int)0);
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_src = values[0];
    __pyx_v_dst = values[1];
    __pyx_v_op = __Pyx_PyInt_AsUnsignedInt(values[2]); if (unlikely((__pyx_v_op == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[3]) {
      __pyx_v_perfect = __Pyx_PyInt_AsUnsignedInt(values[3]); if (unlikely((__pyx_v_perfect == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_perfect = ((unsigned int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("jpegTransform", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("smc.freeimage._freeimage.jpegTransform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_32jpegTransform(__pyx_self, __pyx_v_src, __pyx_v_dst, __pyx_v_op, __pyx_v_perfect);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1861
 *     return (red, green, blue)
 * 
 * def jpegTransform(src, dst, unsigned int op, unsigned int perfect=0):             # <<<<<<<<<<<<<<
 *     """jpegTransform(source: str, destination: str, op: int) -> None
 * 
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_32jpegTransform(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src, PyObject *__pyx_v_dst, unsigned int __pyx_v_op, unsigned int __pyx_v_perfect) {
  BOOL __pyx_v_result;
  char *__pyx_v_csrc;
  char *__pyx_v_cdst;
  PyObject *__pyx_v_bsrc = NULL;
  PyObject *__pyx_v_bdst = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  char *__pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jpegTransform", 0);

  /* "smc/freeimage/_freeimage.pyx":1878
 *     cdef char* cdst
 * 
 *     bsrc = _decodeFilename(src)             # <<<<<<<<<<<<<<
 *     bdst = _decodeFilename(dst)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(__pyx_v_src)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bsrc = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1879
 * 
 *     bsrc = _decodeFilename(src)
 *     bdst = _decodeFilename(dst)             # <<<<<<<<<<<<<<
 * 
 *     if op > fi.FIJPEG_OP_ROTATE_270:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_3smc_9freeimage_10_freeimage__decodeFilename(__pyx_v_dst)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bdst = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1881
 *     bdst = _decodeFilename(dst)
 * 
 *     if op > fi.FIJPEG_OP_ROTATE_270:             # <<<<<<<<<<<<<<
 *         raise ValueError("OP not in range 0-7")
 * 
 */
  __pyx_t_2 = (__pyx_v_op > FIJPEG_OP_ROTATE_270);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1882
 * 
 *     if op > fi.FIJPEG_OP_ROTATE_270:
 *         raise ValueError("OP not in range 0-7")             # <<<<<<<<<<<<<<
 * 
 *     csrc = bsrc
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_137), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "smc/freeimage/_freeimage.pyx":1884
 *         raise ValueError("OP not in range 0-7")
 * 
 *     csrc = bsrc             # <<<<<<<<<<<<<<
 *     cdst = bdst
 * 
 */
  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_bsrc)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_csrc = __pyx_t_3;

  /* "smc/freeimage/_freeimage.pyx":1885
 * 
 *     csrc = bsrc
 *     cdst = bdst             # <<<<<<<<<<<<<<
 * 
 *     with nogil:
 */
  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_bdst)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cdst = __pyx_t_3;

  /* "smc/freeimage/_freeimage.pyx":1887
 *     cdst = bdst
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = fi.FreeImage_JPEGTransform(csrc,
 *                                             cdst,
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "smc/freeimage/_freeimage.pyx":1891
 *                                             cdst,
 *                                             <fi.FREE_IMAGE_JPEG_OPERATION>op,
 *                                             perfect)             # <<<<<<<<<<<<<<
 *     if not result:
 *         raise dispatchFIError(OperationError, "JPEG Transformation of '%s' to '%s' with op "
 */
        __pyx_v_result = FreeImage_JPEGTransform(__pyx_v_csrc, __pyx_v_cdst, ((enum FREE_IMAGE_JPEG_OPERATION)__pyx_v_op), __pyx_v_perfect);
      }

      /* "smc/freeimage/_freeimage.pyx":1887
 *     cdst = bdst
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = fi.FreeImage_JPEGTransform(csrc,
 *                                             cdst,
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "smc/freeimage/_freeimage.pyx":1892
 *                                             <fi.FREE_IMAGE_JPEG_OPERATION>op,
 *                                             perfect)
 *     if not result:             # <<<<<<<<<<<<<<
 *         raise dispatchFIError(OperationError, "JPEG Transformation of '%s' to '%s' with op "
 *                              "'%i' failed." % (src, dst, op))
 */
  __pyx_t_2 = (!__pyx_v_result);
  if (__pyx_t_2) {

    /* "smc/freeimage/_freeimage.pyx":1893
 *                                             perfect)
 *     if not result:
 *         raise dispatchFIError(OperationError, "JPEG Transformation of '%s' to '%s' with op "             # <<<<<<<<<<<<<<
 *                              "'%i' failed." % (src, dst, op))
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__dispatchFIError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__OperationError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);

    /* "smc/freeimage/_freeimage.pyx":1894
 *     if not result:
 *         raise dispatchFIError(OperationError, "JPEG Transformation of '%s' to '%s' with op "
 *                              "'%i' failed." % (src, dst, op))             # <<<<<<<<<<<<<<
 * 
 * def hasJPEGTurbo():
 */
    __pyx_t_5 = PyLong_FromUnsignedLong(__pyx_v_op); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_src);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_src);
    __Pyx_GIVEREF(__pyx_v_src);
    __Pyx_INCREF(__pyx_v_dst);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_dst);
    __Pyx_GIVEREF(__pyx_v_dst);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_138), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("smc.freeimage._freeimage.jpegTransform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bsrc);
  __Pyx_XDECREF(__pyx_v_bdst);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_35hasJPEGTurbo(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3smc_9freeimage_10_freeimage_34hasJPEGTurbo[] = "Is FreeImage compiled against libjeg-turbo\n    ";
static PyMethodDef __pyx_mdef_3smc_9freeimage_10_freeimage_35hasJPEGTurbo = {__Pyx_NAMESTR("hasJPEGTurbo"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_35hasJPEGTurbo, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_34hasJPEGTurbo)};
static PyObject *__pyx_pw_3smc_9freeimage_10_freeimage_35hasJPEGTurbo(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("hasJPEGTurbo (wrapper)", 0);
  __pyx_self = __pyx_self;
  __pyx_r = __pyx_pf_3smc_9freeimage_10_freeimage_34hasJPEGTurbo(__pyx_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1896
 *                              "'%i' failed." % (src, dst, op))
 * 
 * def hasJPEGTurbo():             # <<<<<<<<<<<<<<
 *     """Is FreeImage compiled against libjeg-turbo
 *     """
 */

static PyObject *__pyx_pf_3smc_9freeimage_10_freeimage_34hasJPEGTurbo(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("hasJPEGTurbo", 0);

  /* "smc/freeimage/_freeimage.pyx":1899
 *     """Is FreeImage compiled against libjeg-turbo
 *     """
 *     return bool(FREEIMAGE_TURBO)             # <<<<<<<<<<<<<<
 * 
 * cdef void initialize():
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(FREEIMAGE_TURBO); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_2))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("smc.freeimage._freeimage.hasJPEGTurbo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "smc/freeimage/_freeimage.pyx":1901
 *     return bool(FREEIMAGE_TURBO)
 * 
 * cdef void initialize():             # <<<<<<<<<<<<<<
 *     """Initialize FreeImage
 *     """
 */

static void __pyx_f_3smc_9freeimage_10_freeimage_initialize(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("initialize", 0);

  /* "smc/freeimage/_freeimage.pyx":1905
 *     """
 *     # 0: load all plugins
 *     fi.FreeImage_Initialise(0)             # <<<<<<<<<<<<<<
 *     initErrorHandler()
 * 
 */
  FreeImage_Initialise(0);

  /* "smc/freeimage/_freeimage.pyx":1906
 *     # 0: load all plugins
 *     fi.FreeImage_Initialise(0)
 *     initErrorHandler()             # <<<<<<<<<<<<<<
 * 
 * initialize()
 */
  __pyx_t_1 = __pyx_f_3smc_9freeimage_10_freeimage_initErrorHandler(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_WriteUnraisable("smc.freeimage._freeimage.initialize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}
static struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_Image __pyx_vtable_3smc_9freeimage_10_freeimage_Image;

static PyObject *__pyx_tp_new_3smc_9freeimage_10_freeimage_Image(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)o);
  p->__pyx_vtab = __pyx_vtabptr_3smc_9freeimage_10_freeimage_Image;
  return o;
}

static void __pyx_tp_dealloc_3smc_9freeimage_10_freeimage_Image(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_filename(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_8filename_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_size(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_4size_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_format(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_6format_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_type(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_4type_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_mimetype(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_8mimetype_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpi_x(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_x_1__get__(o);
}

static int __pyx_setprop_3smc_9freeimage_10_freeimage_5Image_dpi_x(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_x_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpi_y(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_y_1__get__(o);
}

static int __pyx_setprop_3smc_9freeimage_10_freeimage_5Image_dpi_y(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpi_y_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpi(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_3dpi_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpm_x(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_x_1__get__(o);
}

static int __pyx_setprop_3smc_9freeimage_10_freeimage_5Image_dpm_x(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_x_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpm_y(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_y_1__get__(o);
}

static int __pyx_setprop_3smc_9freeimage_10_freeimage_5Image_dpm_y(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5dpm_y_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpm(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_3dpm_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_colors_used(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_11colors_used_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_bpp(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_3bpp_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_has_icc(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_7has_icc_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_icc_cmyk(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_8icc_cmyk_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_color_type(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_10color_type_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_color_type_name(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_15color_type_name_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_is_transparent(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_14is_transparent_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_has_bg_color(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_12has_bg_color_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_rgb_mask(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_8rgb_mask_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_colororder(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_10colororder_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_has_pixels(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_10has_pixels_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_closed(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_6closed_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_width(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_5width_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_5Image_height(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_5Image_6height_1__get__(o);
}

static PyMethodDef __pyx_methods_3smc_9freeimage_10_freeimage_Image[] = {
  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_3close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_2close)},
  {__Pyx_NAMESTR("__sizeof__"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_7__sizeof__, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_11__enter__, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_13__exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("floodfill"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_15floodfill, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_14floodfill)},
  {__Pyx_NAMESTR("save"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_17save, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_16save)},
  {__Pyx_NAMESTR("toBuffer"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_19toBuffer, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_18toBuffer)},
  {__Pyx_NAMESTR("toPIL"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_21toPIL, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_20toPIL)},
  {__Pyx_NAMESTR("resize"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_23resize, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_22resize)},
  {__Pyx_NAMESTR("paste"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_25paste, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_24paste)},
  {__Pyx_NAMESTR("clone"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_27clone, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_26clone)},
  {__Pyx_NAMESTR("crop"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_29crop, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_28crop)},
  {__Pyx_NAMESTR("convert_4bits"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_31convert_4bits, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_30convert_4bits)},
  {__Pyx_NAMESTR("convert_8bits"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_33convert_8bits, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_32convert_8bits)},
  {__Pyx_NAMESTR("greyscale"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_35greyscale, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_34greyscale)},
  {__Pyx_NAMESTR("convert_16bits555"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_37convert_16bits555, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_36convert_16bits555)},
  {__Pyx_NAMESTR("convert_16bits565"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_39convert_16bits565, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_38convert_16bits565)},
  {__Pyx_NAMESTR("convert_24bits"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_41convert_24bits, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_40convert_24bits)},
  {__Pyx_NAMESTR("convert_32bits"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_43convert_32bits, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_42convert_32bits)},
  {__Pyx_NAMESTR("convert_rgbf"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_45convert_rgbf, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_44convert_rgbf)},
  {__Pyx_NAMESTR("to_standard"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_47to_standard, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_46to_standard)},
  {__Pyx_NAMESTR("to_type"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_49to_type, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_48to_type)},
  {__Pyx_NAMESTR("dither"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_51dither, METH_O, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_50dither)},
  {__Pyx_NAMESTR("threshold"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_53threshold, METH_O, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_52threshold)},
  {__Pyx_NAMESTR("flipHorizontal"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_55flipHorizontal, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_54flipHorizontal)},
  {__Pyx_NAMESTR("flipVertical"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_57flipVertical, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_56flipVertical)},
  {__Pyx_NAMESTR("rotate"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_59rotate, METH_O, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_58rotate)},
  {__Pyx_NAMESTR("rotateEx"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_61rotateEx, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_60rotateEx)},
  {__Pyx_NAMESTR("getICC"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_63getICC, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_62getICC)},
  {__Pyx_NAMESTR("removeICC"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_65removeICC, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_64removeICC)},
  {__Pyx_NAMESTR("iccTransform"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_67iccTransform, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_66iccTransform)},
  {__Pyx_NAMESTR("getMetadataCount"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_69getMetadataCount, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_68getMetadataCount)},
  {__Pyx_NAMESTR("getMetadata"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_71getMetadata, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_70getMetadata)},
  {__Pyx_NAMESTR("copyMetadataFrom"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_73copyMetadataFrom, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("clearMetadata"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_75clearMetadata, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getInfoHeader"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_77getInfoHeader, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_76getInfoHeader)},
  {__Pyx_NAMESTR("adjustColors"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_79adjustColors, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_78adjustColors)},
  {__Pyx_NAMESTR("adjustGamma"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_81adjustGamma, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_80adjustGamma)},
  {__Pyx_NAMESTR("adjustBrightness"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_83adjustBrightness, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_82adjustBrightness)},
  {__Pyx_NAMESTR("adjustContrast"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_85adjustContrast, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_84adjustContrast)},
  {__Pyx_NAMESTR("invert"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_87invert, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_86invert)},
  {__Pyx_NAMESTR("getHistogram"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_89getHistogram, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_5Image_88getHistogram)},
  {__Pyx_NAMESTR("hline"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_91hline, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("vline"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_5Image_93vline, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_3smc_9freeimage_10_freeimage_Image[] = {
  {(char *)"filename", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_filename, 0, __Pyx_DOCSTR(__pyx_k_139), 0},
  {(char *)"size", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_size, 0, __Pyx_DOCSTR(__pyx_k_140), 0},
  {(char *)"format", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_format, 0, __Pyx_DOCSTR(__pyx_k_141), 0},
  {(char *)"type", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_type, 0, __Pyx_DOCSTR(__pyx_k_142), 0},
  {(char *)"mimetype", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_mimetype, 0, __Pyx_DOCSTR(__pyx_k_143), 0},
  {(char *)"dpi_x", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpi_x, __pyx_setprop_3smc_9freeimage_10_freeimage_5Image_dpi_x, __Pyx_DOCSTR(__pyx_k_144), 0},
  {(char *)"dpi_y", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpi_y, __pyx_setprop_3smc_9freeimage_10_freeimage_5Image_dpi_y, __Pyx_DOCSTR(__pyx_k_145), 0},
  {(char *)"dpi", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpi, 0, __Pyx_DOCSTR(__pyx_k_146), 0},
  {(char *)"dpm_x", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpm_x, __pyx_setprop_3smc_9freeimage_10_freeimage_5Image_dpm_x, __Pyx_DOCSTR(__pyx_k_147), 0},
  {(char *)"dpm_y", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpm_y, __pyx_setprop_3smc_9freeimage_10_freeimage_5Image_dpm_y, __Pyx_DOCSTR(__pyx_k_148), 0},
  {(char *)"dpm", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_dpm, 0, __Pyx_DOCSTR(__pyx_k_149), 0},
  {(char *)"colors_used", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_colors_used, 0, __Pyx_DOCSTR(__pyx_k_150), 0},
  {(char *)"bpp", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_bpp, 0, __Pyx_DOCSTR(__pyx_k_151), 0},
  {(char *)"has_icc", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_has_icc, 0, __Pyx_DOCSTR(__pyx_k_152), 0},
  {(char *)"icc_cmyk", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_icc_cmyk, 0, __Pyx_DOCSTR(__pyx_k_153), 0},
  {(char *)"color_type", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_color_type, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
  {(char *)"color_type_name", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_color_type_name, 0, __Pyx_DOCSTR(__pyx_k_155), 0},
  {(char *)"is_transparent", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_is_transparent, 0, __Pyx_DOCSTR(__pyx_k_156), 0},
  {(char *)"has_bg_color", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_has_bg_color, 0, __Pyx_DOCSTR(__pyx_k_157), 0},
  {(char *)"rgb_mask", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_rgb_mask, 0, __Pyx_DOCSTR(__pyx_k_158), 0},
  {(char *)"colororder", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_colororder, 0, __Pyx_DOCSTR(__pyx_k_159), 0},
  {(char *)"has_pixels", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_has_pixels, 0, __Pyx_DOCSTR(__pyx_k_160), 0},
  {(char *)"closed", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_closed, 0, __Pyx_DOCSTR(__pyx_k_161), 0},
  {(char *)"width", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_width, 0, 0, 0},
  {(char *)"height", __pyx_getprop_3smc_9freeimage_10_freeimage_5Image_height, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Image = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Image = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Image = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Image = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_3smc_9freeimage_10_freeimage_Image = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("smc.freeimage._freeimage.Image"), /*tp_name*/
  sizeof(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3smc_9freeimage_10_freeimage_Image, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_3smc_9freeimage_10_freeimage_5Image_9__repr__, /*tp_repr*/
  &__pyx_tp_as_number_Image, /*tp_as_number*/
  &__pyx_tp_as_sequence_Image, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Image, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Image, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("Image(filename[, buffer=None[, flags=0]])\n\n    Create a new Image. Either filename or buffer must applied.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3smc_9freeimage_10_freeimage_Image, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_3smc_9freeimage_10_freeimage_Image, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_3smc_9freeimage_10_freeimage_5Image_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3smc_9freeimage_10_freeimage_Image, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_3smc_9freeimage_10_freeimage_FormatInfo(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_3smc_9freeimage_10_freeimage_FormatInfo(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_format(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_6format_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_mimetype(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_8mimetype_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_name(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_4name_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_description(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_11description_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_magic_reg_expr(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_14magic_reg_expr_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_supports_reading(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_reading_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_supports_writing(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_16supports_writing_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_supports_icc(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_12supports_icc_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_supports_nopixels(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_17supports_nopixels_1__get__(o);
}

static PyMethodDef __pyx_methods_3smc_9freeimage_10_freeimage_FormatInfo[] = {
  {__Pyx_NAMESTR("getExtensions"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_5getExtensions, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getSupportsExportType"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_7getSupportsExportType, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getSupportsExportBPP"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_9getSupportsExportBPP, METH_O, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_3smc_9freeimage_10_freeimage_FormatInfo[] = {
  {(char *)"format", __pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_format, 0, 0, 0},
  {(char *)"mimetype", __pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_mimetype, 0, 0, 0},
  {(char *)"name", __pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_name, 0, 0, 0},
  {(char *)"description", __pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_description, 0, 0, 0},
  {(char *)"magic_reg_expr", __pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_magic_reg_expr, 0, 0, 0},
  {(char *)"supports_reading", __pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_supports_reading, 0, 0, 0},
  {(char *)"supports_writing", __pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_supports_writing, 0, 0, 0},
  {(char *)"supports_icc", __pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_supports_icc, 0, 0, 0},
  {(char *)"supports_nopixels", __pyx_getprop_3smc_9freeimage_10_freeimage_10FormatInfo_supports_nopixels, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_FormatInfo = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_3__int__, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_3__int__, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_FormatInfo = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_FormatInfo = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_FormatInfo = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_3smc_9freeimage_10_freeimage_FormatInfo = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("smc.freeimage._freeimage.FormatInfo"), /*tp_name*/
  sizeof(struct __pyx_obj_3smc_9freeimage_10_freeimage_FormatInfo), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3smc_9freeimage_10_freeimage_FormatInfo, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_FormatInfo, /*tp_as_number*/
  &__pyx_tp_as_sequence_FormatInfo, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_FormatInfo, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_FormatInfo, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3smc_9freeimage_10_freeimage_FormatInfo, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_3smc_9freeimage_10_freeimage_FormatInfo, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_3smc_9freeimage_10_freeimage_10FormatInfo_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3smc_9freeimage_10_freeimage_FormatInfo, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSTransformation __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSTransformation;

static PyObject *__pyx_tp_new_3smc_9freeimage_10_freeimage_LCMSTransformation(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)o);
  p->__pyx_vtab = __pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSTransformation;
  p->inprofile = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->outprofile = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->hash = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_3smc_9freeimage_10_freeimage_LCMSTransformation(PyObject *o) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_5__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->inprofile));
  Py_XDECREF(((PyObject *)p->outprofile));
  Py_XDECREF(p->hash);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_3smc_9freeimage_10_freeimage_LCMSTransformation(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)o;
  if (p->inprofile) {
    e = (*v)(p->inprofile, a); if (e) return e;
  }
  if (p->outprofile) {
    e = (*v)(p->outprofile, a); if (e) return e;
  }
  if (p->hash) {
    e = (*v)(p->hash, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3smc_9freeimage_10_freeimage_LCMSTransformation(PyObject *o) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->inprofile);
  p->inprofile = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->outprofile);
  p->outprofile = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hash);
  p->hash = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_18LCMSTransformation_inprofile(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_9inprofile_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_18LCMSTransformation_outprofile(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_10outprofile_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_18LCMSTransformation_format(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_6format_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_18LCMSTransformation_intent(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_6intent_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_18LCMSTransformation_flags(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_5flags_1__get__(o);
}

static PyMethodDef __pyx_methods_3smc_9freeimage_10_freeimage_LCMSTransformation[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_3smc_9freeimage_10_freeimage_LCMSTransformation[] = {
  {(char *)"inprofile", __pyx_getprop_3smc_9freeimage_10_freeimage_18LCMSTransformation_inprofile, 0, 0, 0},
  {(char *)"outprofile", __pyx_getprop_3smc_9freeimage_10_freeimage_18LCMSTransformation_outprofile, 0, 0, 0},
  {(char *)"format", __pyx_getprop_3smc_9freeimage_10_freeimage_18LCMSTransformation_format, 0, 0, 0},
  {(char *)"intent", __pyx_getprop_3smc_9freeimage_10_freeimage_18LCMSTransformation_intent, 0, 0, 0},
  {(char *)"flags", __pyx_getprop_3smc_9freeimage_10_freeimage_18LCMSTransformation_flags, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_LCMSTransformation = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_LCMSTransformation = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_LCMSTransformation = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_LCMSTransformation = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_3smc_9freeimage_10_freeimage_LCMSTransformation = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("smc.freeimage._freeimage.LCMSTransformation"), /*tp_name*/
  sizeof(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3smc_9freeimage_10_freeimage_LCMSTransformation, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_LCMSTransformation, /*tp_as_number*/
  &__pyx_tp_as_sequence_LCMSTransformation, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_LCMSTransformation, /*tp_as_mapping*/
  __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_3__hash__, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_LCMSTransformation, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_3smc_9freeimage_10_freeimage_LCMSTransformation, /*tp_traverse*/
  __pyx_tp_clear_3smc_9freeimage_10_freeimage_LCMSTransformation, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3smc_9freeimage_10_freeimage_LCMSTransformation, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_3smc_9freeimage_10_freeimage_LCMSTransformation, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_3smc_9freeimage_10_freeimage_18LCMSTransformation_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3smc_9freeimage_10_freeimage_LCMSTransformation, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSIccCache __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSIccCache;

static PyObject *__pyx_tp_new_3smc_9freeimage_10_freeimage_LCMSIccCache(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)o);
  p->__pyx_vtab = __pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSIccCache;
  p->_cache = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_3smc_9freeimage_10_freeimage_LCMSIccCache(PyObject *o) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)o;
  Py_XDECREF(p->_cache);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_3smc_9freeimage_10_freeimage_LCMSIccCache(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)o;
  if (p->_cache) {
    e = (*v)(p->_cache, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3smc_9freeimage_10_freeimage_LCMSIccCache(PyObject *o) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_cache);
  p->_cache = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_12LCMSIccCache_creations(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_9creations_1__get__(o);
}

static PyMethodDef __pyx_methods_3smc_9freeimage_10_freeimage_LCMSIccCache[] = {
  {__Pyx_NAMESTR("clear"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_3clear, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("keys"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_5keys, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("lookupByImage"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_11lookupByImage, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("lookup"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_13lookup, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("applyTransform"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_15applyTransform, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_3smc_9freeimage_10_freeimage_LCMSIccCache[] = {
  {(char *)"creations", __pyx_getprop_3smc_9freeimage_10_freeimage_12LCMSIccCache_creations, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_LCMSIccCache = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_LCMSIccCache = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_9__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_LCMSIccCache = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_LCMSIccCache = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_3smc_9freeimage_10_freeimage_LCMSIccCache = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("smc.freeimage._freeimage.LCMSIccCache"), /*tp_name*/
  sizeof(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3smc_9freeimage_10_freeimage_LCMSIccCache, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_LCMSIccCache, /*tp_as_number*/
  &__pyx_tp_as_sequence_LCMSIccCache, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_LCMSIccCache, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_LCMSIccCache, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_3smc_9freeimage_10_freeimage_LCMSIccCache, /*tp_traverse*/
  __pyx_tp_clear_3smc_9freeimage_10_freeimage_LCMSIccCache, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_7__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3smc_9freeimage_10_freeimage_LCMSIccCache, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_3smc_9freeimage_10_freeimage_LCMSIccCache, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_3smc_9freeimage_10_freeimage_12LCMSIccCache_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3smc_9freeimage_10_freeimage_LCMSIccCache, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_3smc_9freeimage_10_freeimage_LCMSProfileInfo __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo;

static PyObject *__pyx_tp_new_3smc_9freeimage_10_freeimage_LCMSProfileInfo(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)o);
  p->__pyx_vtab = __pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSProfileInfo;
  p->info = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_3smc_9freeimage_10_freeimage_LCMSProfileInfo(PyObject *o) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_3__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->info));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_3smc_9freeimage_10_freeimage_LCMSProfileInfo(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)o;
  if (p->info) {
    e = (*v)(p->info, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3smc_9freeimage_10_freeimage_LCMSProfileInfo(PyObject *o) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->info);
  p->info = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_info(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_1__get__(o);
}

static int __pyx_setprop_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_info(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_3__set__(o, v);
  }
  else {
    return __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_4info_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_3smc_9freeimage_10_freeimage_LCMSProfileInfo[] = {
  {__Pyx_NAMESTR("_readNamedColorList"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_5_readNamedColorList, METH_O, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_3smc_9freeimage_10_freeimage_LCMSProfileInfo[] = {
  {(char *)"info", __pyx_getprop_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_info, __pyx_setprop_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_info, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_LCMSProfileInfo = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_LCMSProfileInfo = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_LCMSProfileInfo = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_LCMSProfileInfo = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_3smc_9freeimage_10_freeimage_LCMSProfileInfo = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("smc.freeimage._freeimage.LCMSProfileInfo"), /*tp_name*/
  sizeof(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3smc_9freeimage_10_freeimage_LCMSProfileInfo, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_LCMSProfileInfo, /*tp_as_number*/
  &__pyx_tp_as_sequence_LCMSProfileInfo, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_LCMSProfileInfo, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_LCMSProfileInfo, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_3smc_9freeimage_10_freeimage_LCMSProfileInfo, /*tp_traverse*/
  __pyx_tp_clear_3smc_9freeimage_10_freeimage_LCMSProfileInfo, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3smc_9freeimage_10_freeimage_LCMSProfileInfo, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_3smc_9freeimage_10_freeimage_LCMSProfileInfo, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_3smc_9freeimage_10_freeimage_15LCMSProfileInfo_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3smc_9freeimage_10_freeimage_LCMSProfileInfo, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_3smc_9freeimage_10_freeimage__DibWrapper(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *)o);
  p->oldimg = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_3smc_9freeimage_10_freeimage__DibWrapper(PyObject *o) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *)o;
  Py_XDECREF(((PyObject *)p->oldimg));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_3smc_9freeimage_10_freeimage__DibWrapper(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *)o;
  if (p->oldimg) {
    e = (*v)(((PyObject*)p->oldimg), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3smc_9freeimage_10_freeimage__DibWrapper(PyObject *o) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->oldimg);
  p->oldimg = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_3smc_9freeimage_10_freeimage__DibWrapper[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__DibWrapper = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__DibWrapper = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__DibWrapper = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__DibWrapper = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_3smc_9freeimage_10_freeimage__DibWrapper = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("smc.freeimage._freeimage._DibWrapper"), /*tp_name*/
  sizeof(struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3smc_9freeimage_10_freeimage__DibWrapper, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number__DibWrapper, /*tp_as_number*/
  &__pyx_tp_as_sequence__DibWrapper, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__DibWrapper, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__DibWrapper, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Wrapper for bitmaps\n    "), /*tp_doc*/
  __pyx_tp_traverse_3smc_9freeimage_10_freeimage__DibWrapper, /*tp_traverse*/
  __pyx_tp_clear_3smc_9freeimage_10_freeimage__DibWrapper, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3smc_9freeimage_10_freeimage__DibWrapper, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3smc_9freeimage_10_freeimage__DibWrapper, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_3smc_9freeimage_10_freeimage__BitmapInfo(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_3smc_9freeimage_10_freeimage__BitmapInfo(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_size(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_4size_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_width(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_5width_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_height(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_6height_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_planes(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_6planes_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_bit_count(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_9bit_count_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_compression(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_11compression_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_size_image(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_10size_image_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_xppm(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_4xppm_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_yppm(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_4yppm_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_colors_used(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_11colors_used_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_colors_important(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_16colors_important_1__get__(o);
}

static PyMethodDef __pyx_methods_3smc_9freeimage_10_freeimage__BitmapInfo[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_3smc_9freeimage_10_freeimage__BitmapInfo[] = {
  {(char *)"size", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_size, 0, 0, 0},
  {(char *)"width", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_width, 0, 0, 0},
  {(char *)"height", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_height, 0, 0, 0},
  {(char *)"planes", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_planes, 0, 0, 0},
  {(char *)"bit_count", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_bit_count, 0, 0, 0},
  {(char *)"compression", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_compression, 0, 0, 0},
  {(char *)"size_image", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_size_image, 0, 0, 0},
  {(char *)"xppm", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_xppm, 0, 0, 0},
  {(char *)"yppm", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_yppm, 0, 0, 0},
  {(char *)"colors_used", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_colors_used, 0, 0, 0},
  {(char *)"colors_important", __pyx_getprop_3smc_9freeimage_10_freeimage_11_BitmapInfo_colors_important, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__BitmapInfo = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__BitmapInfo = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__BitmapInfo = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__BitmapInfo = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_3smc_9freeimage_10_freeimage__BitmapInfo = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("smc.freeimage._freeimage._BitmapInfo"), /*tp_name*/
  sizeof(struct __pyx_obj_3smc_9freeimage_10_freeimage__BitmapInfo), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3smc_9freeimage_10_freeimage__BitmapInfo, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_3smc_9freeimage_10_freeimage_11_BitmapInfo_1__repr__, /*tp_repr*/
  &__pyx_tp_as_number__BitmapInfo, /*tp_as_number*/
  &__pyx_tp_as_sequence__BitmapInfo, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__BitmapInfo, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__BitmapInfo, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("Wrapper for bitmap info header\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3smc_9freeimage_10_freeimage__BitmapInfo, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_3smc_9freeimage_10_freeimage__BitmapInfo, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3smc_9freeimage_10_freeimage__BitmapInfo, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_3smc_9freeimage_10_freeimage__MemoryIO(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)o);
  p->_img = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_3smc_9freeimage_10_freeimage__MemoryIO(PyObject *o) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_3__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_img));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_3smc_9freeimage_10_freeimage__MemoryIO(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)o;
  if (p->_img) {
    e = (*v)(((PyObject*)p->_img), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3smc_9freeimage_10_freeimage__MemoryIO(PyObject *o) {
  struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *p = (struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_img);
  p->_img = ((struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_9_MemoryIO_format(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_6format_1__get__(o);
}

static PyObject *__pyx_getprop_3smc_9freeimage_10_freeimage_9_MemoryIO_size(PyObject *o, void *x) {
  return __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_4size_1__get__(o);
}

static PyMethodDef __pyx_methods_3smc_9freeimage_10_freeimage__MemoryIO[] = {
  {__Pyx_NAMESTR("tell"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_11tell, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_9_MemoryIO_10tell)},
  {__Pyx_NAMESTR("seek"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_13seek, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_9_MemoryIO_12seek)},
  {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_15read, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3smc_9freeimage_10_freeimage_9_MemoryIO_14read)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_3smc_9freeimage_10_freeimage__MemoryIO[] = {
  {(char *)"format", __pyx_getprop_3smc_9freeimage_10_freeimage_9_MemoryIO_format, 0, 0, 0},
  {(char *)"size", __pyx_getprop_3smc_9freeimage_10_freeimage_9_MemoryIO_size, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__MemoryIO = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__MemoryIO = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__MemoryIO = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__MemoryIO = {
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_5__getreadbuffer__, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_7__getsegcount__, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_3smc_9freeimage_10_freeimage__MemoryIO = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("smc.freeimage._freeimage._MemoryIO"), /*tp_name*/
  sizeof(struct __pyx_obj_3smc_9freeimage_10_freeimage__MemoryIO), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3smc_9freeimage_10_freeimage__MemoryIO, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number__MemoryIO, /*tp_as_number*/
  &__pyx_tp_as_sequence__MemoryIO, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__MemoryIO, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_9__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__MemoryIO, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Memory IO interface to an image\n\n    A memory IO object is the preferred way to access a loaded image from\n    Python. It provides a high-performance interface to the FreeImage memory\n    subsystem. The image is available through a read only buffer, a file like\n    object as well as as a string.\n    "), /*tp_doc*/
  __pyx_tp_traverse_3smc_9freeimage_10_freeimage__MemoryIO, /*tp_traverse*/
  __pyx_tp_clear_3smc_9freeimage_10_freeimage__MemoryIO, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3smc_9freeimage_10_freeimage__MemoryIO, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_3smc_9freeimage_10_freeimage__MemoryIO, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_3smc_9freeimage_10_freeimage_9_MemoryIO_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3smc_9freeimage_10_freeimage__MemoryIO, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("_freeimage"),
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
  {&__pyx_kp_s_100, __pyx_k_100, sizeof(__pyx_k_100), 0, 0, 1, 0},
  {&__pyx_kp_s_102, __pyx_k_102, sizeof(__pyx_k_102), 0, 0, 1, 0},
  {&__pyx_kp_s_103, __pyx_k_103, sizeof(__pyx_k_103), 0, 0, 1, 0},
  {&__pyx_kp_s_104, __pyx_k_104, sizeof(__pyx_k_104), 0, 0, 1, 0},
  {&__pyx_kp_s_106, __pyx_k_106, sizeof(__pyx_k_106), 0, 0, 1, 0},
  {&__pyx_kp_s_108, __pyx_k_108, sizeof(__pyx_k_108), 0, 0, 1, 0},
  {&__pyx_kp_s_110, __pyx_k_110, sizeof(__pyx_k_110), 0, 0, 1, 0},
  {&__pyx_kp_s_112, __pyx_k_112, sizeof(__pyx_k_112), 0, 0, 1, 0},
  {&__pyx_kp_s_113, __pyx_k_113, sizeof(__pyx_k_113), 0, 0, 1, 0},
  {&__pyx_kp_s_114, __pyx_k_114, sizeof(__pyx_k_114), 0, 0, 1, 0},
  {&__pyx_kp_s_115, __pyx_k_115, sizeof(__pyx_k_115), 0, 0, 1, 0},
  {&__pyx_kp_s_116, __pyx_k_116, sizeof(__pyx_k_116), 0, 0, 1, 0},
  {&__pyx_kp_s_118, __pyx_k_118, sizeof(__pyx_k_118), 0, 0, 1, 0},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_s_120, __pyx_k_120, sizeof(__pyx_k_120), 0, 0, 1, 0},
  {&__pyx_kp_s_122, __pyx_k_122, sizeof(__pyx_k_122), 0, 0, 1, 0},
  {&__pyx_kp_s_123, __pyx_k_123, sizeof(__pyx_k_123), 0, 0, 1, 0},
  {&__pyx_kp_s_125, __pyx_k_125, sizeof(__pyx_k_125), 0, 0, 1, 0},
  {&__pyx_kp_s_127, __pyx_k_127, sizeof(__pyx_k_127), 0, 0, 1, 0},
  {&__pyx_kp_s_129, __pyx_k_129, sizeof(__pyx_k_129), 0, 0, 1, 0},
  {&__pyx_kp_s_130, __pyx_k_130, sizeof(__pyx_k_130), 0, 0, 1, 0},
  {&__pyx_kp_b_131, __pyx_k_131, sizeof(__pyx_k_131), 0, 0, 0, 0},
  {&__pyx_kp_s_133, __pyx_k_133, sizeof(__pyx_k_133), 0, 0, 1, 0},
  {&__pyx_kp_s_134, __pyx_k_134, sizeof(__pyx_k_134), 0, 0, 1, 0},
  {&__pyx_kp_s_135, __pyx_k_135, sizeof(__pyx_k_135), 0, 0, 1, 0},
  {&__pyx_kp_s_136, __pyx_k_136, sizeof(__pyx_k_136), 0, 0, 1, 0},
  {&__pyx_kp_s_138, __pyx_k_138, sizeof(__pyx_k_138), 0, 0, 1, 0},
  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
  {&__pyx_kp_s_163, __pyx_k_163, sizeof(__pyx_k_163), 0, 0, 1, 0},
  {&__pyx_kp_s_165, __pyx_k_165, sizeof(__pyx_k_165), 0, 0, 1, 0},
  {&__pyx_n_s_166, __pyx_k_166, sizeof(__pyx_k_166), 0, 0, 1, 1},
  {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
  {&__pyx_kp_s_177, __pyx_k_177, sizeof(__pyx_k_177), 0, 0, 1, 0},
  {&__pyx_n_s_185, __pyx_k_185, sizeof(__pyx_k_185), 0, 0, 1, 1},
  {&__pyx_n_s_188, __pyx_k_188, sizeof(__pyx_k_188), 0, 0, 1, 1},
  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  {&__pyx_n_s_191, __pyx_k_191, sizeof(__pyx_k_191), 0, 0, 1, 1},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
  {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
  {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
  {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
  {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
  {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0},
  {&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0},
  {&__pyx_n_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 1},
  {&__pyx_n_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 1},
  {&__pyx_n_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 1},
  {&__pyx_n_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 1},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_n_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 1},
  {&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0},
  {&__pyx_kp_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 0},
  {&__pyx_n_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 1},
  {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0},
  {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0},
  {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0},
  {&__pyx_kp_s_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 0},
  {&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0},
  {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
  {&__pyx_kp_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 0},
  {&__pyx_kp_s_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 1, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_60, __pyx_k_60, sizeof(__pyx_k_60), 0, 0, 1, 0},
  {&__pyx_kp_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 0},
  {&__pyx_kp_s_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 1, 0},
  {&__pyx_kp_s_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 1, 0},
  {&__pyx_kp_s_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 0, 1, 0},
  {&__pyx_kp_s_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 0, 1, 0},
  {&__pyx_kp_s_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 0, 1, 0},
  {&__pyx_kp_s_71, __pyx_k_71, sizeof(__pyx_k_71), 0, 0, 1, 0},
  {&__pyx_kp_s_73, __pyx_k_73, sizeof(__pyx_k_73), 0, 0, 1, 0},
  {&__pyx_kp_s_76, __pyx_k_76, sizeof(__pyx_k_76), 0, 0, 1, 0},
  {&__pyx_kp_s_78, __pyx_k_78, sizeof(__pyx_k_78), 0, 0, 1, 0},
  {&__pyx_kp_s_79, __pyx_k_79, sizeof(__pyx_k_79), 0, 0, 1, 0},
  {&__pyx_kp_s_80, __pyx_k_80, sizeof(__pyx_k_80), 0, 0, 1, 0},
  {&__pyx_kp_s_81, __pyx_k_81, sizeof(__pyx_k_81), 0, 0, 1, 0},
  {&__pyx_n_s_83, __pyx_k_83, sizeof(__pyx_k_83), 0, 0, 1, 1},
  {&__pyx_kp_s_85, __pyx_k_85, sizeof(__pyx_k_85), 0, 0, 1, 0},
  {&__pyx_kp_s_86, __pyx_k_86, sizeof(__pyx_k_86), 0, 0, 1, 0},
  {&__pyx_kp_s_88, __pyx_k_88, sizeof(__pyx_k_88), 0, 0, 1, 0},
  {&__pyx_kp_s_89, __pyx_k_89, sizeof(__pyx_k_89), 0, 0, 1, 0},
  {&__pyx_kp_s_90, __pyx_k_90, sizeof(__pyx_k_90), 0, 0, 1, 0},
  {&__pyx_kp_s_92, __pyx_k_92, sizeof(__pyx_k_92), 0, 0, 1, 0},
  {&__pyx_kp_s_93, __pyx_k_93, sizeof(__pyx_k_93), 0, 0, 1, 0},
  {&__pyx_kp_s_94, __pyx_k_94, sizeof(__pyx_k_94), 0, 0, 1, 0},
  {&__pyx_kp_s_95, __pyx_k_95, sizeof(__pyx_k_95), 0, 0, 1, 0},
  {&__pyx_kp_s_97, __pyx_k_97, sizeof(__pyx_k_97), 0, 0, 1, 0},
  {&__pyx_kp_s_98, __pyx_k_98, sizeof(__pyx_k_98), 0, 0, 1, 0},
  {&__pyx_n_s__A, __pyx_k__A, sizeof(__pyx_k__A), 0, 0, 1, 1},
  {&__pyx_n_s__BGR, __pyx_k__BGR, sizeof(__pyx_k__BGR), 0, 0, 1, 1},
  {&__pyx_n_s__Black, __pyx_k__Black, sizeof(__pyx_k__Black), 0, 0, 1, 1},
  {&__pyx_n_s__CMYK, __pyx_k__CMYK, sizeof(__pyx_k__CMYK), 0, 0, 1, 1},
  {&__pyx_n_s__D50, __pyx_k__D50, sizeof(__pyx_k__D50), 0, 0, 1, 1},
  {&__pyx_n_s__D55, __pyx_k__D55, sizeof(__pyx_k__D55), 0, 0, 1, 1},
  {&__pyx_n_s__D65, __pyx_k__D65, sizeof(__pyx_k__D65), 0, 0, 1, 1},
  {&__pyx_n_s__D93, __pyx_k__D93, sizeof(__pyx_k__D93), 0, 0, 1, 1},
  {&__pyx_n_s__DIB, __pyx_k__DIB, sizeof(__pyx_k__DIB), 0, 0, 1, 1},
  {&__pyx_n_s__E, __pyx_k__E, sizeof(__pyx_k__E), 0, 0, 1, 1},
  {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1},
  {&__pyx_n_s__F2, __pyx_k__F2, sizeof(__pyx_k__F2), 0, 0, 1, 1},
  {&__pyx_n_s__F8, __pyx_k__F8, sizeof(__pyx_k__F8), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_ANIMATION, __pyx_k__FIMD_ANIMATION, sizeof(__pyx_k__FIMD_ANIMATION), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_COMMENTS, __pyx_k__FIMD_COMMENTS, sizeof(__pyx_k__FIMD_COMMENTS), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_CUSTOM, __pyx_k__FIMD_CUSTOM, sizeof(__pyx_k__FIMD_CUSTOM), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_EXIF_EXIF, __pyx_k__FIMD_EXIF_EXIF, sizeof(__pyx_k__FIMD_EXIF_EXIF), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_EXIF_GPS, __pyx_k__FIMD_EXIF_GPS, sizeof(__pyx_k__FIMD_EXIF_GPS), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_EXIF_INTEROP, __pyx_k__FIMD_EXIF_INTEROP, sizeof(__pyx_k__FIMD_EXIF_INTEROP), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_EXIF_MAIN, __pyx_k__FIMD_EXIF_MAIN, sizeof(__pyx_k__FIMD_EXIF_MAIN), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_EXIF_MAKERNOTE, __pyx_k__FIMD_EXIF_MAKERNOTE, sizeof(__pyx_k__FIMD_EXIF_MAKERNOTE), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_GEOTIFF, __pyx_k__FIMD_GEOTIFF, sizeof(__pyx_k__FIMD_GEOTIFF), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_IPTC, __pyx_k__FIMD_IPTC, sizeof(__pyx_k__FIMD_IPTC), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_NODATA, __pyx_k__FIMD_NODATA, sizeof(__pyx_k__FIMD_NODATA), 0, 0, 1, 1},
  {&__pyx_n_s__FIMD_XMP, __pyx_k__FIMD_XMP, sizeof(__pyx_k__FIMD_XMP), 0, 0, 1, 1},
  {&__pyx_n_s__FormatInfo, __pyx_k__FormatInfo, sizeof(__pyx_k__FormatInfo), 0, 0, 1, 1},
  {&__pyx_n_s__FreeImageError, __pyx_k__FreeImageError, sizeof(__pyx_k__FreeImageError), 0, 0, 1, 1},
  {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
  {&__pyx_n_s__Image, __pyx_k__Image, sizeof(__pyx_k__Image), 0, 0, 1, 1},
  {&__pyx_n_s__LCMSException, __pyx_k__LCMSException, sizeof(__pyx_k__LCMSException), 0, 0, 1, 1},
  {&__pyx_n_s__LCMSIccCache, __pyx_k__LCMSIccCache, sizeof(__pyx_k__LCMSIccCache), 0, 0, 1, 1},
  {&__pyx_n_s__LCMSProfileInfo, __pyx_k__LCMSProfileInfo, sizeof(__pyx_k__LCMSProfileInfo), 0, 0, 1, 1},
  {&__pyx_n_s__LCMSTransformation, __pyx_k__LCMSTransformation, sizeof(__pyx_k__LCMSTransformation), 0, 0, 1, 1},
  {&__pyx_n_s__LoadError, __pyx_k__LoadError, sizeof(__pyx_k__LoadError), 0, 0, 1, 1},
  {&__pyx_n_s__MemoryError, __pyx_k__MemoryError, sizeof(__pyx_k__MemoryError), 0, 0, 1, 1},
  {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
  {&__pyx_n_s__OperationError, __pyx_k__OperationError, sizeof(__pyx_k__OperationError), 0, 0, 1, 1},
  {&__pyx_n_s__Palette, __pyx_k__Palette, sizeof(__pyx_k__Palette), 0, 0, 1, 1},
  {&__pyx_n_s__RGB, __pyx_k__RGB, sizeof(__pyx_k__RGB), 0, 0, 1, 1},
  {&__pyx_n_s__RGBA, __pyx_k__RGBA, sizeof(__pyx_k__RGBA), 0, 0, 1, 1},
  {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s__SaveError, __pyx_k__SaveError, sizeof(__pyx_k__SaveError), 0, 0, 1, 1},
  {&__pyx_n_s__SystemError, __pyx_k__SystemError, sizeof(__pyx_k__SystemError), 0, 0, 1, 1},
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__UNKNOWN, __pyx_k__UNKNOWN, sizeof(__pyx_k__UNKNOWN), 0, 0, 1, 1},
  {&__pyx_n_s__UnknownImageError, __pyx_k__UnknownImageError, sizeof(__pyx_k__UnknownImageError), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s__White, __pyx_k__White, sizeof(__pyx_k__White), 0, 0, 1, 1},
  {&__pyx_n_s__X, __pyx_k__X, sizeof(__pyx_k__X), 0, 0, 1, 1},
  {&__pyx_n_s__XYZ, __pyx_k__XYZ, sizeof(__pyx_k__XYZ), 0, 0, 1, 1},
  {&__pyx_n_s__XYZ2xyY, __pyx_k__XYZ2xyY, sizeof(__pyx_k__XYZ2xyY), 0, 0, 1, 1},
  {&__pyx_n_s__Y, __pyx_k__Y, sizeof(__pyx_k__Y), 0, 0, 1, 1},
  {&__pyx_n_s__Z, __pyx_k__Z, sizeof(__pyx_k__Z), 0, 0, 1, 1},
  {&__pyx_n_s___COLOR_TYPE_NAMES, __pyx_k___COLOR_TYPE_NAMES, sizeof(__pyx_k___COLOR_TYPE_NAMES), 0, 0, 1, 1},
  {&__pyx_n_s___META_MODELS, __pyx_k___META_MODELS, sizeof(__pyx_k___META_MODELS), 0, 0, 1, 1},
  {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
  {&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1},
  {&__pyx_n_s____enter__, __pyx_k____enter__, sizeof(__pyx_k____enter__), 0, 0, 1, 1},
  {&__pyx_n_s____exit__, __pyx_k____exit__, sizeof(__pyx_k____exit__), 0, 0, 1, 1},
  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____name__, __pyx_k____name__, sizeof(__pyx_k____name__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___bitmap, __pyx_k___bitmap, sizeof(__pyx_k___bitmap), 0, 0, 1, 1},
  {&__pyx_n_s___illu_map, __pyx_k___illu_map, sizeof(__pyx_k___illu_map), 0, 0, 1, 1},
  {&__pyx_n_s___new_image, __pyx_k___new_image, sizeof(__pyx_k___new_image), 0, 0, 1, 1},
  {&__pyx_n_s___readNamedColorList, __pyx_k___readNamedColorList, sizeof(__pyx_k___readNamedColorList), 0, 0, 1, 1},
  {&__pyx_n_s___sys, __pyx_k___sys, sizeof(__pyx_k___sys), 0, 0, 1, 1},
  {&__pyx_n_s__adjustColors, __pyx_k__adjustColors, sizeof(__pyx_k__adjustColors), 0, 0, 1, 1},
  {&__pyx_n_s__allocate, __pyx_k__allocate, sizeof(__pyx_k__allocate), 0, 0, 1, 1},
  {&__pyx_n_s__allocation, __pyx_k__allocation, sizeof(__pyx_k__allocation), 0, 0, 1, 1},
  {&__pyx_n_s__alpha, __pyx_k__alpha, sizeof(__pyx_k__alpha), 0, 0, 1, 1},
  {&__pyx_n_s__angle, __pyx_k__angle, sizeof(__pyx_k__angle), 0, 0, 1, 1},
  {&__pyx_n_s__args, __pyx_k__args, sizeof(__pyx_k__args), 0, 0, 1, 1},
  {&__pyx_n_s__attributes, __pyx_k__attributes, sizeof(__pyx_k__attributes), 0, 0, 1, 1},
  {&__pyx_n_s__backing, __pyx_k__backing, sizeof(__pyx_k__backing), 0, 0, 1, 1},
  {&__pyx_n_s__bdst, __pyx_k__bdst, sizeof(__pyx_k__bdst), 0, 0, 1, 1},
  {&__pyx_n_s__blue, __pyx_k__blue, sizeof(__pyx_k__blue), 0, 0, 1, 1},
  {&__pyx_n_s__blueColorant, __pyx_k__blueColorant, sizeof(__pyx_k__blueColorant), 0, 0, 1, 1},
  {&__pyx_n_s__bluePrimary, __pyx_k__bluePrimary, sizeof(__pyx_k__bluePrimary), 0, 0, 1, 1},
  {&__pyx_n_s__blue_mask, __pyx_k__blue_mask, sizeof(__pyx_k__blue_mask), 0, 0, 1, 1},
  {&__pyx_n_s__bottom, __pyx_k__bottom, sizeof(__pyx_k__bottom), 0, 0, 1, 1},
  {&__pyx_n_s__bpp, __pyx_k__bpp, sizeof(__pyx_k__bpp), 0, 0, 1, 1},
  {&__pyx_n_s__brightness, __pyx_k__brightness, sizeof(__pyx_k__brightness), 0, 0, 1, 1},
  {&__pyx_n_s__brigthness, __pyx_k__brigthness, sizeof(__pyx_k__brigthness), 0, 0, 1, 1},
  {&__pyx_n_s__bsrc, __pyx_k__bsrc, sizeof(__pyx_k__bsrc), 0, 0, 1, 1},
  {&__pyx_n_s__buffer, __pyx_k__buffer, sizeof(__pyx_k__buffer), 0, 0, 1, 1},
  {&__pyx_n_s__cdst, __pyx_k__cdst, sizeof(__pyx_k__cdst), 0, 0, 1, 1},
  {&__pyx_n_s__channel, __pyx_k__channel, sizeof(__pyx_k__channel), 0, 0, 1, 1},
  {&__pyx_n_s__chromaticAdaptation, __pyx_k__chromaticAdaptation, sizeof(__pyx_k__chromaticAdaptation), 0, 0, 1, 1},
  {&__pyx_n_s__chromaticity, __pyx_k__chromaticity, sizeof(__pyx_k__chromaticity), 0, 0, 1, 1},
  {&__pyx_n_s__clear, __pyx_k__clear, sizeof(__pyx_k__clear), 0, 0, 1, 1},
  {&__pyx_n_s__clone, __pyx_k__clone, sizeof(__pyx_k__clone), 0, 0, 1, 1},
  {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1},
  {&__pyx_n_s__cls, __pyx_k__cls, sizeof(__pyx_k__cls), 0, 0, 1, 1},
  {&__pyx_n_s__colorSpace, __pyx_k__colorSpace, sizeof(__pyx_k__colorSpace), 0, 0, 1, 1},
  {&__pyx_n_s__color_type_name, __pyx_k__color_type_name, sizeof(__pyx_k__color_type_name), 0, 0, 1, 1},
  {&__pyx_n_s__colorantTable, __pyx_k__colorantTable, sizeof(__pyx_k__colorantTable), 0, 0, 1, 1},
  {&__pyx_n_s__colorantTableOut, __pyx_k__colorantTableOut, sizeof(__pyx_k__colorantTableOut), 0, 0, 1, 1},
  {&__pyx_n_s__colorimetricIntent, __pyx_k__colorimetricIntent, sizeof(__pyx_k__colorimetricIntent), 0, 0, 1, 1},
  {&__pyx_n_s__connectionSpace, __pyx_k__connectionSpace, sizeof(__pyx_k__connectionSpace), 0, 0, 1, 1},
  {&__pyx_n_s__contrast, __pyx_k__contrast, sizeof(__pyx_k__contrast), 0, 0, 1, 1},
  {&__pyx_n_s__copyright, __pyx_k__copyright, sizeof(__pyx_k__copyright), 0, 0, 1, 1},
  {&__pyx_n_s__creationDate, __pyx_k__creationDate, sizeof(__pyx_k__creationDate), 0, 0, 1, 1},
  {&__pyx_n_s__csrc, __pyx_k__csrc, sizeof(__pyx_k__csrc), 0, 0, 1, 1},
  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
  {&__pyx_n_s__datetime, __pyx_k__datetime, sizeof(__pyx_k__datetime), 0, 0, 1, 1},
  {&__pyx_n_s__deviceClass, __pyx_k__deviceClass, sizeof(__pyx_k__deviceClass), 0, 0, 1, 1},
  {&__pyx_n_s__dib, __pyx_k__dib, sizeof(__pyx_k__dib), 0, 0, 1, 1},
  {&__pyx_n_s__dispatchFIError, __pyx_k__dispatchFIError, sizeof(__pyx_k__dispatchFIError), 0, 0, 1, 1},
  {&__pyx_n_s__dpi_x, __pyx_k__dpi_x, sizeof(__pyx_k__dpi_x), 0, 0, 1, 1},
  {&__pyx_n_s__dpi_y, __pyx_k__dpi_y, sizeof(__pyx_k__dpi_y), 0, 0, 1, 1},
  {&__pyx_n_s__dpm_x, __pyx_k__dpm_x, sizeof(__pyx_k__dpm_x), 0, 0, 1, 1},
  {&__pyx_n_s__dpm_y, __pyx_k__dpm_y, sizeof(__pyx_k__dpm_y), 0, 0, 1, 1},
  {&__pyx_n_s__dst, __pyx_k__dst, sizeof(__pyx_k__dst), 0, 0, 1, 1},
  {&__pyx_n_s__dst_type, __pyx_k__dst_type, sizeof(__pyx_k__dst_type), 0, 0, 1, 1},
  {&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
  {&__pyx_n_s__err, __pyx_k__err, sizeof(__pyx_k__err), 0, 0, 1, 1},
  {&__pyx_n_s__exc, __pyx_k__exc, sizeof(__pyx_k__exc), 0, 0, 1, 1},
  {&__pyx_n_s__fd, __pyx_k__fd, sizeof(__pyx_k__fd), 0, 0, 1, 1},
  {&__pyx_n_s__filename, __pyx_k__filename, sizeof(__pyx_k__filename), 0, 0, 1, 1},
  {&__pyx_n_s__filter, __pyx_k__filter, sizeof(__pyx_k__filter), 0, 0, 1, 1},
  {&__pyx_n_s__fimsg, __pyx_k__fimsg, sizeof(__pyx_k__fimsg), 0, 0, 1, 1},
  {&__pyx_n_s__fimsgl, __pyx_k__fimsgl, sizeof(__pyx_k__fimsgl), 0, 0, 1, 1},
  {&__pyx_n_s__flags, __pyx_k__flags, sizeof(__pyx_k__flags), 0, 0, 1, 1},
  {&__pyx_n_s__flare, __pyx_k__flare, sizeof(__pyx_k__flare), 0, 0, 1, 1},
  {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
  {&__pyx_n_s__from_fd, __pyx_k__from_fd, sizeof(__pyx_k__from_fd), 0, 0, 1, 1},
  {&__pyx_n_s__from_file, __pyx_k__from_file, sizeof(__pyx_k__from_file), 0, 0, 1, 1},
  {&__pyx_n_s__from_filename, __pyx_k__from_filename, sizeof(__pyx_k__from_filename), 0, 0, 1, 1},
  {&__pyx_n_s__from_mimetype, __pyx_k__from_mimetype, sizeof(__pyx_k__from_mimetype), 0, 0, 1, 1},
  {&__pyx_n_s__gamma, __pyx_k__gamma, sizeof(__pyx_k__gamma), 0, 0, 1, 1},
  {&__pyx_n_s__geometry, __pyx_k__geometry, sizeof(__pyx_k__geometry), 0, 0, 1, 1},
  {&__pyx_n_s__get, __pyx_k__get, sizeof(__pyx_k__get), 0, 0, 1, 1},
  {&__pyx_n_s__getCompiledFor, __pyx_k__getCompiledFor, sizeof(__pyx_k__getCompiledFor), 0, 0, 1, 1},
  {&__pyx_n_s__getCopyright, __pyx_k__getCopyright, sizeof(__pyx_k__getCopyright), 0, 0, 1, 1},
  {&__pyx_n_s__getFormatCount, __pyx_k__getFormatCount, sizeof(__pyx_k__getFormatCount), 0, 0, 1, 1},
  {&__pyx_n_s__getICC, __pyx_k__getICC, sizeof(__pyx_k__getICC), 0, 0, 1, 1},
  {&__pyx_n_s__getIntents, __pyx_k__getIntents, sizeof(__pyx_k__getIntents), 0, 0, 1, 1},
  {&__pyx_n_s__getLCMSVersion, __pyx_k__getLCMSVersion, sizeof(__pyx_k__getLCMSVersion), 0, 0, 1, 1},
  {&__pyx_n_s__getLogger, __pyx_k__getLogger, sizeof(__pyx_k__getLogger), 0, 0, 1, 1},
  {&__pyx_n_s__getVersion, __pyx_k__getVersion, sizeof(__pyx_k__getVersion), 0, 0, 1, 1},
  {&__pyx_n_s__green, __pyx_k__green, sizeof(__pyx_k__green), 0, 0, 1, 1},
  {&__pyx_n_s__greenColorant, __pyx_k__greenColorant, sizeof(__pyx_k__greenColorant), 0, 0, 1, 1},
  {&__pyx_n_s__greenPrimary, __pyx_k__greenPrimary, sizeof(__pyx_k__greenPrimary), 0, 0, 1, 1},
  {&__pyx_n_s__green_mask, __pyx_k__green_mask, sizeof(__pyx_k__green_mask), 0, 0, 1, 1},
  {&__pyx_n_s__hasJPEGTurbo, __pyx_k__hasJPEGTurbo, sizeof(__pyx_k__hasJPEGTurbo), 0, 0, 1, 1},
  {&__pyx_n_s__has_icc, __pyx_k__has_icc, sizeof(__pyx_k__has_icc), 0, 0, 1, 1},
  {&__pyx_n_s__headerFlags, __pyx_k__headerFlags, sizeof(__pyx_k__headerFlags), 0, 0, 1, 1},
  {&__pyx_n_s__headerManufacturer, __pyx_k__headerManufacturer, sizeof(__pyx_k__headerManufacturer), 0, 0, 1, 1},
  {&__pyx_n_s__headerModel, __pyx_k__headerModel, sizeof(__pyx_k__headerModel), 0, 0, 1, 1},
  {&__pyx_n_s__height, __pyx_k__height, sizeof(__pyx_k__height), 0, 0, 1, 1},
  {&__pyx_n_s__hex, __pyx_k__hex, sizeof(__pyx_k__hex), 0, 0, 1, 1},
  {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1},
  {&__pyx_n_s__iccVersion, __pyx_k__iccVersion, sizeof(__pyx_k__iccVersion), 0, 0, 1, 1},
  {&__pyx_n_s__iccViewingCondition, __pyx_k__iccViewingCondition, sizeof(__pyx_k__iccViewingCondition), 0, 0, 1, 1},
  {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
  {&__pyx_n_s__illuminant, __pyx_k__illuminant, sizeof(__pyx_k__illuminant), 0, 0, 1, 1},
  {&__pyx_n_s__illuminantType, __pyx_k__illuminantType, sizeof(__pyx_k__illuminantType), 0, 0, 1, 1},
  {&__pyx_n_s__img, __pyx_k__img, sizeof(__pyx_k__img), 0, 0, 1, 1},
  {&__pyx_n_s__in, __pyx_k__in, sizeof(__pyx_k__in), 0, 0, 1, 1},
  {&__pyx_n_s__info, __pyx_k__info, sizeof(__pyx_k__info), 0, 0, 1, 1},
  {&__pyx_n_s__inprofile, __pyx_k__inprofile, sizeof(__pyx_k__inprofile), 0, 0, 1, 1},
  {&__pyx_n_s__intent, __pyx_k__intent, sizeof(__pyx_k__intent), 0, 0, 1, 1},
  {&__pyx_n_s__intent_descs, __pyx_k__intent_descs, sizeof(__pyx_k__intent_descs), 0, 0, 1, 1},
  {&__pyx_n_s__intent_ids, __pyx_k__intent_ids, sizeof(__pyx_k__intent_ids), 0, 0, 1, 1},
  {&__pyx_n_s__intents, __pyx_k__intents, sizeof(__pyx_k__intents), 0, 0, 1, 1},
  {&__pyx_n_s__invert, __pyx_k__invert, sizeof(__pyx_k__invert), 0, 0, 1, 1},
  {&__pyx_n_s__isCLUT, __pyx_k__isCLUT, sizeof(__pyx_k__isCLUT), 0, 0, 1, 1},
  {&__pyx_n_s__isIntentSupported, __pyx_k__isIntentSupported, sizeof(__pyx_k__isIntentSupported), 0, 0, 1, 1},
  {&__pyx_n_s__isMatrixShaper, __pyx_k__isMatrixShaper, sizeof(__pyx_k__isMatrixShaper), 0, 0, 1, 1},
  {&__pyx_n_s__items, __pyx_k__items, sizeof(__pyx_k__items), 0, 0, 1, 1},
  {&__pyx_n_s__jpegTransform, __pyx_k__jpegTransform, sizeof(__pyx_k__jpegTransform), 0, 0, 1, 1},
  {&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1},
  {&__pyx_n_s__left, __pyx_k__left, sizeof(__pyx_k__left), 0, 0, 1, 1},
  {&__pyx_n_s__linewidth, __pyx_k__linewidth, sizeof(__pyx_k__linewidth), 0, 0, 1, 1},
  {&__pyx_n_s__loggername, __pyx_k__loggername, sizeof(__pyx_k__loggername), 0, 0, 1, 1},
  {&__pyx_n_s__logging, __pyx_k__logging, sizeof(__pyx_k__logging), 0, 0, 1, 1},
  {&__pyx_n_s__lookup, __pyx_k__lookup, sizeof(__pyx_k__lookup), 0, 0, 1, 1},
  {&__pyx_n_s__lookupSVGColor, __pyx_k__lookupSVGColor, sizeof(__pyx_k__lookupSVGColor), 0, 0, 1, 1},
  {&__pyx_n_s__lookupX11Color, __pyx_k__lookupX11Color, sizeof(__pyx_k__lookupX11Color), 0, 0, 1, 1},
  {&__pyx_n_s__lower, __pyx_k__lower, sizeof(__pyx_k__lower), 0, 0, 1, 1},
  {&__pyx_n_s__luminance, __pyx_k__luminance, sizeof(__pyx_k__luminance), 0, 0, 1, 1},
  {&__pyx_n_s__manufacturer, __pyx_k__manufacturer, sizeof(__pyx_k__manufacturer), 0, 0, 1, 1},
  {&__pyx_n_s__mediaBlackPoint, __pyx_k__mediaBlackPoint, sizeof(__pyx_k__mediaBlackPoint), 0, 0, 1, 1},
  {&__pyx_n_s__mediaWhitePoint, __pyx_k__mediaWhitePoint, sizeof(__pyx_k__mediaWhitePoint), 0, 0, 1, 1},
  {&__pyx_n_s__memory, __pyx_k__memory, sizeof(__pyx_k__memory), 0, 0, 1, 1},
  {&__pyx_n_s__mime, __pyx_k__mime, sizeof(__pyx_k__mime), 0, 0, 1, 1},
  {&__pyx_n_s__mimetype, __pyx_k__mimetype, sizeof(__pyx_k__mimetype), 0, 0, 1, 1},
  {&__pyx_n_s__model, __pyx_k__model, sizeof(__pyx_k__model), 0, 0, 1, 1},
  {&__pyx_n_s__msg, __pyx_k__msg, sizeof(__pyx_k__msg), 0, 0, 1, 1},
  {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1},
  {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
  {&__pyx_n_s__new, __pyx_k__new, sizeof(__pyx_k__new), 0, 0, 1, 1},
  {&__pyx_n_s__observer, __pyx_k__observer, sizeof(__pyx_k__observer), 0, 0, 1, 1},
  {&__pyx_n_s__offset, __pyx_k__offset, sizeof(__pyx_k__offset), 0, 0, 1, 1},
  {&__pyx_n_s__op, __pyx_k__op, sizeof(__pyx_k__op), 0, 0, 1, 1},
  {&__pyx_n_s__open, __pyx_k__open, sizeof(__pyx_k__open), 0, 0, 1, 1},
  {&__pyx_n_s__out, __pyx_k__out, sizeof(__pyx_k__out), 0, 0, 1, 1},
  {&__pyx_n_s__outprofile, __pyx_k__outprofile, sizeof(__pyx_k__outprofile), 0, 0, 1, 1},
  {&__pyx_n_s__perfect, __pyx_k__perfect, sizeof(__pyx_k__perfect), 0, 0, 1, 1},
  {&__pyx_n_s__profileDescription, __pyx_k__profileDescription, sizeof(__pyx_k__profileDescription), 0, 0, 1, 1},
  {&__pyx_n_s__profileid, __pyx_k__profileid, sizeof(__pyx_k__profileid), 0, 0, 1, 1},
  {&__pyx_n_s__rb, __pyx_k__rb, sizeof(__pyx_k__rb), 0, 0, 1, 1},
  {&__pyx_n_s__read, __pyx_k__read, sizeof(__pyx_k__read), 0, 0, 1, 1},
  {&__pyx_n_s__red, __pyx_k__red, sizeof(__pyx_k__red), 0, 0, 1, 1},
  {&__pyx_n_s__redColorant, __pyx_k__redColorant, sizeof(__pyx_k__redColorant), 0, 0, 1, 1},
  {&__pyx_n_s__redPrimary, __pyx_k__redPrimary, sizeof(__pyx_k__redPrimary), 0, 0, 1, 1},
  {&__pyx_n_s__red_mask, __pyx_k__red_mask, sizeof(__pyx_k__red_mask), 0, 0, 1, 1},
  {&__pyx_n_s__renderingIntent, __pyx_k__renderingIntent, sizeof(__pyx_k__renderingIntent), 0, 0, 1, 1},
  {&__pyx_n_s__result, __pyx_k__result, sizeof(__pyx_k__result), 0, 0, 1, 1},
  {&__pyx_n_s__right, __pyx_k__right, sizeof(__pyx_k__right), 0, 0, 1, 1},
  {&__pyx_n_s__round, __pyx_k__round, sizeof(__pyx_k__round), 0, 0, 1, 1},
  {&__pyx_n_s__s, __pyx_k__s, sizeof(__pyx_k__s), 0, 0, 1, 1},
  {&__pyx_n_b__sRGB, __pyx_k__sRGB, sizeof(__pyx_k__sRGB), 0, 0, 0, 1},
  {&__pyx_n_s__scale_linear, __pyx_k__scale_linear, sizeof(__pyx_k__scale_linear), 0, 0, 1, 1},
  {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
  {&__pyx_n_s__size, __pyx_k__size, sizeof(__pyx_k__size), 0, 0, 1, 1},
  {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
  {&__pyx_n_s__src, __pyx_k__src, sizeof(__pyx_k__src), 0, 0, 1, 1},
  {&__pyx_n_s__staticmethod, __pyx_k__staticmethod, sizeof(__pyx_k__staticmethod), 0, 0, 1, 1},
  {&__pyx_n_s__super, __pyx_k__super, sizeof(__pyx_k__super), 0, 0, 1, 1},
  {&__pyx_n_s__surround, __pyx_k__surround, sizeof(__pyx_k__surround), 0, 0, 1, 1},
  {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
  {&__pyx_n_s__target, __pyx_k__target, sizeof(__pyx_k__target), 0, 0, 1, 1},
  {&__pyx_n_s__tb, __pyx_k__tb, sizeof(__pyx_k__tb), 0, 0, 1, 1},
  {&__pyx_n_s__technology, __pyx_k__technology, sizeof(__pyx_k__technology), 0, 0, 1, 1},
  {&__pyx_n_s__tempFromWhitePoint, __pyx_k__tempFromWhitePoint, sizeof(__pyx_k__tempFromWhitePoint), 0, 0, 1, 1},
  {&__pyx_n_s__tempK, __pyx_k__tempK, sizeof(__pyx_k__tempK), 0, 0, 1, 1},
  {&__pyx_n_s__toBuffer, __pyx_k__toBuffer, sizeof(__pyx_k__toBuffer), 0, 0, 1, 1},
  {&__pyx_n_s__top, __pyx_k__top, sizeof(__pyx_k__top), 0, 0, 1, 1},
  {&__pyx_n_s__trafo, __pyx_k__trafo, sizeof(__pyx_k__trafo), 0, 0, 1, 1},
  {&__pyx_n_s__unknown, __pyx_k__unknown, sizeof(__pyx_k__unknown), 0, 0, 1, 1},
  {&__pyx_n_s__use_mask, __pyx_k__use_mask, sizeof(__pyx_k__use_mask), 0, 0, 1, 1},
  {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
  {&__pyx_n_s__values, __pyx_k__values, sizeof(__pyx_k__values), 0, 0, 1, 1},
  {&__pyx_n_s__version, __pyx_k__version, sizeof(__pyx_k__version), 0, 0, 1, 1},
  {&__pyx_n_s__viewingCondition, __pyx_k__viewingCondition, sizeof(__pyx_k__viewingCondition), 0, 0, 1, 1},
  {&__pyx_n_s__whence, __pyx_k__whence, sizeof(__pyx_k__whence), 0, 0, 1, 1},
  {&__pyx_n_s__width, __pyx_k__width, sizeof(__pyx_k__width), 0, 0, 1, 1},
  {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
  {&__pyx_n_s__x_origin, __pyx_k__x_origin, sizeof(__pyx_k__x_origin), 0, 0, 1, 1},
  {&__pyx_n_s__x_shift, __pyx_k__x_shift, sizeof(__pyx_k__x_shift), 0, 0, 1, 1},
  {&__pyx_n_s__xend, __pyx_k__xend, sizeof(__pyx_k__xend), 0, 0, 1, 1},
  {&__pyx_n_s__xstart, __pyx_k__xstart, sizeof(__pyx_k__xstart), 0, 0, 1, 1},
  {&__pyx_n_s__xyY, __pyx_k__xyY, sizeof(__pyx_k__xyY), 0, 0, 1, 1},
  {&__pyx_n_s__xyY2XYZ, __pyx_k__xyY2XYZ, sizeof(__pyx_k__xyY2XYZ), 0, 0, 1, 1},
  {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1},
  {&__pyx_n_s__y_origin, __pyx_k__y_origin, sizeof(__pyx_k__y_origin), 0, 0, 1, 1},
  {&__pyx_n_s__y_shift, __pyx_k__y_shift, sizeof(__pyx_k__y_shift), 0, 0, 1, 1},
  {&__pyx_n_s__yend, __pyx_k__yend, sizeof(__pyx_k__yend), 0, 0, 1, 1},
  {&__pyx_n_s__ystart, __pyx_k__ystart, sizeof(__pyx_k__ystart), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_MemoryError = __Pyx_GetName(__pyx_b, __pyx_n_s__MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_staticmethod = __Pyx_GetName(__pyx_b, __pyx_n_s__staticmethod); if (!__pyx_builtin_staticmethod) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_hex = __Pyx_GetName(__pyx_b, __pyx_n_s__hex); if (!__pyx_builtin_hex) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_super = __Pyx_GetName(__pyx_b, __pyx_n_s__super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_SystemError = __Pyx_GetName(__pyx_b, __pyx_n_s__SystemError); if (!__pyx_builtin_SystemError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_id = __Pyx_GetName(__pyx_b, __pyx_n_s__id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_round = __Pyx_GetName(__pyx_b, __pyx_n_s__round); if (!__pyx_builtin_round) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "smc/freeimage/_freeimage.pyx":96
 *     elif cpython.PyUnicode_Check(filename):
 *         # XXX try FS encoding first
 *         return filename.encode("utf-8")             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError(filename)
 */
  __pyx_k_tuple_3 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_3);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
  PyTuple_SET_ITEM(__pyx_k_tuple_3, 0, ((PyObject *)__pyx_kp_s_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":195
 *                       unsigned long flags=0):
 *         if self.hInProfile == NULL:
 *             raise LCMSException("No in profile")             # <<<<<<<<<<<<<<
 *         if self.hOutProfile == NULL:
 *             raise LCMSException("No out profile")
 */
  __pyx_k_tuple_11 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_11);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_10));
  PyTuple_SET_ITEM(__pyx_k_tuple_11, 0, ((PyObject *)__pyx_kp_s_10));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_10));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":197
 *             raise LCMSException("No in profile")
 *         if self.hOutProfile == NULL:
 *             raise LCMSException("No out profile")             # <<<<<<<<<<<<<<
 *             return -1
 *         self.hTransform = lcms.cmsCreateTransformTHR(< lcms.cmsContext > cpython.PyThread_get_thread_ident(),
 */
  __pyx_k_tuple_13 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_13);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
  PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_kp_s_12));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":204
 *                                              intent, flags)
 *         if self.hTransform == NULL:
 *             raise LCMSException("Failed to create transformation")             # <<<<<<<<<<<<<<
 *         with nogil:
 *             # with LCMS2 we can close the profiles after the
 */
  __pyx_k_tuple_15 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_15);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_14));
  PyTuple_SET_ITEM(__pyx_k_tuple_15, 0, ((PyObject *)__pyx_kp_s_14));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_14));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":309
 *         dib = img._dib
 *         if not dib:
 *             raise ValueError("Image has no data")             # <<<<<<<<<<<<<<
 *         if inprofile is None:
 *             if not img.has_icc:
 */
  __pyx_k_tuple_18 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_18);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_18, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":312
 *         if inprofile is None:
 *             if not img.has_icc:
 *                 raise ValueError("Image has no embedded ICC profile")             # <<<<<<<<<<<<<<
 *             inprofile = img.getICC()
 * 
 */
  __pyx_k_tuple_20 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_20);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
  PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, ((PyObject *)__pyx_kp_s_19));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":340
 *         trafo = self.lookup(inprofile, outprofile, format, intent, flags)
 *         if trafo is None or not isinstance(trafo, LCMSTransformation):
 *             raise ValueError("Failed to lookup or create transformation")             # <<<<<<<<<<<<<<
 * 
 *         hTransform = (< LCMSTransformation > trafo).hTransform
 */
  __pyx_k_tuple_23 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_23);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_22));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 0, ((PyObject *)__pyx_kp_s_22));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_22));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":344
 *         hTransform = (< LCMSTransformation > trafo).hTransform
 *         if not hTransform:
 *             raise ValueError("Transformation has no transformation handle")             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_25);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_24));
  PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_kp_s_24));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":364
 *     dib = img._dib
 *     if not dib:
 *         raise ValueError("Image has no data")             # <<<<<<<<<<<<<<
 * 
 *     hTransform = trafo.hTransform
 */
  __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_26);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":368
 *     hTransform = trafo.hTransform
 *     if not hTransform:
 *         raise ValueError("Transformation has no transformation handle")             # <<<<<<<<<<<<<<
 * 
 *     image_type = fi.FreeImage_GetImageType(dib)
 */
  __pyx_k_tuple_27 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_27);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_24));
  PyTuple_SET_ITEM(__pyx_k_tuple_27, 0, ((PyObject *)__pyx_kp_s_24));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":428
 *             self.hProfile = createHProfile(data, len(data), "in")
 *         elif filename is not None:
 *             with open(filename, "rb") as f:             # <<<<<<<<<<<<<<
 *                 data = f.read()
 *             self.hProfile = createHProfile(data, len(data), "in")
 */
  __pyx_k_tuple_29 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_29);
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_k_tuple_29, 0, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_k_tuple_29, 1, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_k_tuple_29, 2, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_29));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":433
 * 
 *         if self.hProfile == NULL:
 *             raise LCMSException("Failed to set in profile")             # <<<<<<<<<<<<<<
 *         self.info = {}
 *         self._parse()
 */
  __pyx_k_tuple_31 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_31);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
  PyTuple_SET_ITEM(__pyx_k_tuple_31, 0, ((PyObject *)__pyx_kp_s_30));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_31));

  /* "smc/freeimage/_freeimage.pyx":242
 *     global tls_key
 *     if tls_key != -1:
 *         raise RuntimeError("Already initializes")             # <<<<<<<<<<<<<<
 *     # Initialize Python's threading API first. Sorry, there is no way
 *     # around it.
 */
  __pyx_k_tuple_42 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_42);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_41));
  PyTuple_SET_ITEM(__pyx_k_tuple_42, 0, ((PyObject *)__pyx_kp_s_41));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_41));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42));

  /* "smc/freeimage/_freeimage.pyx":271
 *     if fimsg:
 *         fimsgl = fimsg.lower()
 *         for msg in ("allocate", "allocation", "memory", "no space"):             # <<<<<<<<<<<<<<
 *             if msg in fimsgl:
 *                 # it's some kind of memory error
 */
  __pyx_k_tuple_44 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_44)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_44);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__allocate));
  PyTuple_SET_ITEM(__pyx_k_tuple_44, 0, ((PyObject *)__pyx_n_s__allocate));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__allocate));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__allocation));
  PyTuple_SET_ITEM(__pyx_k_tuple_44, 1, ((PyObject *)__pyx_n_s__allocation));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__allocation));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__memory));
  PyTuple_SET_ITEM(__pyx_k_tuple_44, 2, ((PyObject *)__pyx_n_s__memory));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__memory));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
  PyTuple_SET_ITEM(__pyx_k_tuple_44, 3, ((PyObject *)__pyx_kp_s_43));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_44));

  /* "smc/freeimage/_freeimage.pyx":449
 * 
 *         if img._dib == NULL:
 *             raise IOError("Operation on closed image")             # <<<<<<<<<<<<<<
 *         if format == fi.FIF_UNKNOWN:
 *             self._format = img._format
 */
  __pyx_k_tuple_48 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_48)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_48);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_47));
  PyTuple_SET_ITEM(__pyx_k_tuple_48, 0, ((PyObject *)__pyx_kp_s_47));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_47));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_48));

  /* "smc/freeimage/_freeimage.pyx":459
 * 
 *         if self._format < 0 or self._format > fi.FreeImage_GetFIFCount():
 *             raise ValueError("Invalid image format")             # <<<<<<<<<<<<<<
 * 
 *         mem = fi.FreeImage_OpenMemory(NULL, 0)
 */
  __pyx_k_tuple_50 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_50)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_50);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_49));
  PyTuple_SET_ITEM(__pyx_k_tuple_50, 0, ((PyObject *)__pyx_kp_s_49));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_49));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_50));

  /* "smc/freeimage/_freeimage.pyx":491
 *         cdef fi.DWORD size
 *         if index != 0:
 *             raise SystemError("accessing non-existent string segment")             # <<<<<<<<<<<<<<
 *         fi.FreeImage_AcquireMemory(self._mem, <fi.BYTE**>ptr, &size)
 *         return size
 */
  __pyx_k_tuple_54 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_54)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_54);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_53));
  PyTuple_SET_ITEM(__pyx_k_tuple_54, 0, ((PyObject *)__pyx_kp_s_53));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_53));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_54));

  /* "smc/freeimage/_freeimage.pyx":532
 *         """
 *         if whence < stdio.SEEK_SET or whence > stdio.SEEK_END:
 *             raise ValueError("whence must be 0, 1 or 2")             # <<<<<<<<<<<<<<
 *         if not fi.FreeImage_SeekMemory(self._mem, offset, whence):
 *             raise dispatchFIError(OperationError, "Failure during seek")
 */
  __pyx_k_tuple_57 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_57);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_56));
  PyTuple_SET_ITEM(__pyx_k_tuple_57, 0, ((PyObject *)__pyx_kp_s_56));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_56));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57));

  /* "smc/freeimage/_freeimage.pyx":550
 *             rsize = self.size
 *         elif rsize < 0:
 *             raise ValueError("Invalid size")             # <<<<<<<<<<<<<<
 * 
 *         # read up the EOF max
 */
  __pyx_k_tuple_61 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_61);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_60));
  PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_kp_s_60));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_60));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61));

  /* "smc/freeimage/_freeimage.pyx":664
 *         if (bool(filename) + bool(_bitmap is not None) +
 *             bool(buffer is not None) + bool(fd != -2)) != 1:
 *             raise ValueError("Exactly one argument must be applied")             # <<<<<<<<<<<<<<
 *         if filename:
 *             self.from_filename(filename, flags)
 */
  __pyx_k_tuple_65 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_65)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_65);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_64));
  PyTuple_SET_ITEM(__pyx_k_tuple_65, 0, ((PyObject *)__pyx_kp_s_64));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_64));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_65));

  /* "smc/freeimage/_freeimage.pyx":671
 *         if _bitmap:
 *             if flags:
 *                 raise ValueError("Flags argument not used")             # <<<<<<<<<<<<<<
 *             self.from_bitmap(_bitmap)
 *         if fd != -2:
 */
  __pyx_k_tuple_67 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_67)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_67);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_66));
  PyTuple_SET_ITEM(__pyx_k_tuple_67, 0, ((PyObject *)__pyx_kp_s_66));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_66));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_67));

  /* "smc/freeimage/_freeimage.pyx":779
 *     cdef _check_closed(self):
 *         if self._dib == NULL:
 *             raise IOError("Operation on closed image")             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
  __pyx_k_tuple_72 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_72)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_72);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_47));
  PyTuple_SET_ITEM(__pyx_k_tuple_72, 0, ((PyObject *)__pyx_kp_s_47));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_47));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_72));

  /* "smc/freeimage/_freeimage.pyx":839
 *         def __set__(self, float dpi):
 *             if dpi < 0:
 *                 raise ValueError("DPI must be positive or zero.")             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             fi.FreeImage_SetDotsPerMeterX(self._dib, int(round(dpi * METER_INCH)))
 */
  __pyx_k_tuple_74 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_74)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_74);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_73));
  PyTuple_SET_ITEM(__pyx_k_tuple_74, 0, ((PyObject *)__pyx_kp_s_73));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_73));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_74));

  /* "smc/freeimage/_freeimage.pyx":854
 *         def __set__(self, float dpi):
 *             if dpi < 0:
 *                 raise ValueError("DPI must be positive or zero.")             # <<<<<<<<<<<<<<
 *             self._check_closed()
 *             fi.FreeImage_SetDotsPerMeterY(self._dib, int(round(dpi * METER_INCH)))
 */
  __pyx_k_tuple_75 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_75)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_75);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_73));
  PyTuple_SET_ITEM(__pyx_k_tuple_75, 0, ((PyObject *)__pyx_kp_s_73));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_73));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_75));

  /* "smc/freeimage/_freeimage.pyx":1018
 *         result = floodfill(self._dib, red, green, blue, 0)
 *         if result == ERR_ARG:
 *             raise ValueError("Wrong arguments, colors must be between 0% and 100%")             # <<<<<<<<<<<<<<
 *         if result == ERR_UNSUP:
 *             raise NotImplementedError("floodfill for type: %i, bpp:  %i" %
 */
  __pyx_k_tuple_77 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_77)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_77);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_76));
  PyTuple_SET_ITEM(__pyx_k_tuple_77, 0, ((PyObject *)__pyx_kp_s_76));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_76));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_77));

  /* "smc/freeimage/_freeimage.pyx":1053
 *         """
 *         if smc_fi.IS_PYTHON3:
 *             raise NotImplementedError("tuBuffer() not implemented for 3.x yet")             # <<<<<<<<<<<<<<
 *         return _MemoryIO(self, format, flags)
 * 
 */
  __pyx_k_tuple_82 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_82)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_82);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_81));
  PyTuple_SET_ITEM(__pyx_k_tuple_82, 0, ((PyObject *)__pyx_kp_s_81));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_81));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_82));

  /* "smc/freeimage/_freeimage.pyx":1092
 *         self._check_closed()
 *         if src._dib == NULL:
 *             raise IOError("Operation on closed source image")             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = fi.FreeImage_Paste(self._dib, src._dib, left, top, alpha)
 */
  __pyx_k_tuple_87 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_87)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_87);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_86));
  PyTuple_SET_ITEM(__pyx_k_tuple_87, 0, ((PyObject *)__pyx_kp_s_86));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_86));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_87));

  /* "smc/freeimage/_freeimage.pyx":1125
 *             bottom = self.height
 *         if left < 0 or top < 0 or right < 0 or bottom < 0:
 *             raise ValueError("Boundaries must be larger than 0")             # <<<<<<<<<<<<<<
 *         # XXX more checks
 *         with nogil:
 */
  __pyx_k_tuple_91 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_91)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_91);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_90));
  PyTuple_SET_ITEM(__pyx_k_tuple_91, 0, ((PyObject *)__pyx_kp_s_90));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_90));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_91));

  /* "smc/freeimage/_freeimage.pyx":1242
 *         self._check_closed()
 *         if threshold > 255:
 *             raise ValueError("Threshold must be between 0 and 255")             # <<<<<<<<<<<<<<
 *         with nogil:
 *             dib = fi.FreeImage_Threshold(self._dib, <fi.BYTE>threshold)
 */
  __pyx_k_tuple_96 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_96)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_96);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_95));
  PyTuple_SET_ITEM(__pyx_k_tuple_96, 0, ((PyObject *)__pyx_kp_s_95));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_95));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_96));

  /* "smc/freeimage/_freeimage.pyx":1283
 *             angle = 270
 *         if angle not in (90, 180, 270):
 *             raise ValueError("Only -90, 90, 180, 270 are supported")             # <<<<<<<<<<<<<<
 *         # FreeImage uses CCW angle, but we prefer CW angle
 *         if angle == 90:
 */
  __pyx_k_tuple_99 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_99)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_99);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_98));
  PyTuple_SET_ITEM(__pyx_k_tuple_99, 0, ((PyObject *)__pyx_kp_s_98));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_98));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_99));

  /* "smc/freeimage/_freeimage.pyx":1401
 *         self._check_closed()
 *         if src._dib == NULL:
 *             raise IOError("Operation on closed source image")             # <<<<<<<<<<<<<<
 *         if not fi.FreeImage_CloneMetadata(self._dib, src._dib):
 *             raise dispatchFIError(OperationError, "Failed to copy metadata")
 */
  __pyx_k_tuple_101 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_101)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_101);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_86));
  PyTuple_SET_ITEM(__pyx_k_tuple_101, 0, ((PyObject *)__pyx_kp_s_86));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_86));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_101));

  /* "smc/freeimage/_freeimage.pyx":1433
 *         _invert = cpython.PyObject_IsTrue(invert)
 *         if brightness < -100.0 or brightness > +100.0:
 *             raise ValueError("Brightness must be between -100. and +100. "             # <<<<<<<<<<<<<<
 *                              "(percentage)")
 *         if contrast < -100.0 or contrast > +100.0:
 */
  __pyx_k_tuple_105 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_105)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_105);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_104));
  PyTuple_SET_ITEM(__pyx_k_tuple_105, 0, ((PyObject *)__pyx_kp_s_104));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_104));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_105));

  /* "smc/freeimage/_freeimage.pyx":1436
 *                              "(percentage)")
 *         if contrast < -100.0 or contrast > +100.0:
 *             raise ValueError("Contrast must be between -100 and +100 "             # <<<<<<<<<<<<<<
 *                              "(percentage)")
 *         if gamma <= 0.0:
 */
  __pyx_k_tuple_107 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_107)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_107);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_106));
  PyTuple_SET_ITEM(__pyx_k_tuple_107, 0, ((PyObject *)__pyx_kp_s_106));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_106));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_107));

  /* "smc/freeimage/_freeimage.pyx":1439
 *                              "(percentage)")
 *         if gamma <= 0.0:
 *             raise ValueError("Gamma must be greater than 0.")             # <<<<<<<<<<<<<<
 * 
 *         if not fi.FreeImage_AdjustColors(self._dib, brightness, contrast,
 */
  __pyx_k_tuple_109 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_109)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_109);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_108));
  PyTuple_SET_ITEM(__pyx_k_tuple_109, 0, ((PyObject *)__pyx_kp_s_108));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_108));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_109));

  /* "smc/freeimage/_freeimage.pyx":1514
 * 
 *         if y > height:
 *             raise ValueError("y must be smaller than height of image")             # <<<<<<<<<<<<<<
 *         if xend == -1:
 *             xend = width
 */
  __pyx_k_tuple_117 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_117)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_117);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_116));
  PyTuple_SET_ITEM(__pyx_k_tuple_117, 0, ((PyObject *)__pyx_kp_s_116));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_116));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_117));

  /* "smc/freeimage/_freeimage.pyx":1518
 *             xend = width
 *         if xstart >= xend:
 *             raise ValueError("x start must be smaller than x end")             # <<<<<<<<<<<<<<
 *         if linewidth < 0 or linewidth >= height:
 *             raise ValueError("Invalid line height")
 */
  __pyx_k_tuple_119 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_119)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_119);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_118));
  PyTuple_SET_ITEM(__pyx_k_tuple_119, 0, ((PyObject *)__pyx_kp_s_118));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_118));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_119));

  /* "smc/freeimage/_freeimage.pyx":1520
 *             raise ValueError("x start must be smaller than x end")
 *         if linewidth < 0 or linewidth >= height:
 *             raise ValueError("Invalid line height")             # <<<<<<<<<<<<<<
 * 
 *         ys = y
 */
  __pyx_k_tuple_121 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_121)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_121);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_120));
  PyTuple_SET_ITEM(__pyx_k_tuple_121, 0, ((PyObject *)__pyx_kp_s_120));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_120));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_121));

  /* "smc/freeimage/_freeimage.pyx":1621
 * 
 *         if x > width:
 *             raise ValueError("x must be smaller than width of image")             # <<<<<<<<<<<<<<
 *         if yend == -1:
 *             yend = height
 */
  __pyx_k_tuple_124 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_124)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_124);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_123));
  PyTuple_SET_ITEM(__pyx_k_tuple_124, 0, ((PyObject *)__pyx_kp_s_123));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_123));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_124));

  /* "smc/freeimage/_freeimage.pyx":1625
 *             yend = height
 *         if ystart >= yend:
 *             raise ValueError("y start must be smaller than y end")             # <<<<<<<<<<<<<<
 *         if linewidth < 0 or linewidth >= width:
 *             raise ValueError("Invalid line width")
 */
  __pyx_k_tuple_126 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_126)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_126);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_125));
  PyTuple_SET_ITEM(__pyx_k_tuple_126, 0, ((PyObject *)__pyx_kp_s_125));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_125));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_126));

  /* "smc/freeimage/_freeimage.pyx":1627
 *             raise ValueError("y start must be smaller than y end")
 *         if linewidth < 0 or linewidth >= width:
 *             raise ValueError("Invalid line width")             # <<<<<<<<<<<<<<
 * 
 *         xs = x
 */
  __pyx_k_tuple_128 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_128)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_128);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_127));
  PyTuple_SET_ITEM(__pyx_k_tuple_128, 0, ((PyObject *)__pyx_kp_s_127));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_127));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_128));

  /* "smc/freeimage/_freeimage.pyx":1806
 *     def getExtensions(self):
 *         exts = fi.FreeImage_GetFIFExtensionList(self._format)
 *         return [funicode(ext) for ext in exts.split(b',')]             # <<<<<<<<<<<<<<
 * 
 *     def getSupportsExportType(self, int type):
 */
  __pyx_k_tuple_132 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_132)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_132);
  __Pyx_INCREF(((PyObject *)__pyx_kp_b_131));
  PyTuple_SET_ITEM(__pyx_k_tuple_132, 0, ((PyObject *)__pyx_kp_b_131));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_b_131));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_132));

  /* "smc/freeimage/_freeimage.pyx":1882
 * 
 *     if op > fi.FIJPEG_OP_ROTATE_270:
 *         raise ValueError("OP not in range 0-7")             # <<<<<<<<<<<<<<
 * 
 *     csrc = bsrc
 */
  __pyx_k_tuple_137 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_137)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_137);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_136));
  PyTuple_SET_ITEM(__pyx_k_tuple_137, 0, ((PyObject *)__pyx_kp_s_136));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_136));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_137));

  /* "smc/freeimage/_freeimage.pyx":41
 * #--- constants
 * __all__ = (
 *     "Image", "LCMSTransformation", "LCMSException",             # <<<<<<<<<<<<<<
 *     "FreeImageError", "UnknownImageError", "LoadError", "SaveError", "OperationError",
 *     "getVersion", "getCompiledFor", "getCopyright", "FormatInfo",
 */
  __pyx_k_tuple_162 = PyTuple_New(23); if (unlikely(!__pyx_k_tuple_162)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_162);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Image));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 0, ((PyObject *)__pyx_n_s__Image));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Image));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__LCMSTransformation));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 1, ((PyObject *)__pyx_n_s__LCMSTransformation));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LCMSTransformation));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__LCMSException));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 2, ((PyObject *)__pyx_n_s__LCMSException));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LCMSException));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__FreeImageError));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 3, ((PyObject *)__pyx_n_s__FreeImageError));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__FreeImageError));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__UnknownImageError));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 4, ((PyObject *)__pyx_n_s__UnknownImageError));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__UnknownImageError));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__LoadError));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 5, ((PyObject *)__pyx_n_s__LoadError));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LoadError));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__SaveError));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 6, ((PyObject *)__pyx_n_s__SaveError));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SaveError));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__OperationError));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 7, ((PyObject *)__pyx_n_s__OperationError));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__OperationError));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__getVersion));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 8, ((PyObject *)__pyx_n_s__getVersion));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__getVersion));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__getCompiledFor));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 9, ((PyObject *)__pyx_n_s__getCompiledFor));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__getCompiledFor));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__getCopyright));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 10, ((PyObject *)__pyx_n_s__getCopyright));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__getCopyright));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__FormatInfo));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 11, ((PyObject *)__pyx_n_s__FormatInfo));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__FormatInfo));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__getFormatCount));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 12, ((PyObject *)__pyx_n_s__getFormatCount));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__getFormatCount));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__jpegTransform));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 13, ((PyObject *)__pyx_n_s__jpegTransform));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__jpegTransform));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__lookupX11Color));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 14, ((PyObject *)__pyx_n_s__lookupX11Color));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__lookupX11Color));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__lookupSVGColor));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 15, ((PyObject *)__pyx_n_s__lookupSVGColor));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__lookupSVGColor));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__LCMSIccCache));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 16, ((PyObject *)__pyx_n_s__LCMSIccCache));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LCMSIccCache));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__LCMSProfileInfo));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 17, ((PyObject *)__pyx_n_s__LCMSProfileInfo));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LCMSProfileInfo));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__XYZ2xyY));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 18, ((PyObject *)__pyx_n_s__XYZ2xyY));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__XYZ2xyY));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__xyY2XYZ));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 19, ((PyObject *)__pyx_n_s__xyY2XYZ));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__xyY2XYZ));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__getIntents));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 20, ((PyObject *)__pyx_n_s__getIntents));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__getIntents));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__getLCMSVersion));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 21, ((PyObject *)__pyx_n_s__getLCMSVersion));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__getLCMSVersion));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__hasJPEGTurbo));
  PyTuple_SET_ITEM(__pyx_k_tuple_162, 22, ((PyObject *)__pyx_n_s__hasJPEGTurbo));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__hasJPEGTurbo));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_162));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":51
 * lcms.cmsSetLogErrorHandler(< lcms.cmsLogErrorHandlerFunction > errorHandler)
 * 
 * def getLCMSVersion():             # <<<<<<<<<<<<<<
 *     return lcms.LCMS_VERSION
 * 
 */
  __pyx_k_codeobj_164 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_165, __pyx_n_s__getLCMSVersion, 51, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_164)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":54
 *     return lcms.LCMS_VERSION
 * 
 * def XYZ2xyY(float X, float Y, float Z):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsCIEXYZ XYZ
 *     cdef lcms.cmsCIExyY xyY
 */
  __pyx_k_tuple_167 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_167)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_167);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__X));
  PyTuple_SET_ITEM(__pyx_k_tuple_167, 0, ((PyObject *)__pyx_n_s__X));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__X));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Y));
  PyTuple_SET_ITEM(__pyx_k_tuple_167, 1, ((PyObject *)__pyx_n_s__Y));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Y));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Z));
  PyTuple_SET_ITEM(__pyx_k_tuple_167, 2, ((PyObject *)__pyx_n_s__Z));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Z));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__XYZ));
  PyTuple_SET_ITEM(__pyx_k_tuple_167, 3, ((PyObject *)__pyx_n_s__XYZ));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__XYZ));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__xyY));
  PyTuple_SET_ITEM(__pyx_k_tuple_167, 4, ((PyObject *)__pyx_n_s__xyY));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__xyY));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_167));
  __pyx_k_codeobj_168 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_167, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_165, __pyx_n_s__XYZ2xyY, 54, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_168)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":63
 *     return xyY.x, xyY.y, xyY.Y
 * 
 * def xyY2XYZ(float x, float y, float Y):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsCIEXYZ XYZ
 *     cdef lcms.cmsCIExyY xyY
 */
  __pyx_k_tuple_169 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_169)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_169);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x));
  PyTuple_SET_ITEM(__pyx_k_tuple_169, 0, ((PyObject *)__pyx_n_s__x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__y));
  PyTuple_SET_ITEM(__pyx_k_tuple_169, 1, ((PyObject *)__pyx_n_s__y));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Y));
  PyTuple_SET_ITEM(__pyx_k_tuple_169, 2, ((PyObject *)__pyx_n_s__Y));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Y));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__XYZ));
  PyTuple_SET_ITEM(__pyx_k_tuple_169, 3, ((PyObject *)__pyx_n_s__XYZ));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__XYZ));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__xyY));
  PyTuple_SET_ITEM(__pyx_k_tuple_169, 4, ((PyObject *)__pyx_n_s__xyY));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__xyY));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_169));
  __pyx_k_codeobj_170 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_169, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_165, __pyx_n_s__xyY2XYZ, 63, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_170)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":72
 *     return XYZ.X, XYZ.Y, XYZ.Z
 * 
 * def tempFromWhitePoint(float x, float y, float Y):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsFloat64Number tempK
 *     cdef lcms.cmsCIExyY xyY
 */
  __pyx_k_tuple_171 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_171)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_171);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x));
  PyTuple_SET_ITEM(__pyx_k_tuple_171, 0, ((PyObject *)__pyx_n_s__x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__y));
  PyTuple_SET_ITEM(__pyx_k_tuple_171, 1, ((PyObject *)__pyx_n_s__y));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__y));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Y));
  PyTuple_SET_ITEM(__pyx_k_tuple_171, 2, ((PyObject *)__pyx_n_s__Y));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Y));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__tempK));
  PyTuple_SET_ITEM(__pyx_k_tuple_171, 3, ((PyObject *)__pyx_n_s__tempK));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tempK));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__xyY));
  PyTuple_SET_ITEM(__pyx_k_tuple_171, 4, ((PyObject *)__pyx_n_s__xyY));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__xyY));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_171));
  __pyx_k_codeobj_172 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_171, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_165, __pyx_n_s__tempFromWhitePoint, 72, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_172)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":82
 *     return tempK
 * 
 * def getIntents():             # <<<<<<<<<<<<<<
 *     cdef int n, i, intents = 200
 *     cdef int intent_ids[200]
 */
  __pyx_k_tuple_173 = PyTuple_New(6); if (unlikely(!__pyx_k_tuple_173)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_173);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n));
  PyTuple_SET_ITEM(__pyx_k_tuple_173, 0, ((PyObject *)__pyx_n_s__n));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_k_tuple_173, 1, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__intents));
  PyTuple_SET_ITEM(__pyx_k_tuple_173, 2, ((PyObject *)__pyx_n_s__intents));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__intents));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__intent_ids));
  PyTuple_SET_ITEM(__pyx_k_tuple_173, 3, ((PyObject *)__pyx_n_s__intent_ids));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__intent_ids));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__intent_descs));
  PyTuple_SET_ITEM(__pyx_k_tuple_173, 4, ((PyObject *)__pyx_n_s__intent_descs));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__intent_descs));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__result));
  PyTuple_SET_ITEM(__pyx_k_tuple_173, 5, ((PyObject *)__pyx_n_s__result));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__result));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_173));
  __pyx_k_codeobj_174 = (PyObject*)__Pyx_PyCode_New(0, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_173, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_165, __pyx_n_s__getIntents, 82, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_174)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":252
 * #--- exceptions
 * 
 * def dispatchFIError(cls, *args):             # <<<<<<<<<<<<<<
 *     cdef char* err
 * 
 */
  __pyx_k_tuple_175 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_175)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_175);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__cls));
  PyTuple_SET_ITEM(__pyx_k_tuple_175, 0, ((PyObject *)__pyx_n_s__cls));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__cls));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_175, 1, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_175, 2, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__err));
  PyTuple_SET_ITEM(__pyx_k_tuple_175, 3, ((PyObject *)__pyx_n_s__err));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__err));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fimsg));
  PyTuple_SET_ITEM(__pyx_k_tuple_175, 4, ((PyObject *)__pyx_n_s__fimsg));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fimsg));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fimsgl));
  PyTuple_SET_ITEM(__pyx_k_tuple_175, 5, ((PyObject *)__pyx_n_s__fimsgl));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fimsgl));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__msg));
  PyTuple_SET_ITEM(__pyx_k_tuple_175, 6, ((PyObject *)__pyx_n_s__msg));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__msg));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_175));
  __pyx_k_codeobj_176 = (PyObject*)__Pyx_PyCode_New(1, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_175, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s__dispatchFIError, 252, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_176)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":280
 * 
 * class FreeImageError(Exception):
 *     def __init__(self, *args, fimsg=None):             # <<<<<<<<<<<<<<
 *         if fimsg is not None:
 *             args = args + (fimsg,)
 */
  __pyx_k_tuple_178 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_178)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_178);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__self));
  PyTuple_SET_ITEM(__pyx_k_tuple_178, 0, ((PyObject *)__pyx_n_s__self));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__self));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fimsg));
  PyTuple_SET_ITEM(__pyx_k_tuple_178, 1, ((PyObject *)__pyx_n_s__fimsg));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fimsg));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_178, 2, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__args));
  PyTuple_SET_ITEM(__pyx_k_tuple_178, 3, ((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__args));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_178));
  __pyx_k_codeobj_179 = (PyObject*)__Pyx_PyCode_New(2, 1, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_178, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s____init__, 280, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_179)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_tuple_180 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_180)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_180);
  __Pyx_INCREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_k_tuple_180, 0, ((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_180));

  /* "smc/freeimage/_freeimage.pyx":634
 *         return 0
 * 
 * def _new_image(unsigned width, unsigned height, unsigned bpp,             # <<<<<<<<<<<<<<
 *               unsigned red_mask = 0, unsigned green_mask = 0, unsigned blue_mask = 0):
 *         cdef fi.FIBITMAP* dib
 */
  __pyx_k_tuple_181 = PyTuple_New(8); if (unlikely(!__pyx_k_tuple_181)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_181);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__width));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 0, ((PyObject *)__pyx_n_s__width));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__width));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__height));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 1, ((PyObject *)__pyx_n_s__height));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__height));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__bpp));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 2, ((PyObject *)__pyx_n_s__bpp));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bpp));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__red_mask));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 3, ((PyObject *)__pyx_n_s__red_mask));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__red_mask));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__green_mask));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 4, ((PyObject *)__pyx_n_s__green_mask));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__green_mask));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__blue_mask));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 5, ((PyObject *)__pyx_n_s__blue_mask));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__blue_mask));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dib));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 6, ((PyObject *)__pyx_n_s__dib));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dib));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__img));
  PyTuple_SET_ITEM(__pyx_k_tuple_181, 7, ((PyObject *)__pyx_n_s__img));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__img));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_181));
  __pyx_k_codeobj_182 = (PyObject*)__Pyx_PyCode_New(6, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_181, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s___new_image, 634, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_182)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1724
 * # Format Info
 * 
 * def FormatInfo_from_filename(cls, filename):             # <<<<<<<<<<<<<<
 *     """from_filename(filename) -> FormatInfo instance
 * 
 */
  __pyx_k_tuple_183 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_183)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_183);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__cls));
  PyTuple_SET_ITEM(__pyx_k_tuple_183, 0, ((PyObject *)__pyx_n_s__cls));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__cls));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__filename));
  PyTuple_SET_ITEM(__pyx_k_tuple_183, 1, ((PyObject *)__pyx_n_s__filename));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__filename));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__format));
  PyTuple_SET_ITEM(__pyx_k_tuple_183, 2, ((PyObject *)__pyx_n_s__format));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__format));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_183));
  __pyx_k_codeobj_184 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_183, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s_185, 1724, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_184)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1733
 *     return cls(format)
 * 
 * def FormatInfo_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *     """from_file(path) -> FormatInfo instance
 * 
 */
  __pyx_k_tuple_186 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_186)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_186);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__cls));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 0, ((PyObject *)__pyx_n_s__cls));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__cls));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__filename));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 1, ((PyObject *)__pyx_n_s__filename));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__filename));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__format));
  PyTuple_SET_ITEM(__pyx_k_tuple_186, 2, ((PyObject *)__pyx_n_s__format));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__format));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_186));
  __pyx_k_codeobj_187 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_186, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s_188, 1733, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_187)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1742
 *     return cls(format)
 * 
 * def FormatInfo_from_mimetype(cls, mime):             # <<<<<<<<<<<<<<
 *     """from_mimetype(mime) -> FormatInfo instance
 * 
 */
  __pyx_k_tuple_189 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_189)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_189);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__cls));
  PyTuple_SET_ITEM(__pyx_k_tuple_189, 0, ((PyObject *)__pyx_n_s__cls));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__cls));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__mime));
  PyTuple_SET_ITEM(__pyx_k_tuple_189, 1, ((PyObject *)__pyx_n_s__mime));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mime));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__format));
  PyTuple_SET_ITEM(__pyx_k_tuple_189, 2, ((PyObject *)__pyx_n_s__format));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__format));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_189));
  __pyx_k_codeobj_190 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_189, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s_191, 1742, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_190)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1819
 * 
 * #--- module functions
 * def getVersion():             # <<<<<<<<<<<<<<
 *     """getVersion() -> str
 * 
 */
  __pyx_k_codeobj_192 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s__getVersion, 1819, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_192)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1826
 *     return funicode(fi.FreeImage_GetVersion())
 * 
 * def getCompiledFor():             # <<<<<<<<<<<<<<
 *     """getCompiledFor() -> tuple(major, minor, serial)
 *     """
 */
  __pyx_k_codeobj_193 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s__getCompiledFor, 1826, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_193)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1833
 *             fi.FREEIMAGE_RELEASE_SERIAL)
 * 
 * def getCopyright():             # <<<<<<<<<<<<<<
 *     """getCopyright() -> str
 *     """
 */
  __pyx_k_codeobj_194 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s__getCopyright, 1833, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_194)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1838
 *     return funicode(fi.FreeImage_GetCopyrightMessage())
 * 
 * def getFormatCount():             # <<<<<<<<<<<<<<
 *     """getFormatCount() -> int
 *     """
 */
  __pyx_k_codeobj_195 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s__getFormatCount, 1838, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_195)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1843
 *     return fi.FreeImage_GetFIFCount()
 * 
 * def lookupX11Color(name):             # <<<<<<<<<<<<<<
 *     """lookupX11Color(name) -> (r, g, b)
 *     """
 */
  __pyx_k_tuple_196 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_196)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_196);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_196, 0, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__red));
  PyTuple_SET_ITEM(__pyx_k_tuple_196, 1, ((PyObject *)__pyx_n_s__red));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__red));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__green));
  PyTuple_SET_ITEM(__pyx_k_tuple_196, 2, ((PyObject *)__pyx_n_s__green));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__green));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__blue));
  PyTuple_SET_ITEM(__pyx_k_tuple_196, 3, ((PyObject *)__pyx_n_s__blue));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__blue));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_196));
  __pyx_k_codeobj_197 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_196, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s__lookupX11Color, 1843, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_197)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1852
 *     return (red, green, blue)
 * 
 * def lookupSVGColor(name):             # <<<<<<<<<<<<<<
 *     """lookupSVGColor(name) -> (r, g, b)
 *     """
 */
  __pyx_k_tuple_198 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_198)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_198);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_198, 0, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__red));
  PyTuple_SET_ITEM(__pyx_k_tuple_198, 1, ((PyObject *)__pyx_n_s__red));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__red));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__green));
  PyTuple_SET_ITEM(__pyx_k_tuple_198, 2, ((PyObject *)__pyx_n_s__green));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__green));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__blue));
  PyTuple_SET_ITEM(__pyx_k_tuple_198, 3, ((PyObject *)__pyx_n_s__blue));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__blue));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_198));
  __pyx_k_codeobj_199 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_198, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s__lookupSVGColor, 1852, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_199)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1861
 *     return (red, green, blue)
 * 
 * def jpegTransform(src, dst, unsigned int op, unsigned int perfect=0):             # <<<<<<<<<<<<<<
 *     """jpegTransform(source: str, destination: str, op: int) -> None
 * 
 */
  __pyx_k_tuple_200 = PyTuple_New(9); if (unlikely(!__pyx_k_tuple_200)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_200);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__src));
  PyTuple_SET_ITEM(__pyx_k_tuple_200, 0, ((PyObject *)__pyx_n_s__src));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__src));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__dst));
  PyTuple_SET_ITEM(__pyx_k_tuple_200, 1, ((PyObject *)__pyx_n_s__dst));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__dst));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__op));
  PyTuple_SET_ITEM(__pyx_k_tuple_200, 2, ((PyObject *)__pyx_n_s__op));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__op));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__perfect));
  PyTuple_SET_ITEM(__pyx_k_tuple_200, 3, ((PyObject *)__pyx_n_s__perfect));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__perfect));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__result));
  PyTuple_SET_ITEM(__pyx_k_tuple_200, 4, ((PyObject *)__pyx_n_s__result));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__result));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__csrc));
  PyTuple_SET_ITEM(__pyx_k_tuple_200, 5, ((PyObject *)__pyx_n_s__csrc));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__csrc));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__cdst));
  PyTuple_SET_ITEM(__pyx_k_tuple_200, 6, ((PyObject *)__pyx_n_s__cdst));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__cdst));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__bsrc));
  PyTuple_SET_ITEM(__pyx_k_tuple_200, 7, ((PyObject *)__pyx_n_s__bsrc));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bsrc));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__bdst));
  PyTuple_SET_ITEM(__pyx_k_tuple_200, 8, ((PyObject *)__pyx_n_s__bdst));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bdst));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_200));
  __pyx_k_codeobj_201 = (PyObject*)__Pyx_PyCode_New(4, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_200, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s__jpegTransform, 1861, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_201)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "smc/freeimage/_freeimage.pyx":1896
 *                              "'%i' failed." % (src, dst, op))
 * 
 * def hasJPEGTurbo():             # <<<<<<<<<<<<<<
 *     """Is FreeImage compiled against libjeg-turbo
 *     """
 */
  __pyx_k_codeobj_202 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_177, __pyx_n_s__hasJPEGTurbo, 1896, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_202)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_freeimage(void); /*proto*/
PyMODINIT_FUNC init_freeimage(void)
#else
PyMODINIT_FUNC PyInit__freeimage(void); /*proto*/
PyMODINIT_FUNC PyInit__freeimage(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__freeimage(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_freeimage"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_smc__freeimage___freeimage) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  __pyx_v_3smc_9freeimage_10_freeimage__logger = Py_None; Py_INCREF(Py_None);
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_3smc_9freeimage_10_freeimage_Image = &__pyx_vtable_3smc_9freeimage_10_freeimage_Image;
  __pyx_vtable_3smc_9freeimage_10_freeimage_Image.from_filename = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, PyObject *, int))__pyx_f_3smc_9freeimage_10_freeimage_5Image_from_filename;
  __pyx_vtable_3smc_9freeimage_10_freeimage_Image.from_bitmap = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, struct __pyx_obj_3smc_9freeimage_10_freeimage__DibWrapper *))__pyx_f_3smc_9freeimage_10_freeimage_5Image_from_bitmap;
  __pyx_vtable_3smc_9freeimage_10_freeimage_Image.from_buffer = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, PyObject *, int))__pyx_f_3smc_9freeimage_10_freeimage_5Image_from_buffer;
  __pyx_vtable_3smc_9freeimage_10_freeimage_Image._init_infos = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *))__pyx_f_3smc_9freeimage_10_freeimage_5Image__init_infos;
  __pyx_vtable_3smc_9freeimage_10_freeimage_Image._check_closed = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *))__pyx_f_3smc_9freeimage_10_freeimage_5Image__check_closed;
  __pyx_vtable_3smc_9freeimage_10_freeimage_Image.convert_helper = (struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, FI_ConvertFunction))__pyx_f_3smc_9freeimage_10_freeimage_5Image_convert_helper;
  __pyx_vtable_3smc_9freeimage_10_freeimage_Image.hline_rgb24 = (int (*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, RGBQUAD *, unsigned int, unsigned int, unsigned int, unsigned int))__pyx_f_3smc_9freeimage_10_freeimage_5Image_hline_rgb24;
  __pyx_vtable_3smc_9freeimage_10_freeimage_Image.hline_mono = (int (*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, BYTE, unsigned int, unsigned int, unsigned int, unsigned int))__pyx_f_3smc_9freeimage_10_freeimage_5Image_hline_mono;
  __pyx_vtable_3smc_9freeimage_10_freeimage_Image.vline_rgb24 = (int (*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, RGBQUAD *, unsigned int, unsigned int, unsigned int, unsigned int))__pyx_f_3smc_9freeimage_10_freeimage_5Image_vline_rgb24;
  __pyx_vtable_3smc_9freeimage_10_freeimage_Image.vline_mono = (int (*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_Image *, BYTE, unsigned int, unsigned int, unsigned int, unsigned int))__pyx_f_3smc_9freeimage_10_freeimage_5Image_vline_mono;
  if (PyType_Ready(&__pyx_type_3smc_9freeimage_10_freeimage_Image) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_3smc_9freeimage_10_freeimage_Image.tp_dict, __pyx_vtabptr_3smc_9freeimage_10_freeimage_Image) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Image", (PyObject *)&__pyx_type_3smc_9freeimage_10_freeimage_Image) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3smc_9freeimage_10_freeimage_Image = &__pyx_type_3smc_9freeimage_10_freeimage_Image;
  if (PyType_Ready(&__pyx_type_3smc_9freeimage_10_freeimage_FormatInfo) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "FormatInfo", (PyObject *)&__pyx_type_3smc_9freeimage_10_freeimage_FormatInfo) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3smc_9freeimage_10_freeimage_FormatInfo = &__pyx_type_3smc_9freeimage_10_freeimage_FormatInfo;
  __pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSTransformation = &__pyx_vtable_3smc_9freeimage_10_freeimage_LCMSTransformation;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSTransformation.setInProfile = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *, char *, unsigned int))__pyx_f_3smc_9freeimage_10_freeimage_18LCMSTransformation_setInProfile;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSTransformation.setOutProfile = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *, char *, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setOutProfile *__pyx_optional_args))__pyx_f_3smc_9freeimage_10_freeimage_18LCMSTransformation_setOutProfile;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSTransformation._createProfile = (cmsHPROFILE (*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *, char *, unsigned int, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation__createProfile *__pyx_optional_args))__pyx_f_3smc_9freeimage_10_freeimage_18LCMSTransformation__createProfile;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSTransformation.setTransform = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSTransformation *, int, int, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_18LCMSTransformation_setTransform *__pyx_optional_args))__pyx_f_3smc_9freeimage_10_freeimage_18LCMSTransformation_setTransform;
  if (PyType_Ready(&__pyx_type_3smc_9freeimage_10_freeimage_LCMSTransformation) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_3smc_9freeimage_10_freeimage_LCMSTransformation.tp_dict, __pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSTransformation) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "LCMSTransformation", (PyObject *)&__pyx_type_3smc_9freeimage_10_freeimage_LCMSTransformation) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3smc_9freeimage_10_freeimage_LCMSTransformation = &__pyx_type_3smc_9freeimage_10_freeimage_LCMSTransformation;
  __pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSIccCache = &__pyx_vtable_3smc_9freeimage_10_freeimage_LCMSIccCache;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSIccCache.addEntry = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSIccCache *, PyObject *, PyObject *, int, int, unsigned long))__pyx_f_3smc_9freeimage_10_freeimage_12LCMSIccCache_addEntry;
  if (PyType_Ready(&__pyx_type_3smc_9freeimage_10_freeimage_LCMSIccCache) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_3smc_9freeimage_10_freeimage_LCMSIccCache.tp_dict, __pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSIccCache) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "LCMSIccCache", (PyObject *)&__pyx_type_3smc_9freeimage_10_freeimage_LCMSIccCache) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3smc_9freeimage_10_freeimage_LCMSIccCache = &__pyx_type_3smc_9freeimage_10_freeimage_LCMSIccCache;
  __pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSProfileInfo = &__pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo._readMLU = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *, cmsTagSignature, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readMLU *__pyx_optional_args))__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readMLU;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo._readCIEXYZ = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *, cmsTagSignature, struct __pyx_opt_args_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIEXYZ *__pyx_optional_args))__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIEXYZ;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo._calculateRGBPrimaries = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *))__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__calculateRGBPrimaries;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo._readCIEXYZWhitePointTemp = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *))__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIEXYZWhitePointTemp;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo._readCIExyYTriple = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *, cmsTagSignature))__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readCIExyYTriple;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo._readSignature = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *, cmsTagSignature))__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readSignature;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo._readICCMeasurementCond = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *))__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readICCMeasurementCond;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo._readICCViewingCond = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *))__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__readICCViewingCond;
  __pyx_vtable_3smc_9freeimage_10_freeimage_LCMSProfileInfo._parse = (PyObject *(*)(struct __pyx_obj_3smc_9freeimage_10_freeimage_LCMSProfileInfo *))__pyx_f_3smc_9freeimage_10_freeimage_15LCMSProfileInfo__parse;
  if (PyType_Ready(&__pyx_type_3smc_9freeimage_10_freeimage_LCMSProfileInfo) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_3smc_9freeimage_10_freeimage_LCMSProfileInfo.tp_dict, __pyx_vtabptr_3smc_9freeimage_10_freeimage_LCMSProfileInfo) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "LCMSProfileInfo", (PyObject *)&__pyx_type_3smc_9freeimage_10_freeimage_LCMSProfileInfo) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3smc_9freeimage_10_freeimage_LCMSProfileInfo = &__pyx_type_3smc_9freeimage_10_freeimage_LCMSProfileInfo;
  if (PyType_Ready(&__pyx_type_3smc_9freeimage_10_freeimage__DibWrapper) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_DibWrapper", (PyObject *)&__pyx_type_3smc_9freeimage_10_freeimage__DibWrapper) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3smc_9freeimage_10_freeimage__DibWrapper = &__pyx_type_3smc_9freeimage_10_freeimage__DibWrapper;
  if (PyType_Ready(&__pyx_type_3smc_9freeimage_10_freeimage__BitmapInfo) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_BitmapInfo", (PyObject *)&__pyx_type_3smc_9freeimage_10_freeimage__BitmapInfo) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3smc_9freeimage_10_freeimage__BitmapInfo = &__pyx_type_3smc_9freeimage_10_freeimage__BitmapInfo;
  if (PyType_Ready(&__pyx_type_3smc_9freeimage_10_freeimage__MemoryIO) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "_MemoryIO", (PyObject *)&__pyx_type_3smc_9freeimage_10_freeimage__MemoryIO) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3smc_9freeimage_10_freeimage__MemoryIO = &__pyx_type_3smc_9freeimage_10_freeimage__MemoryIO;
  /*--- Type import code ---*/
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "smc/freeimage/_freeimage.pyx":36
 * 
 * 
 * import sys as _sys             # <<<<<<<<<<<<<<
 * from logging import getLogger
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":37
 * 
 * import sys as _sys
 * from logging import getLogger             # <<<<<<<<<<<<<<
 * 
 * #--- constants
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__getLogger));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__getLogger));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__getLogger));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__logging), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__getLogger);
  if (__pyx_t_1 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__getLogger);
    if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getLogger, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":41
 * #--- constants
 * __all__ = (
 *     "Image", "LCMSTransformation", "LCMSException",             # <<<<<<<<<<<<<<
 *     "FreeImageError", "UnknownImageError", "LoadError", "SaveError", "OperationError",
 *     "getVersion", "getCompiledFor", "getCopyright", "FormatInfo",
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_k_tuple_162)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":27
 * 
 * #--- imports
 * from logging import getLogger             # <<<<<<<<<<<<<<
 * from datetime import datetime
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__getLogger));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__getLogger));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__getLogger));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__logging), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__getLogger);
  if (__pyx_t_2 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__getLogger);
    if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getLogger, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":28
 * #--- imports
 * from logging import getLogger
 * from datetime import datetime             # <<<<<<<<<<<<<<
 * 
 * # ***************************************************************************
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__datetime));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__datetime));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__datetime));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__datetime), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__datetime);
  if (__pyx_t_1 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__datetime);
    if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__datetime, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":41
 * 
 * 
 * loggername = "smc.freeimage.lcms"             # <<<<<<<<<<<<<<
 * cdef object _logger = getLogger(loggername)
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__loggername, ((PyObject *)__pyx_kp_s_163)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":42
 * 
 * loggername = "smc.freeimage.lcms"
 * cdef object _logger = getLogger(loggername)             # <<<<<<<<<<<<<<
 * 
 * cdef void errorHandler(lcms.cmsContext ContextID,
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__getLogger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__loggername); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_XGOTREF(__pyx_v_3smc_9freeimage_10_freeimage__logger);
  __Pyx_DECREF(__pyx_v_3smc_9freeimage_10_freeimage__logger);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_3smc_9freeimage_10_freeimage__logger = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":49
 *     _logger.info(< char *> text)
 * 
 * lcms.cmsSetLogErrorHandler(< lcms.cmsLogErrorHandlerFunction > errorHandler)             # <<<<<<<<<<<<<<
 * 
 * def getLCMSVersion():
 */
  cmsSetLogErrorHandler(((cmsLogErrorHandlerFunction)__pyx_f_3smc_9freeimage_10_freeimage_errorHandler));

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":51
 * lcms.cmsSetLogErrorHandler(< lcms.cmsLogErrorHandlerFunction > errorHandler)
 * 
 * def getLCMSVersion():             # <<<<<<<<<<<<<<
 *     return lcms.LCMS_VERSION
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_1getLCMSVersion, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getLCMSVersion, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":54
 *     return lcms.LCMS_VERSION
 * 
 * def XYZ2xyY(float X, float Y, float Z):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsCIEXYZ XYZ
 *     cdef lcms.cmsCIExyY xyY
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_3XYZ2xyY, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__XYZ2xyY, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":63
 *     return xyY.x, xyY.y, xyY.Y
 * 
 * def xyY2XYZ(float x, float y, float Y):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsCIEXYZ XYZ
 *     cdef lcms.cmsCIExyY xyY
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_5xyY2XYZ, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__xyY2XYZ, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":72
 *     return XYZ.X, XYZ.Y, XYZ.Z
 * 
 * def tempFromWhitePoint(float x, float y, float Y):             # <<<<<<<<<<<<<<
 *     cdef lcms.cmsFloat64Number tempK
 *     cdef lcms.cmsCIExyY xyY
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_7tempFromWhitePoint, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__tempFromWhitePoint, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":82
 *     return tempK
 * 
 * def getIntents():             # <<<<<<<<<<<<<<
 *     cdef int n, i, intents = 200
 *     cdef int intent_ids[200]
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_9getIntents, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getIntents, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":95
 *     return result
 * 
 * class LCMSException(Exception):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1), __pyx_n_s__LCMSException, __pyx_n_s_166); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__LCMSException, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":142
 *                  bytes inprofile,
 *                  bytes outprofile=b"sRGB",
 *                  int format=lcms.TYPE_BGR_8,             # <<<<<<<<<<<<<<
 *                  int intent=lcms.INTENT_PERCEPTUAL,
 *                  unsigned long flags=0
 */
  __pyx_k_7 = TYPE_BGR_8;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":143
 *                  bytes outprofile=b"sRGB",
 *                  int format=lcms.TYPE_BGR_8,
 *                  int intent=lcms.INTENT_PERCEPTUAL,             # <<<<<<<<<<<<<<
 *                  unsigned long flags=0
 *                  ):
 */
  __pyx_k_8 = INTENT_PERCEPTUAL;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":192
 * 
 *     cdef setTransform(self, int inputformat, int outputformat,
 *                       int intent=lcms.INTENT_PERCEPTUAL,             # <<<<<<<<<<<<<<
 *                       unsigned long flags=0):
 *         if self.hInProfile == NULL:
 */
  __pyx_k_9 = INTENT_PERCEPTUAL;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":297
 *               bytes inprofile=None,
 *               bytes outprofile=b"sRGB",
 *               int intent=lcms.INTENT_PERCEPTUAL,             # <<<<<<<<<<<<<<
 *               unsigned long flags=0):
 * 
 */
  __pyx_k_16 = INTENT_PERCEPTUAL;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":414
 *     return (t1[0], t2[0], t3[0]), (t1[1], t2[1], t3[1])
 * 
 * _illu_map = {0: "unknown", 1: "D50", 2: "D65", 3: "D93", 4: "F2", 5: "D55", 6: "A", 7: "E", 8: "F8"}             # <<<<<<<<<<<<<<
 * 
 * cdef class LCMSProfileInfo(object):
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_0, ((PyObject *)__pyx_n_s__unknown)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1, ((PyObject *)__pyx_n_s__D50)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2, ((PyObject *)__pyx_n_s__D65)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3, ((PyObject *)__pyx_n_s__D93)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_4, ((PyObject *)__pyx_n_s__F2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_5, ((PyObject *)__pyx_n_s__D55)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_6, ((PyObject *)__pyx_n_s__A)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_7, ((PyObject *)__pyx_n_s__E)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_8, ((PyObject *)__pyx_n_s__F8)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___illu_map, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":443
 *             lcms.cmsCloseProfile(self.hProfile)
 * 
 *     cdef _readMLU(self, lcms.cmsTagSignature info, char * language="en", char * country=lcms.cmsNoCountry):             # <<<<<<<<<<<<<<
 *         cdef int read
 *         cdef lcms.const_cmsMLU * mlu
 */
  __pyx_k_32 = cmsNoCountry;

  /* "/home/heimes/semantics/src/smc.freeimage/smc/freeimage/_lcms.pxi":464
 *         return uni
 * 
 *     cdef _readCIEXYZ(self, lcms.cmsTagSignature info, multi=False):             # <<<<<<<<<<<<<<
 *         cdef lcms.cmsCIEXYZ * XYZ
 *         if not lcms.cmsIsTag(self.hProfile, info):
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_k_33 = __pyx_t_1;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":142
 * DEF ERR_CLOSED = -3
 * 
 * _META_MODELS = {             # <<<<<<<<<<<<<<
 *     "FIMD_NODATA" : fi.FIMD_NODATA,
 *     "FIMD_COMMENTS" : fi.FIMD_COMMENTS,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "smc/freeimage/_freeimage.pyx":143
 * 
 * _META_MODELS = {
 *     "FIMD_NODATA" : fi.FIMD_NODATA,             # <<<<<<<<<<<<<<
 *     "FIMD_COMMENTS" : fi.FIMD_COMMENTS,
 *     "FIMD_EXIF_MAIN" : fi.FIMD_EXIF_MAIN,
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_NODATA); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_NODATA), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":144
 * _META_MODELS = {
 *     "FIMD_NODATA" : fi.FIMD_NODATA,
 *     "FIMD_COMMENTS" : fi.FIMD_COMMENTS,             # <<<<<<<<<<<<<<
 *     "FIMD_EXIF_MAIN" : fi.FIMD_EXIF_MAIN,
 *     "FIMD_EXIF_EXIF" : fi.FIMD_EXIF_EXIF,
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_COMMENTS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_COMMENTS), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":145
 *     "FIMD_NODATA" : fi.FIMD_NODATA,
 *     "FIMD_COMMENTS" : fi.FIMD_COMMENTS,
 *     "FIMD_EXIF_MAIN" : fi.FIMD_EXIF_MAIN,             # <<<<<<<<<<<<<<
 *     "FIMD_EXIF_EXIF" : fi.FIMD_EXIF_EXIF,
 *     "FIMD_EXIF_GPS" : fi.FIMD_EXIF_GPS,
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_EXIF_MAIN); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_EXIF_MAIN), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":146
 *     "FIMD_COMMENTS" : fi.FIMD_COMMENTS,
 *     "FIMD_EXIF_MAIN" : fi.FIMD_EXIF_MAIN,
 *     "FIMD_EXIF_EXIF" : fi.FIMD_EXIF_EXIF,             # <<<<<<<<<<<<<<
 *     "FIMD_EXIF_GPS" : fi.FIMD_EXIF_GPS,
 *     "FIMD_EXIF_MAKERNOTE" : fi.FIMD_EXIF_MAKERNOTE,
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_EXIF_EXIF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_EXIF_EXIF), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":147
 *     "FIMD_EXIF_MAIN" : fi.FIMD_EXIF_MAIN,
 *     "FIMD_EXIF_EXIF" : fi.FIMD_EXIF_EXIF,
 *     "FIMD_EXIF_GPS" : fi.FIMD_EXIF_GPS,             # <<<<<<<<<<<<<<
 *     "FIMD_EXIF_MAKERNOTE" : fi.FIMD_EXIF_MAKERNOTE,
 *     "FIMD_EXIF_INTEROP" : fi.FIMD_EXIF_INTEROP,
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_EXIF_GPS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_EXIF_GPS), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":148
 *     "FIMD_EXIF_EXIF" : fi.FIMD_EXIF_EXIF,
 *     "FIMD_EXIF_GPS" : fi.FIMD_EXIF_GPS,
 *     "FIMD_EXIF_MAKERNOTE" : fi.FIMD_EXIF_MAKERNOTE,             # <<<<<<<<<<<<<<
 *     "FIMD_EXIF_INTEROP" : fi.FIMD_EXIF_INTEROP,
 *     "FIMD_IPTC" : fi.FIMD_IPTC,
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_EXIF_MAKERNOTE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_EXIF_MAKERNOTE), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":149
 *     "FIMD_EXIF_GPS" : fi.FIMD_EXIF_GPS,
 *     "FIMD_EXIF_MAKERNOTE" : fi.FIMD_EXIF_MAKERNOTE,
 *     "FIMD_EXIF_INTEROP" : fi.FIMD_EXIF_INTEROP,             # <<<<<<<<<<<<<<
 *     "FIMD_IPTC" : fi.FIMD_IPTC,
 *     "FIMD_XMP" : fi.FIMD_XMP,
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_EXIF_INTEROP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_EXIF_INTEROP), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":150
 *     "FIMD_EXIF_MAKERNOTE" : fi.FIMD_EXIF_MAKERNOTE,
 *     "FIMD_EXIF_INTEROP" : fi.FIMD_EXIF_INTEROP,
 *     "FIMD_IPTC" : fi.FIMD_IPTC,             # <<<<<<<<<<<<<<
 *     "FIMD_XMP" : fi.FIMD_XMP,
 *     "FIMD_GEOTIFF" : fi.FIMD_GEOTIFF,
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_IPTC); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_IPTC), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":151
 *     "FIMD_EXIF_INTEROP" : fi.FIMD_EXIF_INTEROP,
 *     "FIMD_IPTC" : fi.FIMD_IPTC,
 *     "FIMD_XMP" : fi.FIMD_XMP,             # <<<<<<<<<<<<<<
 *     "FIMD_GEOTIFF" : fi.FIMD_GEOTIFF,
 *     "FIMD_ANIMATION" : fi.FIMD_ANIMATION,
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_XMP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_XMP), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":152
 *     "FIMD_IPTC" : fi.FIMD_IPTC,
 *     "FIMD_XMP" : fi.FIMD_XMP,
 *     "FIMD_GEOTIFF" : fi.FIMD_GEOTIFF,             # <<<<<<<<<<<<<<
 *     "FIMD_ANIMATION" : fi.FIMD_ANIMATION,
 *     "FIMD_CUSTOM" : fi.FIMD_CUSTOM,
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_GEOTIFF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_GEOTIFF), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":153
 *     "FIMD_XMP" : fi.FIMD_XMP,
 *     "FIMD_GEOTIFF" : fi.FIMD_GEOTIFF,
 *     "FIMD_ANIMATION" : fi.FIMD_ANIMATION,             # <<<<<<<<<<<<<<
 *     "FIMD_CUSTOM" : fi.FIMD_CUSTOM,
 *     }
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_ANIMATION); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_ANIMATION), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":154
 *     "FIMD_GEOTIFF" : fi.FIMD_GEOTIFF,
 *     "FIMD_ANIMATION" : fi.FIMD_ANIMATION,
 *     "FIMD_CUSTOM" : fi.FIMD_CUSTOM,             # <<<<<<<<<<<<<<
 *     }
 * 
 */
  __pyx_t_2 = PyInt_FromLong(FIMD_CUSTOM); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FIMD_CUSTOM), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___META_MODELS, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":157
 *     }
 * 
 * _COLOR_TYPE_NAMES = {             # <<<<<<<<<<<<<<
 *     fi.FIC_MINISWHITE : "White",
 *     fi.FIC_MINISBLACK : "Black",
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "smc/freeimage/_freeimage.pyx":158
 * 
 * _COLOR_TYPE_NAMES = {
 *     fi.FIC_MINISWHITE : "White",             # <<<<<<<<<<<<<<
 *     fi.FIC_MINISBLACK : "Black",
 *     fi.FIC_RGB : "RGB",
 */
  __pyx_t_2 = PyInt_FromLong(FIC_MINISWHITE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_n_s__White)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":159
 * _COLOR_TYPE_NAMES = {
 *     fi.FIC_MINISWHITE : "White",
 *     fi.FIC_MINISBLACK : "Black",             # <<<<<<<<<<<<<<
 *     fi.FIC_RGB : "RGB",
 *     fi.FIC_PALETTE : "Palette",
 */
  __pyx_t_2 = PyInt_FromLong(FIC_MINISBLACK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_n_s__Black)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":160
 *     fi.FIC_MINISWHITE : "White",
 *     fi.FIC_MINISBLACK : "Black",
 *     fi.FIC_RGB : "RGB",             # <<<<<<<<<<<<<<
 *     fi.FIC_PALETTE : "Palette",
 *     fi.FIC_RGBALPHA : "RGBA",
 */
  __pyx_t_2 = PyInt_FromLong(FIC_RGB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_n_s__RGB)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":161
 *     fi.FIC_MINISBLACK : "Black",
 *     fi.FIC_RGB : "RGB",
 *     fi.FIC_PALETTE : "Palette",             # <<<<<<<<<<<<<<
 *     fi.FIC_RGBALPHA : "RGBA",
 *     fi.FIC_CMYK : "CMYK"
 */
  __pyx_t_2 = PyInt_FromLong(FIC_PALETTE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_n_s__Palette)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":162
 *     fi.FIC_RGB : "RGB",
 *     fi.FIC_PALETTE : "Palette",
 *     fi.FIC_RGBALPHA : "RGBA",             # <<<<<<<<<<<<<<
 *     fi.FIC_CMYK : "CMYK"
 * }
 */
  __pyx_t_2 = PyInt_FromLong(FIC_RGBALPHA); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_n_s__RGBA)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":163
 *     fi.FIC_PALETTE : "Palette",
 *     fi.FIC_RGBALPHA : "RGBA",
 *     fi.FIC_CMYK : "CMYK"             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_t_2 = PyInt_FromLong(FIC_CMYK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_n_s__CMYK)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___COLOR_TYPE_NAMES, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":178
 * # lost.
 * 
 * cdef int tls_key = -1             # <<<<<<<<<<<<<<
 * 
 * cdef struct SmcFiError:
 */
  __pyx_v_3smc_9freeimage_10_freeimage_tls_key = -1;

  /* "smc/freeimage/_freeimage.pyx":252
 * #--- exceptions
 * 
 * def dispatchFIError(cls, *args):             # <<<<<<<<<<<<<<
 *     cdef char* err
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_11dispatchFIError, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__dispatchFIError, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":279
 * 
 * 
 * class FreeImageError(Exception):             # <<<<<<<<<<<<<<
 *     def __init__(self, *args, fimsg=None):
 *         if fimsg is not None:
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "smc/freeimage/_freeimage.pyx":280
 * 
 * class FreeImageError(Exception):
 *     def __init__(self, *args, fimsg=None):             # <<<<<<<<<<<<<<
 *         if fimsg is not None:
 *             args = args + (fimsg,)
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_14FreeImageError_1__init__, 0, NULL, __pyx_n_s_166, ((PyObject *)__pyx_k_codeobj_179)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, ((PyObject *)__pyx_k_tuple_180));
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "smc/freeimage/_freeimage.pyx":279
 * 
 * 
 * class FreeImageError(Exception):             # <<<<<<<<<<<<<<
 *     def __init__(self, *args, fimsg=None):
 *         if fimsg is not None:
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__FreeImageError, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__FreeImageError, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":287
 * 
 * 
 * class UnknownImageError(FreeImageError):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__FreeImageError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__UnknownImageError, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__UnknownImageError, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":291
 * 
 * 
 * class LoadError(FreeImageError):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__FreeImageError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__LoadError, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__LoadError, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":295
 * 
 * 
 * class SaveError(FreeImageError):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__FreeImageError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__SaveError, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__SaveError, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":299
 * 
 * 
 * class OperationError(FreeImageError):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__FreeImageError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__OperationError, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__OperationError, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":303
 * 
 * 
 * class FreeImageMemoryError(FreeImageError, MemoryError):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__FreeImageError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_builtin_MemoryError);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_builtin_MemoryError);
  __Pyx_GIVEREF(__pyx_builtin_MemoryError);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s_45, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_45, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":526
 *         return fi.FreeImage_TellMemory(self._mem)
 * 
 *     def seek(self, int offset, unsigned whence=stdio.SEEK_SET):             # <<<<<<<<<<<<<<
 *         """seek(offset [, whence]) -> None
 * 
 */
  __pyx_k_55 = SEEK_SET;

  /* "smc/freeimage/_freeimage.pyx":634
 *         return 0
 * 
 * def _new_image(unsigned width, unsigned height, unsigned bpp,             # <<<<<<<<<<<<<<
 *               unsigned red_mask = 0, unsigned green_mask = 0, unsigned blue_mask = 0):
 *         cdef fi.FIBITMAP* dib
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_13_new_image, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___new_image, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":677
 *         self.buffers = 0
 * 
 *     new = staticmethod(_new_image)             # <<<<<<<<<<<<<<
 * 
 *     cdef from_filename(self, filename, int flags):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___new_image); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_builtin_staticmethod, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_3smc_9freeimage_10_freeimage_Image->tp_dict, __pyx_n_s__new, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_3smc_9freeimage_10_freeimage_Image);

  /* "smc/freeimage/_freeimage.pyx":1065
 *     # **********************************************************************
 *     # scale
 *     def resize(self, int width, int height, int filter=fi.FILTER_BOX):             # <<<<<<<<<<<<<<
 *         """resize(width: int, height: int[, filter=FILTER_BOX]) -> new image
 *         """
 */
  __pyx_k_84 = FILTER_BOX;

  /* "smc/freeimage/_freeimage.pyx":1465
 *         self.adjustColors(invert=1)
 * 
 *     def getHistogram(self, int channel=fi.FICC_BLACK):             # <<<<<<<<<<<<<<
 *         """getHistogramm([channel=fi.FICC_BLACK]) -> list[256]
 *         """
 */
  __pyx_k_111 = FICC_BLACK;

  /* "smc/freeimage/_freeimage.pyx":1724
 * # Format Info
 * 
 * def FormatInfo_from_filename(cls, filename):             # <<<<<<<<<<<<<<
 *     """from_filename(filename) -> FormatInfo instance
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_15FormatInfo_from_filename, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_185, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1733
 *     return cls(format)
 * 
 * def FormatInfo_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *     """from_file(path) -> FormatInfo instance
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_17FormatInfo_from_file, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_188, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1742
 *     return cls(format)
 * 
 * def FormatInfo_from_mimetype(cls, mime):             # <<<<<<<<<<<<<<
 *     """from_mimetype(mime) -> FormatInfo instance
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_19FormatInfo_from_mimetype, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_191, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "smc/freeimage/_freeimage.pyx":1761
 *         self._format = <fi.FREE_IMAGE_FORMAT>format
 * 
 *     from_filename = classmethod(FormatInfo_from_filename)             # <<<<<<<<<<<<<<
 *     from_file = classmethod(FormatInfo_from_file)
 *     from_mimetype = classmethod(FormatInfo_from_mimetype)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_185); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_Method_ClassMethod(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_3smc_9freeimage_10_freeimage_FormatInfo->tp_dict, __pyx_n_s__from_filename, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_3smc_9freeimage_10_freeimage_FormatInfo);

  /* "smc/freeimage/_freeimage.pyx":1762
 * 
 *     from_filename = classmethod(FormatInfo_from_filename)
 *     from_file = classmethod(FormatInfo_from_file)             # <<<<<<<<<<<<<<
 *     from_mimetype = classmethod(FormatInfo_from_mimetype)
 * 
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s_188); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_Method_ClassMethod(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_3smc_9freeimage_10_freeimage_FormatInfo->tp_dict, __pyx_n_s__from_file, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_3smc_9freeimage_10_freeimage_FormatInfo);

  /* "smc/freeimage/_freeimage.pyx":1763
 *     from_filename = classmethod(FormatInfo_from_filename)
 *     from_file = classmethod(FormatInfo_from_file)
 *     from_mimetype = classmethod(FormatInfo_from_mimetype)             # <<<<<<<<<<<<<<
 * 
 *     def __int__(self):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_191); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_Method_ClassMethod(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_3smc_9freeimage_10_freeimage_FormatInfo->tp_dict, __pyx_n_s__from_mimetype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_3smc_9freeimage_10_freeimage_FormatInfo);

  /* "smc/freeimage/_freeimage.pyx":1819
 * 
 * #--- module functions
 * def getVersion():             # <<<<<<<<<<<<<<
 *     """getVersion() -> str
 * 
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_21getVersion, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getVersion, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "smc/freeimage/_freeimage.pyx":1826
 *     return funicode(fi.FreeImage_GetVersion())
 * 
 * def getCompiledFor():             # <<<<<<<<<<<<<<
 *     """getCompiledFor() -> tuple(major, minor, serial)
 *     """
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_23getCompiledFor, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getCompiledFor, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "smc/freeimage/_freeimage.pyx":1833
 *             fi.FREEIMAGE_RELEASE_SERIAL)
 * 
 * def getCopyright():             # <<<<<<<<<<<<<<
 *     """getCopyright() -> str
 *     """
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_25getCopyright, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getCopyright, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "smc/freeimage/_freeimage.pyx":1838
 *     return funicode(fi.FreeImage_GetCopyrightMessage())
 * 
 * def getFormatCount():             # <<<<<<<<<<<<<<
 *     """getFormatCount() -> int
 *     """
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_27getFormatCount, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__getFormatCount, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "smc/freeimage/_freeimage.pyx":1843
 *     return fi.FreeImage_GetFIFCount()
 * 
 * def lookupX11Color(name):             # <<<<<<<<<<<<<<
 *     """lookupX11Color(name) -> (r, g, b)
 *     """
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_29lookupX11Color, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__lookupX11Color, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "smc/freeimage/_freeimage.pyx":1852
 *     return (red, green, blue)
 * 
 * def lookupSVGColor(name):             # <<<<<<<<<<<<<<
 *     """lookupSVGColor(name) -> (r, g, b)
 *     """
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_31lookupSVGColor, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__lookupSVGColor, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "smc/freeimage/_freeimage.pyx":1861
 *     return (red, green, blue)
 * 
 * def jpegTransform(src, dst, unsigned int op, unsigned int perfect=0):             # <<<<<<<<<<<<<<
 *     """jpegTransform(source: str, destination: str, op: int) -> None
 * 
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_33jpegTransform, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__jpegTransform, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "smc/freeimage/_freeimage.pyx":1896
 *                              "'%i' failed." % (src, dst, op))
 * 
 * def hasJPEGTurbo():             # <<<<<<<<<<<<<<
 *     """Is FreeImage compiled against libjeg-turbo
 *     """
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_3smc_9freeimage_10_freeimage_35hasJPEGTurbo, NULL, __pyx_n_s_166); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__hasJPEGTurbo, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "smc/freeimage/_freeimage.pyx":1908
 *     initErrorHandler()
 * 
 * initialize()             # <<<<<<<<<<<<<<
 */
  __pyx_f_3smc_9freeimage_10_freeimage_initialize();

  /* "smc/freeimage/_freeimage.pyx":1
 * # -*- coding: utf-8 -*-             # <<<<<<<<<<<<<<
 * #=============================================================================
 * # Copyright   : (c) 2008-2012 semantics GmbH. All Rights Reserved.
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__pyx_m) {
    __Pyx_AddTraceback("init smc.freeimage._freeimage", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init smc.freeimage._freeimage");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result) {
        if (dict != __pyx_b) {
            PyErr_Clear();
            result = PyObject_GetAttr(__pyx_b, name);
        }
        if (!result) {
            PyErr_SetObject(PyExc_NameError, name);
        }
    }
    return result;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else /* Python 3+ */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (!PyExceptionClass_Check(type)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        }
        else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        }
        else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        if (!value) {
            value = PyObject_CallObject(type, NULL);
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }
bad:
    return;
}
#endif

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}



static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #else
        if (unlikely(!PyUnicode_Check(key)))
        #endif
            goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}



static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
    if (unlikely(tstate->curexc_type))
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected);
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else if (PyErr_Occurred()) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
}

static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
    long q = a / b;
    long r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t val) {
    const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(uint32_t) == sizeof(char))  ||
        (sizeof(uint32_t) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(uint32_t) == sizeof(int)) ||
               (sizeof(uint32_t) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(uint32_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(uint32_t),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int32_t(int32_t val) {
    const int32_t neg_one = (int32_t)-1, const_zero = (int32_t)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(int32_t) == sizeof(char))  ||
        (sizeof(int32_t) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(int32_t) == sizeof(int)) ||
               (sizeof(int32_t) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(int32_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(int32_t),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint16_t(uint16_t val) {
    const uint16_t neg_one = (uint16_t)-1, const_zero = (uint16_t)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(uint16_t) == sizeof(char))  ||
        (sizeof(uint16_t) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(uint16_t) == sizeof(int)) ||
               (sizeof(uint16_t) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(uint16_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(uint16_t),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
    /* It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API */
    static PyTypeObject *methoddescr_type = NULL;
    if (methoddescr_type == NULL) {
       PyObject *meth = __Pyx_GetAttrString((PyObject*)&PyList_Type, "append");
       if (!meth) return NULL;
       methoddescr_type = Py_TYPE(meth);
       Py_DECREF(meth);
    }
    if (PyObject_TypeCheck(method, methoddescr_type)) { /* cdef classes */
        PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
        #if PY_VERSION_HEX < 0x03020000
        PyTypeObject *d_type = descr->d_type;
        #else
        PyTypeObject *d_type = descr->d_common.d_type;
        #endif
        return PyDescr_NewClassMethod(d_type, descr->d_method);
    }
    else if (PyMethod_Check(method)) { /* python classes */
        return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
    }
    else if (PyCFunction_Check(method)) {
        return PyClassMethod_New(method);
    }
#ifdef __Pyx_CyFunction_USED
    else if (PyObject_TypeCheck(method, __pyx_CyFunctionType)) {
        return PyClassMethod_New(method);
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "Class-level classmethod() can only be called on "
                 "a method_descriptor or instance method.");
    return NULL;
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    #if PY_VERSION_HEX >= 0x02050000
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                /* try package relative import first */
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0; /* try absolute import on failure */
        }
        #endif
        if (!module) {
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
        }
    }
    #else
    if (level>0) {
        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
        goto bad;
    }
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
    #endif
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name) {
#if PY_MAJOR_VERSION < 3
    PyErr_Format(PyExc_ImportError, "cannot import name %.230s",
                 PyString_AsString(name));
#else
    PyErr_Format(PyExc_ImportError, "cannot import name %S", name);
#endif
}

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
    PyObject *metaclass;
    /* Default metaclass */
#if PY_MAJOR_VERSION < 3
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = PyObject_GetAttrString(base, (char *)"__class__");
        if (!metaclass) {
            PyErr_Clear();
            metaclass = (PyObject*) Py_TYPE(base);
        }
    } else {
        metaclass = (PyObject *) &PyClass_Type;
    }
#else
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = (PyObject*) Py_TYPE(base);
    } else {
        metaclass = (PyObject *) &PyType_Type;
    }
#endif
    Py_INCREF(metaclass);
    return metaclass;
}

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname) {
    PyObject *result;
    PyObject *metaclass;
    if (PyDict_SetItemString(dict, "__module__", modname) < 0)
        return NULL;
    /* Python2 __metaclass__ */
    metaclass = PyDict_GetItemString(dict, "__metaclass__");
    if (metaclass) {
        Py_INCREF(metaclass);
    } else {
        metaclass = __Pyx_FindPy2Metaclass(bases);
    }
    result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
    Py_DECREF(metaclass);
    return result;
}

static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (op->func_doc == NULL && op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
        op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
        op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
    }
    if (op->func_doc == 0) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL)
        op->func_doc = Py_None; /* Mark as deleted */
    else
        op->func_doc = value;
    Py_INCREF(op->func_doc);
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (op->func_name == NULL) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (value == NULL || !PyUnicode_Check(value)) {
#else
    if (value == NULL || !PyString_Check(value)) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (op->func_dict == NULL) {
        op->func_dict = PyDict_New();
        if (op->func_dict == NULL)
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (value == NULL) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    PyObject* dict = PyModule_GetDict(__pyx_m);
    Py_XINCREF(dict);
    return dict;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op)
{
    if (op->defaults_tuple) {
        Py_INCREF(op->defaults_tuple);
        return op->defaults_tuple;
    }
    if (op->defaults_getter) {
        PyObject *res = op->defaults_getter((PyObject *) op);
        if (res) {
            Py_INCREF(res);
            op->defaults_tuple = res;
        }
        return res;
    }
    Py_INCREF(Py_None);
    return Py_None;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, 0, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, 0, 0, 0},
    {0, 0, 0, 0, 0}
};
#ifndef PY_WRITE_RESTRICTED /* < Py2.5 */
#define PY_WRITE_RESTRICTED WRITE_RESTRICTED
#endif
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags,
                                      PyObject *closure, PyObject *module, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    op->func_weakreflist = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_getter = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyMem_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    if (m->func_weakreflist != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return PyMethod_New(func,
                            type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
    PyObject *func_name = __Pyx_CyFunction_get_name(op);
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                func_name, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(func_name), (void *)op);
#endif
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/
    sizeof(__pyx_CyFunctionObject),   /*tp_basicsize*/
    0,                                  /*tp_itemsize*/
    (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/
    0,                                  /*tp_print*/
    0,                                  /*tp_getattr*/
    0,                                  /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
    0,                                  /*tp_compare*/
#else
    0,                                  /*reserved*/
#endif
    (reprfunc) __Pyx_CyFunction_repr,   /*tp_repr*/
    0,                                  /*tp_as_number*/
    0,                                  /*tp_as_sequence*/
    0,                                  /*tp_as_mapping*/
    0,                                  /*tp_hash*/
    __Pyx_PyCFunction_Call,             /*tp_call*/
    0,                                  /*tp_str*/
    0,                                  /*tp_getattro*/
    0,                                  /*tp_setattro*/
    0,                                  /*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
    0,                                  /*tp_doc*/
    (traverseproc) __Pyx_CyFunction_traverse,   /*tp_traverse*/
    (inquiry) __Pyx_CyFunction_clear,   /*tp_clear*/
    0,                                  /*tp_richcompare*/
    offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */
    0,                                  /*tp_iter*/
    0,                                  /*tp_iternext*/
    __pyx_CyFunction_methods,           /*tp_methods*/
    __pyx_CyFunction_members,           /*tp_members*/
    __pyx_CyFunction_getsets,           /*tp_getset*/
    0,                                  /*tp_base*/
    0,                                  /*tp_dict*/
    __Pyx_CyFunction_descr_get,         /*tp_descr_get*/
    0,                                  /*tp_descr_set*/
    offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/
    0,                                  /*tp_init*/
    0,                                  /*tp_alloc*/
    0,                                  /*tp_new*/
    0,                                  /*tp_free*/
    0,                                  /*tp_is_gc*/
    0,                                  /*tp_bases*/
    0,                                  /*tp_mro*/
    0,                                  /*tp_cache*/
    0,                                  /*tp_subclasses*/
    0,                                  /*tp_weaklist*/
    0,                                  /*tp_del*/
#if PY_VERSION_HEX >= 0x02060000
    0,                                  /*tp_version_tag*/
#endif
};
static int __Pyx_CyFunction_init(void)
{
    if (PyType_Ready(&__pyx_CyFunctionType_type) < 0)
        return -1;
    __pyx_CyFunctionType = &__pyx_CyFunctionType_type;
    return 0;
}
void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyMem_Malloc(size);
    if (!m->defaults)
        return PyErr_NoMemory();
    memset(m->defaults, 0, sizeof(size));
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_cmsUInt32Number(cmsUInt32Number val) {
    const cmsUInt32Number neg_one = (cmsUInt32Number)-1, const_zero = (cmsUInt32Number)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(cmsUInt32Number) == sizeof(char))  ||
        (sizeof(cmsUInt32Number) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(cmsUInt32Number) == sizeof(int)) ||
               (sizeof(cmsUInt32Number) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(cmsUInt32Number) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(cmsUInt32Number),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_cmsUInt64Number(cmsUInt64Number val) {
    const cmsUInt64Number neg_one = (cmsUInt64Number)-1, const_zero = (cmsUInt64Number)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(cmsUInt64Number) == sizeof(char))  ||
        (sizeof(cmsUInt64Number) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(cmsUInt64Number) == sizeof(int)) ||
               (sizeof(cmsUInt64Number) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(cmsUInt64Number) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(cmsUInt64Number),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_cmsBool(cmsBool val) {
    const cmsBool neg_one = (cmsBool)-1, const_zero = (cmsBool)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(cmsBool) == sizeof(char))  ||
        (sizeof(cmsBool) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(cmsBool) == sizeof(int)) ||
               (sizeof(cmsBool) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(cmsBool) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(cmsBool),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE cmsUInt32Number __Pyx_PyInt_from_py_cmsUInt32Number(PyObject* x) {
    const cmsUInt32Number neg_one = (cmsUInt32Number)-1, const_zero = (cmsUInt32Number)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(cmsUInt32Number) == sizeof(char)) {
        if (is_unsigned)
            return (cmsUInt32Number)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (cmsUInt32Number)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(cmsUInt32Number) == sizeof(short)) {
        if (is_unsigned)
            return (cmsUInt32Number)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (cmsUInt32Number)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(cmsUInt32Number) == sizeof(int)) {
        if (is_unsigned)
            return (cmsUInt32Number)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (cmsUInt32Number)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(cmsUInt32Number) == sizeof(long)) {
        if (is_unsigned)
            return (cmsUInt32Number)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (cmsUInt32Number)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(cmsUInt32Number) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (cmsUInt32Number)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (cmsUInt32Number)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        cmsUInt32Number val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_VERSION_HEX < 0x03000000
        if (likely(v) && !PyLong_Check(v)) {
            PyObject *tmp = v;
            v = PyNumber_Long(tmp);
            Py_DECREF(tmp);
        }
        #endif
        if (likely(v)) {
            int one = 1; int is_little = (int)*(unsigned char *)&one;
            unsigned char *bytes = (unsigned char *)&val;
            int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                          bytes, sizeof(val),
                                          is_little, !is_unsigned);
            Py_DECREF(v);
            if (likely(!ret))
                return val;
        }
        return (cmsUInt32Number)-1;
    }
}

static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject* x) {
    const int32_t neg_one = (int32_t)-1, const_zero = (int32_t)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(int32_t) == sizeof(char)) {
        if (is_unsigned)
            return (int32_t)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (int32_t)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(int32_t) == sizeof(short)) {
        if (is_unsigned)
            return (int32_t)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (int32_t)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(int32_t) == sizeof(int)) {
        if (is_unsigned)
            return (int32_t)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (int32_t)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(int32_t) == sizeof(long)) {
        if (is_unsigned)
            return (int32_t)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (int32_t)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(int32_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (int32_t)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (int32_t)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        int32_t val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_VERSION_HEX < 0x03000000
        if (likely(v) && !PyLong_Check(v)) {
            PyObject *tmp = v;
            v = PyNumber_Long(tmp);
            Py_DECREF(tmp);
        }
        #endif
        if (likely(v)) {
            int one = 1; int is_little = (int)*(unsigned char *)&one;
            unsigned char *bytes = (unsigned char *)&val;
            int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                          bytes, sizeof(val),
                                          is_little, !is_unsigned);
            Py_DECREF(v);
            if (likely(!ret))
                return val;
        }
        return (int32_t)-1;
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint8_t(uint8_t val) {
    const uint8_t neg_one = (uint8_t)-1, const_zero = (uint8_t)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(uint8_t) == sizeof(char))  ||
        (sizeof(uint8_t) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(uint8_t) == sizeof(int)) ||
               (sizeof(uint8_t) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(uint8_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(uint8_t),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return (unsigned long)PyLong_AsUnsignedLong(x);
        } else {
            return (unsigned long)PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return (long)PyLong_AsUnsignedLong(x);
        } else {
            return (long)PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return (signed long)PyLong_AsUnsignedLong(x);
        } else {
            return (signed long)PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && (size_t)((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        if (PyErr_Warn(NULL, warning) < 0) goto bad;
        #else
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
        #endif
    }
    else if ((size_t)((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = (start + end) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,            /*int argcount,*/
        0,            /*int kwonlyargcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,      /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_globals = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}


/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
