Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-08-04 03:59:42 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-08-04 03:59:42 +0400
commit49370765189d67d4c65750d9bdff12bc369bcf8f (patch)
treee5632a15da60156848fde5212801a6e8b0eacedd /source
parenta72047b197c4d5ba7c87541aa9aa2cbef97c2f9e (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')
-rw-r--r--source/blender/blenkernel/intern/colortools.c61
-rw-r--r--source/blender/editors/space_image/image_draw.c25
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c2
3 files changed, 58 insertions, 30 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
}
}
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 28616f08555..187e21a8702 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -215,7 +215,7 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy)
glEnd();
}
-static void sima_draw_alpha_backdrop(float x1, float y1, float xsize, float ysize, float zoomx, float zoomy)
+static void sima_draw_alpha_backdrop(float x1, float y1, float xsize, float ysize, float zoomx, float zoomy, unsigned char col1[3], unsigned char col2[3])
{
GLubyte checker_stipple[32*32/8] =
{
@@ -229,9 +229,9 @@ static void sima_draw_alpha_backdrop(float x1, float y1, float xsize, float ysiz
0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, \
};
- glColor3ub(100, 100, 100);
+ glColor3ubv(col1);
glRectf(x1, y1, x1 + zoomx*xsize, y1 + zoomy*ysize);
- glColor3ub(160, 160, 160);
+ glColor3ubv(col2);
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(checker_stipple);
@@ -271,11 +271,16 @@ static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, fl
}
#ifdef WITH_LCMS
-static void sima_draw_colorcorrected_pixels(float x1, float y1, ImBuf *ibuf)
+static int sima_draw_colorcorrected_pixels(float x1, float y1, ImBuf *ibuf)
{
colorcorrection_do_ibuf(ibuf, "MONOSCNR.ICM"); /* path is hardcoded here, find some place better */
-
- glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->crect);
+
+ if(ibuf->crect) {
+ glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->crect);
+ return 1;
+ }
+
+ return 0;
}
#endif
@@ -361,13 +366,17 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image
else if(sima->flag & SI_COLOR_CORRECTION) {
image_verify_buffer_float(sima, ima, ibuf, color_manage);
- sima_draw_colorcorrected_pixels(x, y, ibuf);
+ if(sima_draw_colorcorrected_pixels(x, y, ibuf)==0) {
+ unsigned char col1[3]= {100, 0, 100}, col2[3]= {160, 0, 160}; /* pink says 'warning' in blender land */
+ sima_draw_alpha_backdrop(x, y, ibuf->x, ibuf->y, zoomx, zoomy, col1, col2);
+ }
}
#endif
else {
if(sima->flag & SI_USE_ALPHA) {
- sima_draw_alpha_backdrop(x, y, ibuf->x, ibuf->y, zoomx, zoomy);
+ unsigned char col1[3]= {100, 100, 100}, col2[3]= {160, 160, 160};
+ sima_draw_alpha_backdrop(x, y, ibuf->x, ibuf->y, zoomx, zoomy, col1, col2);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 606913dd590..8e00c7c7cf1 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -77,7 +77,7 @@ void imb_freerectImBuf(ImBuf *ibuf)
{
if(ibuf==NULL) return;
- if(ibuf->crect && ibuf->crect != ibuf->rect)
+ if(ibuf->crect)
MEM_freeN(ibuf->crect);
if(ibuf->rect && (ibuf->mall & IB_rect))