Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/wand/cdefs/pixel_wand.py : 88%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1""":mod:`wand.cdefs.pixel_wand` --- Pixel-Wand definitions
2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4.. versionadded:: 0.5.0
5"""
6from ctypes import (CDLL, POINTER, c_char_p, c_double,
7 c_float, c_int, c_longdouble, c_size_t,
8 c_ubyte, c_uint, c_ushort, c_void_p)
9from wand.cdefs.wandtypes import c_magick_char_p
10import numbers
12__all__ = ('load',)
15def load(lib, IM_VERSION, IM_QUANTUM_DEPTH, IM_HDRI):
16 """Define Pixel Wand methods. The ImageMagick version is given as
17 a second argument for comparison. This will quick to determine which
18 methods are available from the library, and can be implemented as::
20 if IM_VERSION < 0x700:
21 # ... do ImageMagick-6 methods ...
22 else
23 # ... do ImageMagick-7 methods ...
25 .. seealso::
27 #include "wand/pixel-wand.h"
28 // Or
29 #include "MagickWand/pixel-wand.h"
31 Mapping Pixel methods also requires the wand library to evaluate
32 what "Quantum" is to ImageMagick. We must query the library
33 to identify if HRDI is enabled, and what the quantum depth is.
35 .. seealso::
37 MagickCore/magick-type.h
39 :param lib: the loaded ``MagickWand`` library.
40 :type lib: :class:`ctypes.CDLL`
41 :param IM_VERSION: the ImageMagick version number (i.e. 0x0689).
42 :type IM_VERSION: :class:`numbers.Integral`
43 :param IM_QUANTUM_DEPTH: the ImageMagick Quantum Depth
44 (must be 8, 16, 32, or 64).
45 :type IM_QUANTUM_DEPTH: :class:`numbers.Integral`
46 :param IM_HDRI: if ImageMagick was compiled with HDRI support.
47 :type IM_HDRI: :class:`bool`
49 .. versionadded:: 0.5.0
51 """
52 if not isinstance(lib, CDLL):
53 raise AttributeError(repr(lib) + " is not an instanced of ctypes.CDLL")
54 if not isinstance(IM_VERSION, numbers.Integral):
55 raise AttributeError("Expecting MagickCore version number")
56 if IM_QUANTUM_DEPTH not in [8, 16, 32, 65]:
57 raise AttributeError("QUANTUM_DEPTH must be one of 8, 16, 32, or 64")
58 is_im_6 = IM_VERSION < 0x700
59 is_im_7 = IM_VERSION >= 0x700
61 if IM_QUANTUM_DEPTH == 8:
62 QuantumType = c_float if IM_HDRI else c_ubyte
63 elif IM_QUANTUM_DEPTH == 16:
64 QuantumType = c_float if IM_HDRI else c_ushort
65 elif IM_QUANTUM_DEPTH == 32:
66 QuantumType = c_double if IM_HDRI else c_uint
67 elif IM_QUANTUM_DEPTH == 64:
68 QuantumType = c_longdouble
70 lib.ClearPixelWand.argtypes = [c_void_p]
71 lib.ClonePixelWand.argtypes = [c_void_p]
72 lib.ClonePixelWand.restype = c_void_p
73 lib.DestroyPixelWand.argtypes = [c_void_p]
74 lib.DestroyPixelWand.restype = c_void_p
75 lib.DestroyPixelWands.argtypes = [POINTER(c_void_p), c_size_t]
76 lib.DestroyPixelWands.restype = POINTER(c_void_p)
77 lib.IsPixelWand.argtypes = [c_void_p]
78 lib.IsPixelWandSimilar.argtypes = [c_void_p, c_void_p, c_double]
79 lib.NewPixelWand.argtypes = []
80 lib.NewPixelWand.restype = c_void_p
81 lib.PixelClearException.argtypes = [c_void_p]
82 lib.PixelClearException.restype = c_int
83 lib.PixelGetAlpha.argtypes = [c_void_p]
84 lib.PixelGetAlpha.restype = c_double
85 lib.PixelGetAlphaQuantum.argtypes = [c_void_p]
86 lib.PixelGetAlphaQuantum.restype = QuantumType
87 lib.PixelGetBlack.argtypes = [c_void_p]
88 lib.PixelGetBlack.restype = c_double
89 lib.PixelGetBlackQuantum.argtypes = [c_void_p]
90 lib.PixelGetBlackQuantum.restype = QuantumType
91 lib.PixelGetBlue.argtypes = [c_void_p]
92 lib.PixelGetBlue.restype = c_double
93 lib.PixelGetBlueQuantum.argtypes = [c_void_p]
94 lib.PixelGetBlueQuantum.restype = QuantumType
95 lib.PixelGetColorAsNormalizedString.argtypes = [c_void_p]
96 lib.PixelGetColorAsNormalizedString.restype = c_magick_char_p
97 lib.PixelGetColorAsString.argtypes = [c_void_p]
98 lib.PixelGetColorAsString.restype = c_magick_char_p
99 lib.PixelGetColorCount.argtypes = [c_void_p]
100 lib.PixelGetColorCount.restype = c_size_t
101 lib.PixelGetCyan.argtypes = [c_void_p]
102 lib.PixelGetCyan.restype = c_double
103 lib.PixelGetCyanQuantum.argtypes = [c_void_p]
104 lib.PixelGetCyanQuantum.restype = QuantumType
105 lib.PixelGetException.argtypes = [c_void_p, POINTER(c_int)]
106 lib.PixelGetException.restype = c_magick_char_p
107 lib.PixelGetExceptionType.argtypes = [c_void_p]
108 lib.PixelGetExceptionType.restype = c_int
109 lib.PixelGetFuzz.argtypes = [c_void_p]
110 lib.PixelGetFuzz.restype = c_double
111 lib.PixelGetGreen.argtypes = [c_void_p]
112 lib.PixelGetGreen.restype = c_double
113 lib.PixelGetGreenQuantum.argtypes = [c_void_p]
114 lib.PixelGetGreenQuantum.restype = QuantumType
115 lib.PixelGetHSL.argtypes = [c_void_p,
116 POINTER(c_double),
117 POINTER(c_double),
118 POINTER(c_double)]
119 lib.PixelGetIndex.argtypes = [c_void_p]
120 lib.PixelGetIndex.restype = QuantumType
121 lib.PixelGetMagenta.argtypes = [c_void_p]
122 lib.PixelGetMagenta.restype = c_double
123 lib.PixelGetMagentaQuantum.argtypes = [c_void_p]
124 lib.PixelGetMagentaQuantum.restype = QuantumType
125 lib.PixelGetMagickColor.argtypes = [c_void_p, c_void_p]
126 if is_im_7:
127 lib.PixelGetPixel.argtypes = [c_void_p]
128 lib.PixelGetPixel.restype = c_void_p
129 lib.PixelGetRed.argtypes = [c_void_p]
130 lib.PixelGetRed.restype = c_double
131 lib.PixelGetRedQuantum.argtypes = [c_void_p]
132 lib.PixelGetRedQuantum.restype = QuantumType
133 lib.PixelGetYellow.argtypes = [c_void_p]
134 lib.PixelGetYellow.restype = c_double
135 lib.PixelGetYellowQuantum.argtypes = [c_void_p]
136 lib.PixelGetYellowQuantum.restype = QuantumType
137 lib.PixelSetAlpha.argtypes = [c_void_p, c_double]
138 lib.PixelSetAlphaQuantum.argtypes = [c_void_p, QuantumType]
139 lib.PixelSetBlack.argtypes = [c_void_p, c_double]
140 lib.PixelSetBlackQuantum.argtypes = [c_void_p, QuantumType]
141 lib.PixelSetBlue.argtypes = [c_void_p, c_double]
142 lib.PixelSetBlueQuantum.argtypes = [c_void_p, QuantumType]
143 lib.PixelSetColor.argtypes = [c_void_p, c_char_p]
144 lib.PixelSetColor.restype = c_int
145 lib.PixelSetColorCount.argtypes = [c_void_p, c_size_t]
146 lib.PixelSetCyan.argtypes = [c_void_p, c_double]
147 lib.PixelSetCyanQuantum.argtypes = [c_void_p, QuantumType]
148 lib.PixelSetFuzz.argtypes = [c_void_p, c_double]
149 lib.PixelSetGreen.argtypes = [c_void_p, c_double]
150 lib.PixelSetGreenQuantum.argtypes = [c_void_p, QuantumType]
151 lib.PixelSetHSL.argtypes = [c_void_p, c_double, c_double, c_double]
152 lib.PixelSetIndex.argtypes = [c_void_p, QuantumType]
153 lib.PixelSetMagenta.argtypes = [c_void_p, c_double]
154 lib.PixelSetMagentaQuantum.argtypes = [c_void_p, QuantumType]
155 if is_im_6:
156 lib.PixelSetMagickColor.argtypes = [c_void_p, c_void_p]
157 else:
158 lib.PixelSetMagickColor = None
159 if is_im_7:
160 lib.PixelSetPixelColor.argtypes = [c_void_p, c_void_p]
161 else:
162 lib.PixelSetPixelColor = None
163 lib.PixelSetRed.argtypes = [c_void_p, c_double]
164 lib.PixelSetRedQuantum.argtypes = [c_void_p, QuantumType]
165 lib.PixelSetYellow.argtypes = [c_void_p, c_double]
166 lib.PixelSetYellowQuantum.argtypes = [c_void_p, QuantumType]
167 if is_im_6:
168 lib.PixelSetMagickColor.argtypes = [c_void_p, c_void_p]
169 lib.PixelSetPixelColor = None
170 if is_im_7:
171 lib.PixelSetMagickColor = None
172 lib.PixelSetPixelColor.argtypes = [c_void_p, c_void_p]