[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47855] trunk/blender/source/blender: image sample line now updates with the compositor changes (mango request)

Campbell Barton ideasman42 at gmail.com
Thu Jun 14 00:38:46 CEST 2012


Revision: 47855
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47855
Author:   campbellbarton
Date:     2012-06-13 22:38:31 +0000 (Wed, 13 Jun 2012)
Log Message:
-----------
image sample line now updates with the compositor changes (mango request)

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_colortools.h
    trunk/blender/source/blender/blenkernel/intern/colortools.c
    trunk/blender/source/blender/editors/space_image/image_ops.c
    trunk/blender/source/blender/editors/space_image/space_image.c

Modified: trunk/blender/source/blender/blenkernel/BKE_colortools.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_colortools.h	2012-06-13 21:58:40 UTC (rev 47854)
+++ trunk/blender/source/blender/blenkernel/BKE_colortools.h	2012-06-13 22:38:31 UTC (rev 47855)
@@ -35,6 +35,7 @@
 struct CurveMap;
 struct CurveMapPoint;
 struct Scopes;
+struct Histogram;
 struct ImBuf;
 struct rctf;
 
@@ -74,7 +75,7 @@
 int                 curvemapping_RGBA_does_something(struct CurveMapping *cumap);
 void                curvemapping_initialize(struct CurveMapping *cumap);
 void                curvemapping_table_RGBA(struct CurveMapping *cumap, float **array, int *size);
-
+void                BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const short use_color_management);
 void                scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, int use_color_management);
 void                scopes_free(struct Scopes *scopes);
 void                scopes_new(struct Scopes *scopes);

Modified: trunk/blender/source/blender/blenkernel/intern/colortools.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/colortools.c	2012-06-13 21:58:40 UTC (rev 47854)
+++ trunk/blender/source/blender/blenkernel/intern/colortools.c	2012-06-13 22:38:31 UTC (rev 47855)
@@ -946,6 +946,62 @@
 	}
 }
 
+void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short use_color_management)
+{
+	int i, x, y;
+	float *fp;
+	float rgb[3];
+	unsigned char *cp;
+
+	int x1 = 0.5f + hist->co[0][0] * ibuf->x;
+	int x2 = 0.5f + hist->co[1][0] * ibuf->x;
+	int y1 = 0.5f + hist->co[0][1] * ibuf->y;
+	int y2 = 0.5f + hist->co[1][1] * ibuf->y;
+
+	hist->channels = 3;
+	hist->x_resolution = 256;
+	hist->xmax = 1.0f;
+	hist->ymax = 1.0f;
+
+	if (ibuf->rect == NULL && ibuf->rect_float == NULL) return;
+
+	/* persistent draw */
+	hist->flag |= HISTO_FLAG_SAMPLELINE; /* keep drawing the flag after */
+
+	for (i = 0; i < 256; i++) {
+		x = (int)(0.5f + x1 + (float)i * (x2 - x1) / 255.0f);
+		y = (int)(0.5f + y1 + (float)i * (y2 - y1) / 255.0f);
+
+		if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
+			hist->data_luma[i] = hist->data_r[i] = hist->data_g[i] = hist->data_b[i] = hist->data_a[i] = 0.0f;
+		}
+		else {
+			if (ibuf->rect_float) {
+				fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
+
+				if (use_color_management)
+					linearrgb_to_srgb_v3_v3(rgb, fp);
+				else
+					copy_v3_v3(rgb, fp);
+
+				hist->data_luma[i]  = rgb_to_luma(rgb);
+				hist->data_r[i]     = rgb[0];
+				hist->data_g[i]     = rgb[1];
+				hist->data_b[i]     = rgb[2];
+				hist->data_a[i]     = fp[3];
+			}
+			else if (ibuf->rect) {
+				cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+				hist->data_luma[i]  = (float)rgb_to_luma_byte(cp) / 255.0f;
+				hist->data_r[i]     = (float)cp[0] / 255.0f;
+				hist->data_g[i]     = (float)cp[1] / 255.0f;
+				hist->data_b[i]     = (float)cp[2] / 255.0f;
+				hist->data_a[i]     = (float)cp[3] / 255.0f;
+			}
+		}
+	}
+}
+
 void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
 {
 	int x, y, c;

Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c	2012-06-13 21:58:40 UTC (rev 47854)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c	2012-06-13 22:38:31 UTC (rev 47855)
@@ -2110,11 +2110,6 @@
 	Histogram *hist = &sima->sample_line_hist;
 	
 	float x1f, y1f, x2f, y2f;
-	int x1, y1, x2, y2;
-	int i, x, y;
-	float *fp;
-	float rgb[3];
-	unsigned char *cp;
 	
 	if (ibuf == NULL) {
 		ED_space_image_release_buffer(sima, lock);
@@ -2128,55 +2123,13 @@
 	
 	UI_view2d_region_to_view(&ar->v2d, x_start, y_start, &x1f, &y1f);
 	UI_view2d_region_to_view(&ar->v2d, x_end, y_end, &x2f, &y2f);
-	x1 = 0.5f + x1f * ibuf->x;
-	x2 = 0.5f + x2f * ibuf->x;
-	y1 = 0.5f + y1f * ibuf->y;
-	y2 = 0.5f + y2f * ibuf->y;
-	
-	hist->channels = 3;
-	hist->x_resolution = 256;
-	hist->xmax = 1.0f;
-	hist->ymax = 1.0f;
 
-	/* persistent draw */
 	hist->co[0][0] = x1f;
 	hist->co[0][1] = y1f;
 	hist->co[1][0] = x2f;
 	hist->co[1][1] = y2f;
-	hist->flag |= HISTO_FLAG_SAMPLELINE; /* keep drawing the flag after */
 
-	for (i = 0; i < 256; i++) {
-		x = (int)(0.5f + x1 + (float)i * (x2 - x1) / 255.0f);
-		y = (int)(0.5f + y1 + (float)i * (y2 - y1) / 255.0f);
-		
-		if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
-			hist->data_luma[i] = hist->data_r[i] = hist->data_g[i] = hist->data_b[i] = hist->data_a[i] = 0.0f;
-		}
-		else {
-			if (ibuf->rect_float) {
-				fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
-
-				if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
-					linearrgb_to_srgb_v3_v3(rgb, fp);
-				else
-					copy_v3_v3(rgb, fp);
-
-				hist->data_luma[i]  = rgb_to_luma(rgb);
-				hist->data_r[i]     = rgb[0];
-				hist->data_g[i]     = rgb[1];
-				hist->data_b[i]     = rgb[2];
-				hist->data_a[i]     = fp[3];
-			}
-			else if (ibuf->rect) {
-				cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
-				hist->data_luma[i]  = (float)rgb_to_luma_byte(cp) / 255.0f;
-				hist->data_r[i]     = (float)cp[0] / 255.0f;
-				hist->data_g[i]     = (float)cp[1] / 255.0f;
-				hist->data_b[i]     = (float)cp[2] / 255.0f;
-				hist->data_a[i]     = (float)cp[3] / 255.0f;
-			}
-		}
-	}
+	BKE_histogram_update_sample_line(hist, ibuf, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0);
 	
 	ED_space_image_release_buffer(sima, lock);
 	

Modified: trunk/blender/source/blender/editors/space_image/space_image.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/space_image.c	2012-06-13 21:58:40 UTC (rev 47854)
+++ trunk/blender/source/blender/editors/space_image/space_image.c	2012-06-13 22:38:31 UTC (rev 47855)
@@ -914,6 +914,9 @@
 	void *lock;
 	ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
 	if (ibuf) {
+		if (!sima->scopes.ok) {
+			BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+		}
 		scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
 	}
 	ED_space_image_release_buffer(sima, lock);




More information about the Bf-blender-cvs mailing list