aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/libgamma-method.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-08-28 15:32:01 +0200
committerMattias Andrée <maandree@operamail.com>2014-08-28 15:32:01 +0200
commit5a9b82bc5b9c5973ac9bda6c0ec4701c7fb88271 (patch)
tree20524d8a1fd61ef466b792e335434727fa352016 /src/lib/libgamma-method.c
parentinfo: ramps => ramps16 (diff)
downloadlibgamma-5a9b82bc5b9c5973ac9bda6c0ec4701c7fb88271.tar.gz
libgamma-5a9b82bc5b9c5973ac9bda6c0ec4701c7fb88271.tar.bz2
libgamma-5a9b82bc5b9c5973ac9bda6c0ec4701c7fb88271.tar.xz
add 8-bit ramps (good for software gamma)
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/lib/libgamma-method.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/lib/libgamma-method.c b/src/lib/libgamma-method.c
index 7311de4..0fa76c3 100644
--- a/src/lib/libgamma-method.c
+++ b/src/lib/libgamma-method.c
@@ -34,6 +34,55 @@
* @param this The gamma ramps.
* @return Zero on success, -1 on allocation error, `errno` will be set accordingly.
*/
+int libgamma_gamma_ramps8_initialise(libgamma_gamma_ramps8_t* restrict this)
+{
+ size_t n = this->red_size + this->green_size + this->blue_size;
+ this->red = malloc(n * sizeof(uint8_t));
+ this->green = this-> red + this-> red_size;
+ this->blue = this->green + this->green_size;
+ return this->red == NULL ? -1 : 0;
+}
+
+
+/**
+ * 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.
+ *
+ * @param this The gamma ramps.
+ */
+void libgamma_gamma_ramps8_destroy(libgamma_gamma_ramps8_t* restrict this)
+{
+ free(this->red);
+}
+
+
+/**
+ * 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.
+ */
+void libgamma_gamma_ramps8_free(libgamma_gamma_ramps8_t* restrict this)
+{
+ free(this->red);
+ free(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.
+ */
int libgamma_gamma_ramps16_initialise(libgamma_gamma_ramps16_t* restrict this)
{
size_t n = this->red_size + this->green_size + this->blue_size;