[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31024] trunk/blender/source/blender: bugfix [#23173] Blender crashes on selecting display color corrected image in image editor
Campbell Barton
ideasman42 at gmail.com
Wed Aug 4 01:59:42 CEST 2010
Revision: 31024
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31024
Author: campbellbarton
Date: 2010-08-04 01:59:42 +0200 (Wed, 04 Aug 2010)
Log Message:
-----------
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)
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/colortools.c
trunk/blender/source/blender/editors/space_image/image_draw.c
trunk/blender/source/blender/imbuf/intern/allocimbuf.c
Modified: trunk/blender/source/blender/blenkernel/intern/colortools.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/colortools.c 2010-08-03 23:57:39 UTC (rev 31023)
+++ trunk/blender/source/blender/blenkernel/intern/colortools.c 2010-08-03 23:59:42 UTC (rev 31024)
@@ -782,34 +782,53 @@
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");
+ /* TODO, move to initialization area of code */
+ //cmsSetLogErrorHandler(ErrorReportingFunction);
+ cmsSetErrorHandler(ErrorReportingFunction);
+
+ /* will return NULL if the file isn't fount */
+ proofingProfile = cmsOpenProfileFromFile(profile, "r");
- imageProfile = cmsCreate_sRGBProfile();
- proofingProfile = cmsOpenProfileFromFile(profile, "r");
+ cmsErrorAction(LCMS_ERROR_SHOW);
+
+ 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);
- 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;
+ cmsDoTransform(hTransform, ibuf->rect, ibuf->crect, ibuf->x * ibuf->y);
+
+ cmsDeleteTransform(hTransform);
+ cmsCloseProfile(imageProfile);
+ cmsCloseProfile(proofingProfile);
+ }
#endif
}
}
Modified: trunk/blender/source/blender/editors/space_image/image_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_draw.c 2010-08-03 23:57:39 UTC (rev 31023)
+++ trunk/blender/source/blender/editors/space_image/image_draw.c 2010-08-03 23:59:42 UTC (rev 31024)
@@ -215,7 +215,7 @@
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 @@
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 @@
}
#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 @@
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);
Modified: trunk/blender/source/blender/imbuf/intern/allocimbuf.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/allocimbuf.c 2010-08-03 23:57:39 UTC (rev 31023)
+++ trunk/blender/source/blender/imbuf/intern/allocimbuf.c 2010-08-03 23:59:42 UTC (rev 31024)
@@ -77,7 +77,7 @@
{
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))
More information about the Bf-blender-cvs
mailing list