diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-04 03:59:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-04 03:59:42 +0400 |
commit | 49370765189d67d4c65750d9bdff12bc369bcf8f (patch) | |
tree | e5632a15da60156848fde5212801a6e8b0eacedd /source/blender/blenkernel | |
parent | a72047b197c4d5ba7c87541aa9aa2cbef97c2f9e (diff) |
bugfix [#23173] Blender crashes on selecting display color corrected image in image editor
notes,
- Use our own callback which doesnt exit() blender.
- Hard coded 'MONOSCNR.ICM' is bad, should this be a user preference or stored per image?
- imb->crect was being set to imb->rect in some cases, disable this because its possible 'rect' gets reallocated and crect becomes freed memory.
- when crect cant be created draw pink checkers, so users dont get confused if color correction isnt working. (previously would draw the uncorrected image, if it didnt crash)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/colortools.c | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 11801557c99..4b694ada7fb 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -782,34 +782,53 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float *vecout, const vecout[2]= curvemap_evaluateF(cumap->cm+2, fac); } + +#ifdef WITH_LCMS +/* basic error handler, if we dont do this blender will exit */ +static int ErrorReportingFunction(int ErrorCode, const char *ErrorText) +{ + fprintf(stderr, "%s:%d\n", ErrorText, ErrorCode); + return 1; +} +#endif + void colorcorrection_do_ibuf(ImBuf *ibuf, const char *profile) { +#ifdef WITH_LCMS if (ibuf->crect == NULL) { -#ifdef WITH_LCMS - cmsHPROFILE imageProfile, proofingProfile; - cmsHTRANSFORM hTransform; + cmsHPROFILE proofingProfile; - ibuf->crect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(int), "imbuf crect"); - - imageProfile = cmsCreate_sRGBProfile(); - proofingProfile = cmsOpenProfileFromFile(profile, "r"); + /* TODO, move to initialization area of code */ + //cmsSetLogErrorHandler(ErrorReportingFunction); + cmsSetErrorHandler(ErrorReportingFunction); + /* will return NULL if the file isn't fount */ + 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; + + if(proofingProfile) { + cmsHPROFILE imageProfile; + cmsHTRANSFORM hTransform; + + ibuf->crect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(int), "imbuf crect"); + + imageProfile = cmsCreate_sRGBProfile(); + + + 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); + } #endif } } |