HDR color picker now works in the clip space.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user