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:
authorDaniel Genrich <daniel.genrich@gmx.net>2012-08-26 17:34:17 +0400
committerDaniel Genrich <daniel.genrich@gmx.net>2012-08-26 17:34:17 +0400
commitb61abd4fe0da70ce52acf29c065df2af68e2eabe (patch)
tree67eb2668ca92240580a62f4358f7bc464c938b2e /source/blender/editors/space_image/image_ops.c
parent43bb431548436b6b1699f795acd107de0f6b86a8 (diff)
parent25a925ceabb9987c0204df32200b664dcc1aaf44 (diff)
Merge from trunk r49908-r50219smoke2
Diffstat (limited to 'source/blender/editors/space_image/image_ops.c')
-rw-r--r--source/blender/editors/space_image/image_ops.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index b2a9584b243..3d6b316b743 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -98,9 +98,9 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat
if ((width < 4) && (height < 4))
sima->zoom = oldzoom;
- else if ((ar->winrct.xmax - ar->winrct.xmin) <= sima->zoom)
+ else if (BLI_RCT_SIZE_X(&ar->winrct) <= sima->zoom)
sima->zoom = oldzoom;
- else if ((ar->winrct.ymax - ar->winrct.ymin) <= sima->zoom)
+ else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sima->zoom)
sima->zoom = oldzoom;
}
@@ -581,8 +581,8 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op))
h = height * aspy;
/* check if the image will fit in the image with (zoom == 1) */
- width = ar->winrct.xmax - ar->winrct.xmin + 1;
- height = ar->winrct.ymax - ar->winrct.ymin + 1;
+ width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
if ((w >= width || h >= height) && (width > 0 && height > 0)) {
/* find the zoom value that will fit the image in the image space */
@@ -1948,6 +1948,52 @@ 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 (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;
+ }
+ }
+
+ 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);