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:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-05-13 12:19:32 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-05-13 12:22:18 +0300
commit958d613f6681bd9463bcc60ecd1d7ad52407a9f0 (patch)
treee2bfb135f38a10af0c100bd97878c7db40181b3e
parentb72aef92c4fce0c7fc7cf6fca111d085ede99dbe (diff)
Image editor: Show actual value of single-channel buffer in sample info
Previously if image only had single channel only z buffer value was displaying. This isn't handy for cases when you've got single channel buffer which is not a z buffer. Also fixed possible read past the array.
-rw-r--r--source/blender/editors/space_image/image_draw.c13
-rw-r--r--source/blender/editors/space_image/image_ops.c36
2 files changed, 41 insertions, 8 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index aff0a4c3d44..e810f4db7dd 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -197,6 +197,19 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
dx += BLF_width(blf_mono_font, str, sizeof(str));
}
+ if (channels == 1 && (cp != NULL || fp != NULL)) {
+ if (fp != NULL) {
+ BLI_snprintf(str, sizeof(str), " Val:%-.3f |", fp[0]);
+ }
+ else if (cp != NULL) {
+ BLI_snprintf(str, sizeof(str), " Val:%-.3f |", cp[0] / 255.0f);
+ }
+ glColor3ub(255, 255, 255);
+ BLF_position(blf_mono_font, dx, dy, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
+ }
+
if (channels >= 3) {
glColor3ubv(red);
if (fp)
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 88bab733013..8db5a8f9bd3 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2826,8 +2826,8 @@ typedef struct ImageSampleInfo {
int *zp;
float *zfp;
- int draw;
- int color_manage;
+ bool draw;
+ bool color_manage;
int use_default_view;
} ImageSampleInfo;
@@ -2901,7 +2901,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
if (ibuf == NULL) {
ED_space_image_release_buffer(sima, ibuf, lock);
- info->draw = 0;
+ info->draw = false;
return;
}
@@ -2918,7 +2918,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
info->x = x;
info->y = y;
- info->draw = 1;
+ info->draw = true;
info->channels = ibuf->channels;
info->colp = NULL;
@@ -2951,10 +2951,24 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
if (ibuf->rect_float) {
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
- info->colf[0] = fp[0];
- info->colf[1] = fp[1];
- info->colf[2] = fp[2];
- info->colf[3] = fp[3];
+ if (ibuf->channels == 4) {
+ info->colf[0] = fp[0];
+ info->colf[1] = fp[1];
+ info->colf[2] = fp[2];
+ info->colf[3] = fp[3];
+ }
+ else if (ibuf->channels == 3) {
+ info->colf[0] = fp[0];
+ info->colf[1] = fp[1];
+ info->colf[2] = fp[2];
+ info->colf[3] = 1.0f;
+ }
+ else {
+ info->colf[0] = fp[0];
+ info->colf[1] = fp[0];
+ info->colf[2] = fp[0];
+ info->colf[3] = 1.0f;
+ }
info->colfp = info->colf;
copy_v4_v4(info->linearcol, info->colf);
@@ -2965,10 +2979,16 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
if (ibuf->zbuf) {
info->z = ibuf->zbuf[y * ibuf->x + x];
info->zp = &info->z;
+ if (ibuf->zbuf == (int*)ibuf->rect) {
+ info->colp = NULL;
+ }
}
if (ibuf->zbuf_float) {
info->zf = ibuf->zbuf_float[y * ibuf->x + x];
info->zfp = &info->zf;
+ if (ibuf->zbuf_float == ibuf->rect_float) {
+ info->colfp = NULL;
+ }
}
if (curve_mapping && ibuf->channels == 4) {