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 /source/blender/blenkernel/intern/colortools.c
parent94a03557954ee2c8a4b5c45f8a4577640b099e73 (diff)
image sample line now updates with the compositor changes (mango request)
Diffstat (limited to 'source/blender/blenkernel/intern/colortools.c')
-rw-r--r--source/blender/blenkernel/intern/colortools.c56
1 files changed, 56 insertions, 0 deletions
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;