diff options
author | Martin Poirier <theeth@yahoo.com> | 2009-05-17 20:19:13 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2009-05-17 20:19:13 +0400 |
commit | 7eeb8ac01cea69fc8dbf3e4a58179b1026fc6198 (patch) | |
tree | bb1fda3f9be548369ebaa8742ba0129080257bb8 /source/blender/blenkernel/intern/colortools.c | |
parent | 351086dbb83fa42d393a8a4f64287c2b90e23d97 (diff) |
Color proofing support with lcms (http://www.littlecms.com/).
Enable with WITH_LCMS (options have been added for scons).
lcms is very common on linux package managers, so no need to add in extern (IMHO). Libs for windows can be added to /lib
Code is mostly a proof of concept with hardcoded path for icc profile (taken from the lcms test suite).
Adding this now to svn so it doesn't rot on my hard drive. People interested in pushing it forward should feel free to dig in the code or poke me about it.
Diffstat (limited to 'source/blender/blenkernel/intern/colortools.c')
-rw-r--r-- | source/blender/blenkernel/intern/colortools.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 1bc34aea9a1..e8716aba296 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -32,6 +32,10 @@ #include <stdlib.h> #include <float.h> +#ifdef WITH_LCMS +#include <lcms.h> +#endif + #include "MEM_guardedalloc.h" #include "DNA_color_types.h" @@ -650,6 +654,38 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float *vecout, const vecout[2]= curvemap_evaluateF(cumap->cm+2, fac); } +void colorcorrection_do_ibuf(ImBuf *ibuf, const char *profile) +{ + if (ibuf->crect == NULL) + { +#ifdef WITH_LCMS + cmsHPROFILE imageProfile, proofingProfile; + cmsHTRANSFORM hTransform; + + ibuf->crect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(int), "imbuf crect"); + + imageProfile = cmsCreate_sRGBProfile(); + proofingProfile = cmsOpenProfileFromFile(profile, "r"); + + cmsErrorAction(LCMS_ERROR_SHOW); + + hTransform = cmsCreateProofingTransform(imageProfile, TYPE_RGBA_8, imageProfile, TYPE_RGBA_8, + proofingProfile, + INTENT_ABSOLUTE_COLORIMETRIC, + INTENT_ABSOLUTE_COLORIMETRIC, + cmsFLAGS_SOFTPROOFING); + + cmsDoTransform(hTransform, ibuf->rect, ibuf->crect, ibuf->x * ibuf->y); + + cmsDeleteTransform(hTransform); + cmsCloseProfile(imageProfile); + cmsCloseProfile(proofingProfile); +#else + ibuf->crect = ibuf->rect; +#endif + } +} + void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) { |