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-20 20:56:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-20 20:56:11 +0400
commitff876a473aa030a7308560c69c2b6fd4bb7e77a4 (patch)
tree35cb24c8b548c8eefb36c821cc6b46680805300b /source/blender
parent5e78327b92f0acacd5e77485daa036b40c9ababa (diff)
HDR color picker now works in the clip space.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/include/ED_clip.h2
-rw-r--r--source/blender/editors/interface/interface_ops.c14
-rw-r--r--source/blender/editors/space_clip/clip_editor.c48
3 files changed, 63 insertions, 1 deletions
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h
index 3a1d63574a6..13c3b180230 100644
--- a/source/blender/editors/include/ED_clip.h
+++ b/source/blender/editors/include/ED_clip.h
@@ -62,6 +62,8 @@ int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc);
struct ImBuf *ED_space_clip_get_buffer(struct SpaceClip *sc);
struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle);
+int ED_space_clip_color_sample(struct SpaceClip *sc, struct ARegion *ar, int mval[2], float r_col[3]);
+
void ED_clip_update_frame(const struct Main *mainp, int cfra);
int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 802000567da..d3b81974479 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -27,7 +27,6 @@
* \ingroup edinterface
*/
-
#include <stdio.h>
#include <math.h>
#include <string.h>
@@ -71,6 +70,7 @@
#include "ED_image.h" /* for HDR color sampling */
#include "ED_node.h" /* for HDR color sampling */
+#include "ED_clip.h" /* for HDR color sampling */
/* ********************************************************** */
@@ -165,6 +165,18 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int
}
}
}
+ else if (sa->spacetype == SPACE_CLIP) {
+ ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if (BLI_in_rcti(&ar->winrct, mx, my)) {
+ SpaceClip *sc = sa->spacedata.first;
+ int mval[2] = {mx - ar->winrct.xmin,
+ my - ar->winrct.ymin};
+
+ if (ED_space_clip_color_sample(sc, ar, mval, r_col)) {
+ return;
+ }
+ }
+ }
}
}
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 5e4ef1aa24a..5b4849a425f 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -247,6 +247,54 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale
return NULL;
}
+/* returns color in SRGB */
+/* matching ED_space_image_color_sample() */
+int ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r_col[3])
+{
+ ImBuf *ibuf;
+ float fx, fy, co[2];
+ int ret = FALSE;
+
+ ibuf = ED_space_clip_get_buffer(sc);
+ if (!ibuf) {
+ return FALSE;
+ }
+
+ /* map the mouse coords to the backdrop image space */
+ ED_clip_mouse_pos(sc, ar, mval, co);
+
+ fx = co[0];
+ fy = co[1];
+
+ 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));
+ /* IB_PROFILE_NONE is default but infact its linear */
+ if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) {
+ 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);
+ rgb_uchar_to_float(r_col, cp);
+ ret = TRUE;
+ }
+ }
+
+ return ret;
+}
+
void ED_clip_update_frame(const Main *mainp, int cfra)
{
wmWindowManager *wm;