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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-14 02:38:31 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-14 02:38:31 +0400
commitfd212cd4bc1e82ad8b61f54ec75d09747f7a9536 (patch)
tree94b832e2f354fbf34a16389916479ddeabddea35
parent94a03557954ee2c8a4b5c45f8a4577640b099e73 (diff)
image sample line now updates with the compositor changes (mango request)
-rw-r--r--source/blender/blenkernel/BKE_colortools.h3
-rw-r--r--source/blender/blenkernel/intern/colortools.c56
-rw-r--r--source/blender/editors/space_image/image_ops.c49
-rw-r--r--source/blender/editors/space_image/space_image.c3
4 files changed, 62 insertions, 49 deletions
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h
index d67e1a9118e..f58af8f39a0 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -35,6 +35,7 @@ struct CurveMapping;
struct CurveMap;
struct CurveMapPoint;
struct Scopes;
+struct Histogram;
struct ImBuf;
struct rctf;
@@ -74,7 +75,7 @@ void curvemapping_premultiply(struct CurveMapping *cumap, int res
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);
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 12dee600532..6879ec506f0 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -946,6 +946,62 @@ static void save_sample_line(Scopes *scopes, const int idx, const float fx, cons
}
}
+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;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 97f3bd744dc..7e67e737cc2 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2110,11 +2110,6 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
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 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
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);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 6652a7470c2..32e6f588e27 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -914,6 +914,9 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar)
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);