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-08-16 18:47:14 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-16 18:47:14 +0400
commit81dd80f1d3da6db3227abafe431ac0e92c4e7197 (patch)
tree6130beb4db65bb8bf7bc5872ce565d4de9e45e16 /source/blender/editors/space_image
parent6fb4bbdbd963eb0f9626d6bd784b22c65bd5cd44 (diff)
support fro HDR color picking (values over 1.0) when color picking in the image editor or node space.
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r--source/blender/editors/space_image/image_ops.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index b2a9584b243..30480bd095f 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1948,6 +1948,54 @@ static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_
}
}
+/* returns color in SRGB */
+/* matching ED_space_node_color_sample() */
+int ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], float r_col[3])
+{
+ void *lock;
+ ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
+ float fx, fy;
+ int ret = FALSE;
+
+ if (ibuf == NULL) {
+ ED_space_image_release_buffer(sima, lock);
+ return FALSE;
+ }
+
+ UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &fx, &fy);
+
+ if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
+ float *fp;
+ unsigned char *cp;
+ int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
+
+ CLAMP(x, 0, ibuf->x - 1);
+ CLAMP(y, 0, ibuf->y - 1);
+
+ if (ibuf->rect_float) {
+ fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
+
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB) {
+ linearrgb_to_srgb_v3_v3(r_col, fp);
+ }
+ else {
+ copy_v3_v3(r_col, fp);
+ }
+ ret = TRUE;
+ }
+ else if (ibuf->rect) {
+ cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+ r_col[0] = cp[0] / 255.0f;
+ r_col[1] = cp[1] / 255.0f;
+ r_col[2] = cp[2] / 255.0f;
+ ret = TRUE;
+ }
+ }
+
+ ED_space_image_release_buffer(sima, lock);
+ return ret;
+}
+
static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima = CTX_wm_space_image(C);