From ae6072ece6ac02a0d2438d110af90cf6ca2f3f50 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 3 Sep 2014 19:12:59 +0200 Subject: gamma ramps and exception class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libgamma-facade.cc | 291 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 287 insertions(+), 4 deletions(-) (limited to 'src/libgamma-facade.cc') diff --git a/src/libgamma-facade.cc b/src/libgamma-facade.cc index 4937e78..bd6ee28 100644 --- a/src/libgamma-facade.cc +++ b/src/libgamma-facade.cc @@ -17,6 +17,8 @@ */ #include "libgamma-facade.hh" +#include "libgamma-error.hh" + #include @@ -55,7 +57,6 @@ namespace libgamma return rc; } - /** * Check whether an adjustment method is available, non-existing (invalid) methods will be * identified as not available under the rationale that the library may be out of date. @@ -68,7 +69,6 @@ namespace libgamma return libgamma_is_method_available(method); } - /** * Return the capabilities of an adjustment method. * @@ -82,7 +82,6 @@ namespace libgamma *output = MethodCapabilities(&caps); } - /** * Return the default site for an adjustment method. * @@ -98,7 +97,6 @@ namespace libgamma return new std::string(cstr); } - /** * Return the default variable that determines * the default site for an adjustment method. @@ -117,6 +115,7 @@ namespace libgamma return new std::string(cstr); } + /** * Convert a raw representation of an EDID to a lowercase hexadecimal representation. * @@ -172,5 +171,289 @@ namespace libgamma return libgamma_unhex_edid(cstr); } + + /** + * Initialise a gamma ramp in the proper way that allows all adjustment + * methods to read from and write to it without causing segmentation violation. + * + * @param ramps The gamma ramp to initialise. + * @param red The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + */ + void gamma_ramps8_initialise(GammaRamps* ramps, size_t red, size_t blue, size_t green) + { + libgamma_gamma_ramps8_t native; + int r; + native.red_size = ramps->red.size = red; + native.green_size = ramps->green.size = green; + native.blue_size = ramps->blue.size = blue; + ramps->depth = 8; + r = libgamma_gamma_ramps8_initialise(&native); + if (r != 0) + throw create_error(r); + ramps->red.ramp = native.red; + ramps->green.ramp = native.green; + ramps->blue.ramp = native.blue; + } + + /** + * Initialise a gamma ramp in the proper way that allows all adjustment + * methods to read from and write to it without causing segmentation violation. + * + * @param ramps The gamma ramp to initialise. + * @param red The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + */ + void gamma_ramps16_initialise(GammaRamps* ramps, size_t red, size_t blue, size_t green) + { + libgamma_gamma_ramps16_t native; + int r; + native.red_size = ramps->red.size = red; + native.green_size = ramps->green.size = green; + native.blue_size = ramps->blue.size = blue; + ramps->depth = 16; + r = libgamma_gamma_ramps16_initialise(&native); + if (r != 0) + throw create_error(r); + ramps->red.ramp = native.red; + ramps->green.ramp = native.green; + ramps->blue.ramp = native.blue; + } + + /** + * Initialise a gamma ramp in the proper way that allows all adjustment + * methods to read from and write to it without causing segmentation violation. + * + * @param ramps The gamma ramp to initialise. + * @param red The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + */ + void gamma_ramps32_initialise(GammaRamps* ramps, size_t red, size_t blue, size_t green) + { + libgamma_gamma_ramps32_t native; + int r; + native.red_size = ramps->red.size = red; + native.green_size = ramps->green.size = green; + native.blue_size = ramps->blue.size = blue; + ramps->depth = 32; + r = libgamma_gamma_ramps32_initialise(&native); + if (r != 0) + throw create_error(r); + ramps->red.ramp = native.red; + ramps->green.ramp = native.green; + ramps->blue.ramp = native.blue; + } + + /** + * Initialise a gamma ramp in the proper way that allows all adjustment + * methods to read from and write to it without causing segmentation violation. + * + * @param ramps The gamma ramp to initialise. + * @param red The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + */ + void gamma_ramps64_initialise(GammaRamps* ramps, size_t red, size_t blue, size_t green) + { + libgamma_gamma_ramps64_t native; + int r; + native.red_size = ramps->red.size = red; + native.green_size = ramps->green.size = green; + native.blue_size = ramps->blue.size = blue; + ramps->depth = 64; + r = libgamma_gamma_ramps64_initialise(&native); + if (r != 0) + throw create_error(r); + ramps->red.ramp = native.red; + ramps->green.ramp = native.green; + ramps->blue.ramp = native.blue; + } + + /** + * Initialise a gamma ramp in the proper way that allows all adjustment + * methods to read from and write to it without causing segmentation violation. + * + * @param ramps The gamma ramp to initialise. + * @param red The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + */ + void gamma_rampsf_initialise(GammaRamps* ramps, size_t red, size_t blue, size_t green) + { + libgamma_gamma_rampsf_t native; + int r; + native.red_size = ramps->red.size = red; + native.green_size = ramps->green.size = green; + native.blue_size = ramps->blue.size = blue; + ramps->depth = -1; + r = libgamma_gamma_rampsf_initialise(&native); + if (r != 0) + throw create_error(r); + ramps->red.ramp = native.red; + ramps->green.ramp = native.green; + ramps->blue.ramp = native.blue; + } + + /** + * Initialise a gamma ramp in the proper way that allows all adjustment + * methods to read from and write to it without causing segmentation violation. + * + * @param ramps The gamma ramp to initialise. + * @param red The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + */ + void gamma_rampsd_initialise(GammaRamps* ramps, size_t red, size_t blue, size_t green) + { + libgamma_gamma_rampsd_t native; + int r; + native.red_size = ramps->red.size = red; + native.green_size = ramps->green.size = green; + native.blue_size = ramps->blue.size = blue; + ramps->depth = -2; + r = libgamma_gamma_rampsd_initialise(&native); + if (r != 0) + throw create_error(r); + ramps->red.ramp = native.red; + ramps->green.ramp = native.green; + ramps->blue.ramp = native.blue; + } + + + /** + * 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 The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + * @return The gamma ramp. + */ + GammaRamps* gamma_ramps8_create(size_t red, size_t blue, size_t green) + { + libgamma_gamma_ramps8_t ramps; + int r; + ramps.red_size = red; + ramps.green_size = green; + ramps.blue_size = blue; + r = libgamma_gamma_ramps8_initialise(&ramps); + if (r != 0) + throw create_error(r); + return new GammaRamps(ramps.red, ramps.green, ramps.blue, red, green, blue, 8); + } + + /** + * 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 The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + * @return The gamma ramp. + */ + GammaRamps* gamma_ramps16_create(size_t red, size_t blue, size_t green) + { + libgamma_gamma_ramps16_t ramps; + int r; + ramps.red_size = red; + ramps.green_size = green; + ramps.blue_size = blue; + r = libgamma_gamma_ramps16_initialise(&ramps); + if (r != 0) + throw create_error(r); + return new GammaRamps(ramps.red, ramps.green, ramps.blue, red, green, blue, 16); + } + + /** + * 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 The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + * @return The gamma ramp. + */ + GammaRamps* gamma_ramps32_create(size_t red, size_t blue, size_t green) + { + libgamma_gamma_ramps32_t ramps; + int r; + ramps.red_size = red; + ramps.green_size = green; + ramps.blue_size = blue; + r = libgamma_gamma_ramps32_initialise(&ramps); + if (r != 0) + throw create_error(r); + return new GammaRamps(ramps.red, ramps.green, ramps.blue, red, green, blue, 32); + } + + /** + * 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 The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + * @return The gamma ramp. + */ + GammaRamps* gamma_ramps64_create(size_t red, size_t blue, size_t green) + { + libgamma_gamma_ramps64_t ramps; + int r; + ramps.red_size = red; + ramps.green_size = green; + ramps.blue_size = blue; + r = libgamma_gamma_ramps64_initialise(&ramps); + if (r != 0) + throw create_error(r); + return new GammaRamps(ramps.red, ramps.green, ramps.blue, red, green, blue, 64); + } + + /** + * 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 The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + * @return The gamma ramp. + */ + GammaRamps* gamma_rampsf_create(size_t red, size_t blue, size_t green) + { + libgamma_gamma_rampsf_t ramps; + int r; + ramps.red_size = red; + ramps.green_size = green; + ramps.blue_size = blue; + r = libgamma_gamma_rampsf_initialise(&ramps); + if (r != 0) + throw create_error(r); + return new GammaRamps(ramps.red, ramps.green, ramps.blue, red, green, blue, -1); + } + + /** + * 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 The size of the gamma ramp for the red channel. + * @param green The size of the gamma ramp for the green channel. + * @param blue The size of the gamma ramp for the blue channel. + * @return The gamma ramp. + */ + GammaRamps* gamma_rampsd_create(size_t red, size_t blue, size_t green) + { + libgamma_gamma_rampsd_t ramps; + int r; + ramps.red_size = red; + ramps.green_size = green; + ramps.blue_size = blue; + r = libgamma_gamma_rampsd_initialise(&ramps); + if (r != 0) + throw create_error(r); + return new GammaRamps(ramps.red, ramps.green, ramps.blue, red, green, blue, -2); + } + } -- cgit v1.2.3-70-g09d2