aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/c.pyx37
-rw-r--r--src/libgamma_method.py199
-rw-r--r--src/libgamma_native_method.pyx652
3 files changed, 888 insertions, 0 deletions
diff --git a/src/c.pyx b/src/c.pyx
new file mode 100644
index 0000000..f38ce6a
--- /dev/null
+++ b/src/c.pyx
@@ -0,0 +1,37 @@
+# -*- python -*-
+'''
+pylibgamma — Python 3 wrapper for libgamma
+Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
+
+This library is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library. If not, see <http://www.gnu.org/licenses/>.
+'''
+
+cimport cython
+
+from libc.string cimport strerror as c_strerror
+
+
+def strerror(error : int) -> str:
+ '''
+ Get a textual description of an error.
+
+ @param error The number of the error.
+ @return The description of the error.
+ '''
+ cdef const char* text
+ cdef bytes bs
+ text = c_strerror(<int>error)
+ bs = text
+ return bs.decode('utf-8', 'strict')
+
diff --git a/src/libgamma_method.py b/src/libgamma_method.py
index 8e7ebdd..ce92adb 100644
--- a/src/libgamma_method.py
+++ b/src/libgamma_method.py
@@ -570,3 +570,202 @@ that required there is a monitor attached to the connector,
and that status itself.
'''
+
+
+class GammaRamps:
+ '''
+ Gamma ramp structure.
+ '''
+
+ def __init__(self, red_size : int, green_size : int = ..., blue_size : int = ..., *, depth : int = 16):
+ '''
+ Constructor.
+
+ @param red_size The number of stops in the gamma ramp for the red channel
+ @param green_size The number of stops in the gamma ramp for the green channel, `...` for `red_size`
+ @param blue_size The number of stops in the gamma ramp for the blue channel, `...` for `green_size`
+ @param depth The depth of the gamma ramps
+ '''
+ if green_size is ...: green_size = red_size
+ if blue_size is ...: blue_size = green_size
+
+ self.__depth = depth
+ if depth not in (8, 16, 32, 64, -1, -2):
+ raise ValueError('invalid gamma ramp depth')
+
+ if depth == 8: ramp_struct = libgamma_native_gamma_ramps8_create (red_size, green_size, blue_size)
+ elif depth == 16: ramp_struct = libgamma_native_gamma_ramps16_create(red_size, green_size, blue_size)
+ elif depth == 32: ramp_struct = libgamma_native_gamma_ramps32_create(red_size, green_size, blue_size)
+ elif depth == 64: ramp_struct = libgamma_native_gamma_ramps64_create(red_size, green_size, blue_size)
+ elif depth == -1: ramp_struct = libgamma_native_gamma_rampsf_create (red_size, green_size, blue_size)
+ elif depth == -2: ramp_struct = libgamma_native_gamma_rampsd_create (red_size, green_size, blue_size)
+ if isinstance(ramp_struct, int):
+ import c
+ error = OSError()
+ error.errno = ramp_struct
+ error.strerror = c.strerror(error.errno)
+ raise error
+ (self.__ramps, red, green, blue) = ramp_struct
+
+ class Ramp:
+ '''
+ A gamma ramp for one single channel.
+ '''
+
+ def __init__(self, ramp, size : int, depth : int):
+ '''
+ Constructor.
+
+ @param ramp The gamma ramp.
+ @param size The number of stops in the gamma ramp.
+ @param depth The depth of the gamma ramp.
+ '''
+ self.__size = size
+ self.__ramp = ramp
+ if depth == 8: fs = (libgamma_native_gamma_ramps8_get, libgamma_native_gamma_ramps8_set)
+ elif depth == 16: fs = (libgamma_native_gamma_ramps16_get, libgamma_native_gamma_ramps16_set)
+ elif depth == 32: fs = (libgamma_native_gamma_ramps32_get, libgamma_native_gamma_ramps32_set)
+ elif depth == 64: fs = (libgamma_native_gamma_ramps64_get, libgamma_native_gamma_ramps64_set)
+ elif depth == -1: fs = (libgamma_native_gamma_rampsf_get, libgamma_native_gamma_rampsf_set)
+ elif depth == -2: fs = (libgamma_native_gamma_rampsd_get, libgamma_native_gamma_rampsd_set)
+ (self.__get, self.__set) = fs
+
+
+ @property
+ def size(self) -> int:
+ '''
+ Get the number of stops in the gamma ramp.
+
+ @return The number of stops in the gamma ramp.
+ '''
+ return self.__size
+
+ @size.setter
+ def size(self, value : int):
+ '''
+ It is not possible to change this attribute, but a setter is
+ required for the getter to function.
+ '''
+ raise AttributeError('cannot resize ramp')
+
+ def __len__(self) -> int:
+ '''
+ Get the number of stops in the gamma ramp.
+
+ @return The number of stops in the gamma ramp.
+ '''
+ return self.__size
+
+ def __getitem__(self, indices):
+ '''
+ Read the gamma ramp.
+
+ @param indices:slice The stops to read.
+ @return :list<int|float> The values of the read stops.
+
+ -- OR --
+
+ @param indices:int The index of the stop to read.
+ @return :int|float The value of the read stop.
+ '''
+ if isinstance(indices, slice):
+ start = indices.start
+ stop = indices.stop
+ step = indices.step
+ if start is None: start = 0
+ elif start < 0: start += self.__size
+ if stop is None: stop = self.__size
+ elif stop < 0: stop += self.__size
+ if step is None: step = 1
+ return [self.__get(self.__ramp, i) for i in range(start, stop, step)]
+ else:
+ if indices < 0:
+ indices += self.__size
+ return self.__get(self.__ramp, indices)
+
+ def __setitem__(self, indices, values):
+ '''
+ Modify the gamma ramp.
+
+ @param indices:slice The stops to modify.
+ @param values:itr<int|float> The values for the selected stops.
+
+ -- OR --
+
+ @param indices:int The index of the stop to modify.
+ @param values:int|float The new value for the stop.
+ '''
+ if isinstance(indices, slice):
+ start = indices.start
+ stop = indices.stop
+ step = indices.step
+ if start is None: start = 0
+ elif start < 0: start += self.__size
+ if stop is None: stop = self.__size
+ elif stop < 0: stop += self.__size
+ if step is None: step = 1
+ indices = list(range(start, stop, step))
+ if not len(indices) == len(values):
+ raise ValueError('cannot resize ramp')
+ for index, value in zip(indices, values):
+ self.__set(self.__ramp, index, value)
+ else:
+ if indices < 0:
+ indices += self.__size
+ self.__set(self.__ramp, indices, values)
+
+ self.red = Ramp(red, red_size, depth)
+ self.green = Ramp(green, green_size, depth)
+ self.blue = Ramp(blue, blue_size, depth)
+
+
+ def __del__(self):
+ '''
+ This function is called when the object is not longer in use.
+ '''
+ if self.__depth == 8: libgamma_native_gamma_ramps8_free(self.__ramps)
+ elif self.__depth == 16: libgamma_native_gamma_ramps16_free(self.__ramps)
+ elif self.__depth == 32: libgamma_native_gamma_ramps32_free(self.__ramps)
+ elif self.__depth == 64: libgamma_native_gamma_ramps64_free(self.__ramps)
+ elif self.__depth == -1: libgamma_native_gamma_rampsf_free(self.__ramps)
+ elif self.__depth == -2: libgamma_native_gamma_rampsd_free(self.__ramps)
+
+
+ @property
+ def size(self) -> tuple:
+ '''
+ Get the ramps' sizes.
+
+ @return :(red:int, green:int, blue:int) The size of each individual ramp.
+ '''
+ return (self.red.size, self.green.size, self.blue.size)
+
+
+ @size.setter
+ def size(self, value):
+ '''
+ It is not possible to change this attribute, but a setter is
+ required for the getter to function.
+ '''
+ raise AttributeError('cannot resize ramps')
+
+
+ @property
+ def depth(self) -> int:
+ '''
+ Get the depth of ramps.
+
+ @return :int The ramps' depth in bits and -1 for single precision floating
+ point and -2 for doublesingle precision floating point
+ '''
+ return self.__depth
+
+
+ @size.setter
+ def depth(self, value):
+ '''
+ It is not possible to change this attribute, but a setter is
+ required for the getter to function.
+ '''
+ raise AttributeError('cannot change depth')
+
diff --git a/src/libgamma_native_method.pyx b/src/libgamma_native_method.pyx
new file mode 100644
index 0000000..7e9a867
--- /dev/null
+++ b/src/libgamma_native_method.pyx
@@ -0,0 +1,652 @@
+# -*- python -*-
+'''
+pylibgamma — Python 3 wrapper for libgamma
+Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
+
+This library is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library. If not, see <http://www.gnu.org/licenses/>.
+'''
+
+cimport cython
+
+from libc.stdint cimport *
+from libc.stdlib cimport malloc
+from libc.stddef cimport size_t
+from libc.errno cimport errno
+
+
+cdef extern from "libgamma/libgamma-method.h":
+ ctypedef struct libgamma_gamma_ramps8_t:
+ # Gamma ramp structure for 8-bit gamma ramps.
+ size_t red_size
+ # The size of `red`.
+ size_t green_size
+ # The size of `green`.
+ size_t blue_size
+ # The size of `blue`.
+ uint8_t* red
+ # The gamma ramp for the red channel.
+ uint8_t* green
+ # The gamma ramp for the green channel.
+ uint8_t* blue
+ # The gamma ramp for the blue channel.
+
+ ctypedef struct libgamma_gamma_ramps16_t:
+ # Gamma ramp structure for 16-bit gamma ramps.
+ size_t red_size
+ # The size of `red`.
+ size_t green_size
+ # The size of `green`.
+ size_t blue_size
+ # The size of `blue`.
+ uint16_t* red
+ # The gamma ramp for the red channel.
+ uint16_t* green
+ # The gamma ramp for the green channel.
+ uint16_t* blue
+ # The gamma ramp for the blue channel.
+
+ ctypedef struct libgamma_gamma_ramps32_t:
+ # Gamma ramp structure for 32-bit gamma ramps.
+ size_t red_size
+ # The size of `red`.
+ size_t green_size
+ # The size of `green`.
+ size_t blue_size
+ # The size of `blue`.
+ uint32_t* red
+ # The gamma ramp for the red channel.
+ uint32_t* green
+ # The gamma ramp for the green channel.
+ uint32_t* blue
+ # The gamma ramp for the blue channel.
+
+ ctypedef struct libgamma_gamma_ramps64_t:
+ # Gamma ramp structure for 64-bit gamma ramps.
+ size_t red_size
+ # The size of `red`.
+ size_t green_size
+ # The size of `green`.
+ size_t blue_size
+ # The size of `blue`.
+ uint64_t* red
+ # The gamma ramp for the red channel.
+ uint64_t* green
+ # The gamma ramp for the green channel.
+ uint64_t* blue
+ # The gamma ramp for the blue channel.
+
+ ctypedef struct libgamma_gamma_rampsf_t:
+ # Gamma ramp structure for `float` gamma ramps.
+ size_t red_size
+ # The size of `red`.
+ size_t green_size
+ # The size of `green`.
+ size_t blue_size
+ # The size of `blue`.
+ float* red
+ # The gamma ramp for the red channel.
+ float* green
+ # The gamma ramp for the green channel.
+ float* blue
+ # The gamma ramp for the blue channel.
+
+ ctypedef struct libgamma_gamma_rampsd_t:
+ # Gamma ramp structure for `double` gamma ramps.
+ size_t red_size
+ # The size of `red`.
+ size_t green_size
+ # The size of `green`.
+ size_t blue_size
+ # The size of `blue`.
+ double* red
+ # The gamma ramp for the red channel.
+ double* green
+ # The gamma ramp for the green channel.
+ double* blue
+ # The gamma ramp for the blue channel.
+
+
+cdef extern int libgamma_gamma_ramps8_initialise(libgamma_gamma_ramps8_t* this)
+'''
+Initialise a gamma ramp in the proper way that allows all adjustment
+methods to read from and write to it without causing segmentation violation.
+
+The input must have `red_size`, `green_size` and `blue_size` set to the
+sizes of the gamma ramps that should be allocated.
+
+@param this The gamma ramps.
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+'''
+
+cdef extern void libgamma_gamma_ramps8_free(libgamma_gamma_ramps8_t* this)
+'''
+Release resources that are held by a gamma ramp strcuture that
+has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise
+initialises in the proper manner, as well as release the pointer
+to the structure.
+
+@param this The gamma ramps.
+'''
+
+
+cdef extern int libgamma_gamma_ramps16_initialise(libgamma_gamma_ramps16_t* this)
+'''
+Initialise a gamma ramp in the proper way that allows all adjustment
+methods to read from and write to it without causing segmentation violation.
+
+The input must have `red_size`, `green_size` and `blue_size` set to the
+sizes of the gamma ramps that should be allocated.
+
+@param this The gamma ramps.
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+'''
+
+cdef extern void libgamma_gamma_ramps16_free(libgamma_gamma_ramps16_t* this)
+'''
+Release resources that are held by a gamma ramp strcuture that
+has been allocated by `libgamma_gamma_ramps16_initialise` or otherwise
+initialises in the proper manner, as well as release the pointer
+to the structure.
+
+@param this The gamma ramps.
+'''
+
+
+cdef extern int libgamma_gamma_ramps32_initialise(libgamma_gamma_ramps32_t* this)
+'''
+Initialise a gamma ramp in the proper way that allows all adjustment
+methods to read from and write to it without causing segmentation violation.
+
+The input must have `red_size`, `green_size` and `blue_size` set to the
+sizes of the gamma ramps that should be allocated.
+
+@param this The gamma ramps.
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+'''
+
+cdef extern void libgamma_gamma_ramps32_free(libgamma_gamma_ramps32_t* this)
+'''
+Release resources that are held by a gamma ramp strcuture that
+has been allocated by `libgamma_gamma_ramps32_initialise` or otherwise
+initialises in the proper manner, as well as release the pointer
+to the structure.
+
+@param this The gamma ramps.
+'''
+
+
+cdef extern int libgamma_gamma_ramps64_initialise(libgamma_gamma_ramps64_t* this)
+'''
+Initialise a gamma ramp in the proper way that allows all adjustment
+methods to read from and write to it without causing segmentation violation.
+
+The input must have `red_size`, `green_size` and `blue_size` set to the
+sizes of the gamma ramps that should be allocated.
+
+@param this The gamma ramps.
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+'''
+
+cdef extern void libgamma_gamma_ramps64_free(libgamma_gamma_ramps64_t* this)
+'''
+Release resources that are held by a gamma ramp strcuture that
+has been allocated by `libgamma_gamma_ramps64_initialise` or otherwise
+initialises in the proper manner, as well as release the pointer
+to the structure.
+
+@param this The gamma ramps.
+'''
+
+
+cdef extern int libgamma_gamma_rampsf_initialise(libgamma_gamma_rampsf_t* this)
+'''
+Initialise a gamma ramp in the proper way that allows all adjustment
+methods to read from and write to it without causing segmentation violation.
+
+The input must have `red_size`, `green_size` and `blue_size` set to the
+sizes of the gamma ramps that should be allocated.
+
+@param this The gamma ramps.
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+'''
+
+cdef extern void libgamma_gamma_rampsf_free(libgamma_gamma_rampsf_t* this)
+'''
+Release resources that are held by a gamma ramp strcuture that
+has been allocated by `libgamma_gamma_rampsf_initialise` or otherwise
+initialises in the proper manner, as well as release the pointer
+to the structure.
+
+@param this The gamma ramps.
+'''
+
+
+cdef extern int libgamma_gamma_rampsd_initialise(libgamma_gamma_rampsd_t* this)
+'''
+Initialise a gamma ramp in the proper way that allows all adjustment
+methods to read from and write to it without causing segmentation violation.
+
+The input must have `red_size`, `green_size` and `blue_size` set to the
+sizes of the gamma ramps that should be allocated.
+
+@param this The gamma ramps
+@return Zero on success, -1 on allocation error, `errno` will be set accordingly.
+'''
+
+cdef extern void libgamma_gamma_rampsd_free(libgamma_gamma_rampsd_t* this)
+'''
+Release resources that are held by a gamma ramp strcuture that
+has been allocated by `libgamma_gamma_rampsd_initialise` or otherwise
+initialises in the proper manner, as well as release the pointer
+to the structure.
+
+@param this The gamma ramps.
+'''
+
+
+
+def libgamma_native_gamma_ramps8_create(red_size : int, green_size : int, blue_size : int):
+ '''
+ Create a gamma ramp in the proper way that allows all adjustment
+ methods to read from and write to it without causing segmentation violation.
+
+ @param red_size The size of the gamma ramp for the red channel
+ @param green_size The size of the gamma ramp for the green channel
+ @param blue_size The size of the gamma ramp for the blue channel
+ @return :(int){4}|int The tuple that describes the created data, `errno` on failure:
+ Element 1: The address of the gamma ramp structure
+ Element 2: The address of the gamma ramp for the red channel
+ Element 3: The address of the gamma ramp for the green channel
+ Element 4: The address of the gamma ramp for the blue channel
+ '''
+ cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps8_t))
+ cdef libgamma_gamma_ramps8_t* item = <libgamma_gamma_ramps8_t*>allocation
+ cdef size_t red, green, blue
+ if item == NULL:
+ return errno
+ red = <size_t><void*>(item.red)
+ green = <size_t><void*>(item.green)
+ blue = <size_t><void*>(item.blue)
+ return (int(<size_t>allocation), int(red), int(blue), int(blue))
+
+
+def libgamma_native_gamma_ramps8_free(this : int):
+ '''
+ Release resources that are held by a gamma ramp strcuture that
+ has been allocated by `libgamma_native_gamma_ramps8_create` or otherwise
+ created in the proper manner, as well as release the pointer
+ to the structure.
+
+ @param this The gamma ramps.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef libgamma_gamma_ramps8_t* item = <libgamma_gamma_ramps8_t*>address
+ libgamma_gamma_ramps8_free(item)
+
+
+def libgamma_native_gamma_ramps8_get(this : int, index : int) -> int:
+ '''
+ Read a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @return The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef uint8_t* ramp = <uint8_t*>address
+ return int(ramp[<size_t>index])
+
+
+def libgamma_native_gamma_ramps8_set(this : int, index : int, value : int):
+ '''
+ Modify a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @param value The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef uint8_t* ramp = <uint8_t*>address
+ ramp[<size_t>index] = <uint8_t>value
+
+
+
+def libgamma_native_gamma_ramps16_create(red_size : int, green_size : int, blue_size : int):
+ '''
+ Create a gamma ramp in the proper way that allows all adjustment
+ methods to read from and write to it without causing segmentation violation.
+
+ @param red_size The size of the gamma ramp for the red channel
+ @param green_size The size of the gamma ramp for the green channel
+ @param blue_size The size of the gamma ramp for the blue channel
+ @return :(int){4}|int The tuple that describes the created data, `errno` on failure:
+ Element 1: The address of the gamma ramp structure
+ Element 2: The address of the gamma ramp for the red channel
+ Element 3: The address of the gamma ramp for the green channel
+ Element 4: The address of the gamma ramp for the blue channel
+ '''
+ cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps16_t))
+ cdef libgamma_gamma_ramps16_t* item = <libgamma_gamma_ramps16_t*>allocation
+ cdef size_t red, green, blue
+ if item == NULL:
+ return errno
+ red = <size_t><void*>(item.red)
+ green = <size_t><void*>(item.green)
+ blue = <size_t><void*>(item.blue)
+ return (int(<size_t>allocation), int(red), int(blue), int(blue))
+
+
+def libgamma_native_gamma_ramps16_free(this : int):
+ '''
+ Release resources that are held by a gamma ramp strcuture that
+ has been allocated by `libgamma_native_gamma_ramps16_create` or otherwise
+ created in the proper manner, as well as release the pointer
+ to the structure.
+
+ @param this The gamma ramps.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef libgamma_gamma_ramps16_t* item = <libgamma_gamma_ramps16_t*>address
+ libgamma_gamma_ramps16_free(item)
+
+
+def libgamma_native_gamma_ramps16_get(this : int, index : int) -> int:
+ '''
+ Read a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @return The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef uint16_t* ramp = <uint16_t*>address
+ return int(ramp[<size_t>index])
+
+
+def libgamma_native_gamma_ramps16_set(this : int, index : int, value : int):
+ '''
+ Modify a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @param value The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef uint16_t* ramp = <uint16_t*>address
+ ramp[<size_t>index] = <uint16_t>value
+
+
+
+def libgamma_native_gamma_ramps32_create(red_size : int, green_size : int, blue_size : int):
+ '''
+ Create a gamma ramp in the proper way that allows all adjustment
+ methods to read from and write to it without causing segmentation violation.
+
+ @param red_size The size of the gamma ramp for the red channel
+ @param green_size The size of the gamma ramp for the green channel
+ @param blue_size The size of the gamma ramp for the blue channel
+ @return :(int){4}|int The tuple that describes the created data, `errno` on failure:
+ Element 1: The address of the gamma ramp structure
+ Element 2: The address of the gamma ramp for the red channel
+ Element 3: The address of the gamma ramp for the green channel
+ Element 4: The address of the gamma ramp for the blue channel
+ '''
+ cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps32_t))
+ cdef libgamma_gamma_ramps32_t* item = <libgamma_gamma_ramps32_t*>allocation
+ cdef size_t red, green, blue
+ if item == NULL:
+ return errno
+ red = <size_t><void*>(item.red)
+ green = <size_t><void*>(item.green)
+ blue = <size_t><void*>(item.blue)
+ return (int(<size_t>allocation), int(red), int(blue), int(blue))
+
+
+def libgamma_native_gamma_ramps32_free(this : int):
+ '''
+ Release resources that are held by a gamma ramp strcuture that
+ has been allocated by `libgamma_native_gamma_ramps32_create` or otherwise
+ created in the proper manner, as well as release the pointer
+ to the structure.
+
+ @param this The gamma ramps.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef libgamma_gamma_ramps32_t* item = <libgamma_gamma_ramps32_t*>address
+ libgamma_gamma_ramps32_free(item)
+
+
+def libgamma_native_gamma_ramps32_get(this : int, index : int) -> int:
+ '''
+ Read a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @return The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef uint32_t* ramp = <uint32_t*>address
+ return int(ramp[<size_t>index])
+
+
+def libgamma_native_gamma_ramps32_set(this : int, index : int, value : int):
+ '''
+ Modify a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @param value The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef uint32_t* ramp = <uint32_t*>address
+ ramp[<size_t>index] = <uint32_t>value
+
+
+
+def libgamma_native_gamma_ramps64_create(red_size : int, green_size : int, blue_size : int):
+ '''
+ Create a gamma ramp in the proper way that allows all adjustment
+ methods to read from and write to it without causing segmentation violation.
+
+ @param red_size The size of the gamma ramp for the red channel
+ @param green_size The size of the gamma ramp for the green channel
+ @param blue_size The size of the gamma ramp for the blue channel
+ @return :(int){4}|int The tuple that describes the created data, `errno` on failure:
+ Element 1: The address of the gamma ramp structure
+ Element 2: The address of the gamma ramp for the red channel
+ Element 3: The address of the gamma ramp for the green channel
+ Element 4: The address of the gamma ramp for the blue channel
+ '''
+ cdef void* allocation = malloc(sizeof(libgamma_gamma_ramps64_t))
+ cdef libgamma_gamma_ramps64_t* item = <libgamma_gamma_ramps64_t*>allocation
+ cdef size_t red, green, blue
+ if item == NULL:
+ return errno
+ red = <size_t><void*>(item.red)
+ green = <size_t><void*>(item.green)
+ blue = <size_t><void*>(item.blue)
+ return (int(<size_t>allocation), int(red), int(blue), int(blue))
+
+
+def libgamma_native_gamma_ramps64_free(this : int):
+ '''
+ Release resources that are held by a gamma ramp strcuture that
+ has been allocated by `libgamma_native_gamma_ramps64_create` or otherwise
+ created in the proper manner, as well as release the pointer
+ to the structure.
+
+ @param this The gamma ramps.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef libgamma_gamma_ramps64_t* item = <libgamma_gamma_ramps64_t*>address
+ libgamma_gamma_ramps64_free(item)
+
+
+def libgamma_native_gamma_ramps64_get(this : int, index : int) -> int:
+ '''
+ Read a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @return The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef uint64_t* ramp = <uint64_t*>address
+ return int(ramp[<size_t>index])
+
+
+def libgamma_native_gamma_ramps64_set(this : int, index : int, value : int):
+ '''
+ Modify a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @param value The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef uint64_t* ramp = <uint64_t*>address
+ ramp[<size_t>index] = <uint64_t>value
+
+
+
+def libgamma_native_gamma_rampsf_create(red_size : int, green_size : int, blue_size : int):
+ '''
+ Create a gamma ramp in the proper way that allows all adjustment
+ methods to read from and write to it without causing segmentation violation.
+
+ @param red_size The size of the gamma ramp for the red channel
+ @param green_size The size of the gamma ramp for the green channel
+ @param blue_size The size of the gamma ramp for the blue channel
+ @return :(int){4}|int The tuple that describes the created data, `errno` on failure:
+ Element 1: The address of the gamma ramp structure
+ Element 2: The address of the gamma ramp for the red channel
+ Element 3: The address of the gamma ramp for the green channel
+ Element 4: The address of the gamma ramp for the blue channel
+ '''
+ cdef void* allocation = malloc(sizeof(libgamma_gamma_rampsf_t))
+ cdef libgamma_gamma_rampsf_t* item = <libgamma_gamma_rampsf_t*>allocation
+ cdef size_t red, green, blue
+ if item == NULL:
+ return errno
+ red = <size_t><void*>(item.red)
+ green = <size_t><void*>(item.green)
+ blue = <size_t><void*>(item.blue)
+ return (int(<size_t>allocation), int(red), int(blue), int(blue))
+
+
+def libgamma_native_gamma_rampsf_free(this : int):
+ '''
+ Release resources that are held by a gamma ramp strcuture that
+ has been allocated by `libgamma_native_gamma_rampsf_create` or otherwise
+ created in the proper manner, as well as release the pointer
+ to the structure.
+
+ @param this The gamma ramps.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef libgamma_gamma_rampsf_t* item = <libgamma_gamma_rampsf_t*>address
+ libgamma_gamma_rampsf_free(item)
+
+
+def libgamma_native_gamma_rampsf_get(this : int, index : int) -> int:
+ '''
+ Read a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @return The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef float* ramp = <float*>address
+ return int(ramp[<size_t>index])
+
+
+def libgamma_native_gamma_rampsf_set(this : int, index : int, value : int):
+ '''
+ Modify a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @param value The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef float* ramp = <float*>address
+ ramp[<size_t>index] = <float>value
+
+
+
+def libgamma_native_gamma_rampsd_create(red_size : int, green_size : int, blue_size : int):
+ '''
+ Create a gamma ramp in the proper way that allows all adjustment
+ methods to read from and write to it without causing segmentation violation.
+
+ @param red_size The size of the gamma ramp for the red channel
+ @param green_size The size of the gamma ramp for the green channel
+ @param blue_size The size of the gamma ramp for the blue channel
+ @return :(int){4}|int The tuple that describes the created data, `errno` on failure:
+ Element 1: The address of the gamma ramp structure
+ Element 2: The address of the gamma ramp for the red channel
+ Element 3: The address of the gamma ramp for the green channel
+ Element 4: The address of the gamma ramp for the blue channel
+ '''
+ cdef void* allocation = malloc(sizeof(libgamma_gamma_rampsd_t))
+ cdef libgamma_gamma_rampsd_t* item = <libgamma_gamma_rampsd_t*>allocation
+ cdef size_t red, green, blue
+ if item == NULL:
+ return errno
+ red = <size_t><void*>(item.red)
+ green = <size_t><void*>(item.green)
+ blue = <size_t><void*>(item.blue)
+ return (int(<size_t>allocation), int(red), int(blue), int(blue))
+
+
+def libgamma_native_gamma_rampsd_free(this : int):
+ '''
+ Release resources that are held by a gamma ramp strcuture that
+ has been allocated by `libgamma_native_gamma_rampsd_create` or otherwise
+ created in the proper manner, as well as release the pointer
+ to the structure.
+
+ @param this The gamma ramps.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef libgamma_gamma_rampsd_t* item = <libgamma_gamma_rampsd_t*>address
+ libgamma_gamma_rampsd_free(item)
+
+
+def libgamma_native_gamma_rampsd_get(this : int, index : int) -> int:
+ '''
+ Read a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @return The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef double* ramp = <double*>address
+ return int(ramp[<size_t>index])
+
+
+def libgamma_native_gamma_rampsd_set(this : int, index : int, value : int):
+ '''
+ Modify a stop in a gamma ramp.
+
+ @param this The gamma ramp.
+ @param index The index of the gamma ramp stop.
+ @param value The value of the gamma ramp stop.
+ '''
+ cdef void* address = <void*><size_t>this
+ cdef double* ramp = <double*>address
+ ramp[<size_t>index] = <double>value
+