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
path: root/source
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2011-04-20 13:49:32 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2011-04-20 13:49:32 +0400
commit38a192031ffa1a9183d0a4f1d9bb5e03ebd7e2c3 (patch)
treea341ba4a002f92915e98bfd1ad5f00bd71b3259b /source
parent0da889dff5515ebd2201874c7272398f5dc156b2 (diff)
Upgrade for pixel color info in image editor and compositor backdrop. Next to the RGB color values there is now a small rectangle displaying the actual color under the mouse cursor. In addition to that the HSV and luminance values are also displayed.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_image/image_draw.c192
-rw-r--r--source/blender/editors/space_node/drawnode.c199
2 files changed, 340 insertions, 51 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index d76374ec3f4..8030bffae2d 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -45,6 +45,7 @@
#include "PIL_time.h"
+#include "BLI_math_color.h"
#include "BLI_threads.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@@ -135,26 +136,19 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf)
{
char str[256];
- int ofs= 0;
-
- ofs += BLI_snprintf(str + ofs, sizeof(str)-ofs, "X: %4d Y: %4d ", x, y);
- if(cp)
- ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| R: %3d G: %3d B: %3d A: %3d ", cp[0], cp[1], cp[2], cp[3]);
-
- if(fp) {
- if(channels==4)
- ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| R: %.4f G: %.4f B: %.4f A: %.4f ", fp[0], fp[1], fp[2], fp[3]);
- else if(channels==1)
- ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| Val: %.4f ", fp[0]);
- else if(channels==3)
- ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| R: %.4f G: %.4f B: %.4f ", fp[0], fp[1], fp[2]);
- }
-
- if(zp)
- ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| Z: %.4f ", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff));
- if(zpf)
- ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| Z: %.3f ", *zpf);
- (void)ofs; /* quiet clang */
+ float dx= 6;
+ /* text colors */
+ /* XXX colored text not allowed in Blender UI */
+ #if 0
+ unsigned char red[3] = {255, 50, 50};
+ unsigned char green[3] = {0, 255, 0};
+ unsigned char blue[3] = {100, 100, 255};
+ #else
+ unsigned char red[3] = {255, 255, 255};
+ unsigned char green[3] = {255, 255, 255};
+ unsigned char blue[3] = {255, 255, 255};
+ #endif
+ float hue=0, sat=0, val=0, lum=0, u=0, v=0;
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
@@ -163,14 +157,164 @@ void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *f
glColor4ub(0, 0, 0, 190);
glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20);
glDisable(GL_BLEND);
-
+
+ BLF_size(blf_mono_font, 11, 72);
+
glColor3ub(255, 255, 255);
-
+ sprintf(str, "X:%-4d Y:%-4d |", x, y);
// UI_DrawString(6, 6, str); // works ok but fixed width is nicer.
- BLF_size(blf_mono_font, 11, 72);
- BLF_position(blf_mono_font, 6, 6, 0);
+ BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ if(zp) {
+ glColor3ub(255, 255, 255);
+ sprintf(str, " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff));
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
+ if(zpf) {
+ glColor3ub(255, 255, 255);
+ sprintf(str, " Z:%-.3f |", *zpf);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
+
+ if(channels >= 3) {
+ glColor3ubv(red);
+ if (fp)
+ sprintf(str, " R:%-.4f", fp[0]);
+ else if (cp)
+ sprintf(str, " R:%-3d", cp[0]);
+ else
+ sprintf(str, " R:-");
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ glColor3ubv(green);
+ if (fp)
+ sprintf(str, " G:%-.4f", fp[1]);
+ else if (cp)
+ sprintf(str, " G:%-3d", cp[1]);
+ else
+ sprintf(str, " G:-");
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ glColor3ubv(blue);
+ if (fp)
+ sprintf(str, " B:%-.4f", fp[2]);
+ else if (cp)
+ sprintf(str, " B:%-3d", cp[2]);
+ else
+ sprintf(str, " B:-");
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ if(channels == 4) {
+ glColor3ub(255, 255, 255);
+ if (fp)
+ sprintf(str, " A:%-.4f", fp[3]);
+ else if (cp)
+ sprintf(str, " A:%-3d", cp[3]);
+ else
+ sprintf(str, "- ");
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
+ }
+ glDisable(GL_BLEND);
+ if (channels==1) {
+ if (fp)
+ glColor3f(fp[0], fp[0], fp[0]);
+ else if (cp)
+ glColor3ub(cp[0], cp[0], cp[0]);
+ else
+ glColor3ub(0, 0, 0);
+ }
+ else if (channels==3) {
+ if (fp)
+ glColor3fv(fp);
+ else if (cp)
+ glColor3ub(cp[0], cp[1], cp[2]);
+ else
+ glColor3ub(0, 0, 0);
+ }
+ else if (channels==4) {
+ if (fp)
+ glColor4fv(fp);
+ else if (cp)
+ glColor4ub(cp[0], cp[1], cp[2], cp[3]);
+ else
+ glColor3ub(0, 0, 0);
+ }
+ dx += 5;
+ glBegin(GL_QUADS);
+ glVertex2f(dx, 3);
+ glVertex2f(dx, 17);
+ glVertex2f(dx+30, 17);
+ glVertex2f(dx+30, 3);
+ glEnd();
+ dx += 35;
+
+ glColor3ub(255, 255, 255);
+ if(channels == 1) {
+ if (fp) {
+ rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val);
+ rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v);
+ }
+ else if (cp) {
+ rgb_to_hsv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &hue, &sat, &val);
+ rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v);
+ }
+
+ sprintf(str, "V:%-.4f", val);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ sprintf(str, " L:%-.4f", lum);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
+ else if(channels >= 3) {
+ if (fp) {
+ rgb_to_hsv(fp[0], fp[1], fp[2], &hue, &sat, &val);
+ rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v);
+ }
+ else if (cp) {
+ rgb_to_hsv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &hue, &sat, &val);
+ rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v);
+ }
+
+ sprintf(str, "H:%-.4f", hue);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ sprintf(str, " S:%-.4f", sat);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ sprintf(str, " V:%-.4f", val);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ sprintf(str, " L:%-.4f", lum);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
}
/* image drawing */
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index ba15e47ba04..db6e4640d5f 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -1445,42 +1445,187 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
void draw_nodespace_color_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp)
{
char str[256];
- int ofs;
-
- ofs= sprintf(str, "X: %4d Y: %4d ", x, y);
+ float dx= 6;
+ /* text colors */
+ /* XXX colored text not allowed in Blender UI */
+ #if 0
+ unsigned char red[3] = {255, 50, 50};
+ unsigned char green[3] = {0, 255, 0};
+ unsigned char blue[3] = {100, 100, 255};
+ #else
+ unsigned char red[3] = {255, 255, 255};
+ unsigned char green[3] = {255, 255, 255};
+ unsigned char blue[3] = {255, 255, 255};
+ #endif
+ float hue=0, sat=0, val=0, lum=0, u=0, v=0;
+
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+
+ /* noisy, high contrast make impossible to read if lower alpha is used. */
+ glColor4ub(0, 0, 0, 190);
+ glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20);
+ glDisable(GL_BLEND);
+
+ BLF_size(blf_mono_font, 11, 72);
+
+ glColor3ub(255, 255, 255);
+ sprintf(str, "X:%-4d Y:%-4d |", x, y);
+ // UI_DrawString(6, 6, str); // works ok but fixed width is nicer.
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ #if 0 /* XXX no Z value in compo backdrop atm */
+ if(zp) {
+ glColor3ub(255, 255, 255);
+ sprintf(str, " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff));
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
+ if(zpf) {
+ glColor3ub(255, 255, 255);
+ sprintf(str, " Z:%-.3f |", *zpf);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
+ #endif
- if(channels==4) {
- if(cp)
- ofs+= sprintf(str+ofs, "| R: %3d G: %3d B: %3d A: %3d ", cp[0], cp[1], cp[2], cp[3]);
+ if(channels >= 3) {
+ glColor3ubv(red);
+ if (fp)
+ sprintf(str, " R:%-.4f", fp[0]);
+ else if (cp)
+ sprintf(str, " R:%-3d", cp[0]);
+ else
+ sprintf(str, " R:-");
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ glColor3ubv(green);
if (fp)
- ofs+= sprintf(str+ofs, "| R: %.4f G: %.4f B: %.4f A: %.4f ", fp[0], fp[1], fp[2], fp[3]);
+ sprintf(str, " G:%-.4f", fp[1]);
+ else if (cp)
+ sprintf(str, " G:%-3d", cp[1]);
+ else
+ sprintf(str, " G:-");
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ glColor3ubv(blue);
+ if (fp)
+ sprintf(str, " B:%-.4f", fp[2]);
+ else if (cp)
+ sprintf(str, " B:%-3d", cp[2]);
+ else
+ sprintf(str, " B:-");
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ if(channels == 4) {
+ glColor3ub(255, 255, 255);
+ if (fp)
+ sprintf(str, " A:%-.4f", fp[3]);
+ else if (cp)
+ sprintf(str, " A:%-3d", cp[3]);
+ else
+ sprintf(str, "- ");
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
}
- else if(channels==1) {
- if(cp)
- ofs+= sprintf(str+ofs, "| Val: %3d ", cp[0]);
+
+ glDisable(GL_BLEND);
+ if (channels==1) {
+ if (fp)
+ glColor3f(fp[0], fp[0], fp[0]);
+ else if (cp)
+ glColor3ub(cp[0], cp[0], cp[0]);
+ else
+ glColor3ub(0, 0, 0);
+ }
+ else if (channels==3) {
if (fp)
- ofs+= sprintf(str+ofs, "| Val: %.4f ", fp[0]);
+ glColor3fv(fp);
+ else if (cp)
+ glColor3ub(cp[0], cp[1], cp[2]);
+ else
+ glColor3ub(0, 0, 0);
}
- else if(channels==3) {
- if(cp)
- ofs+= sprintf(str+ofs, "| R: %3d G: %3d B: %3d ", cp[0], cp[1], cp[2]);
+ else if (channels==4) {
if (fp)
- ofs+= sprintf(str+ofs, "| R: %.4f G: %.4f B: %.4f ", fp[0], fp[1], fp[2]);
+ glColor4fv(fp);
+ else if (cp)
+ glColor4ub(cp[0], cp[1], cp[2], cp[3]);
+ else
+ glColor3ub(0, 0, 0);
}
+ dx += 5;
+ glBegin(GL_QUADS);
+ glVertex2f(dx, 3);
+ glVertex2f(dx, 17);
+ glVertex2f(dx+30, 17);
+ glVertex2f(dx+30, 3);
+ glEnd();
+ dx += 35;
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- glColor4f(.0,.0,.0,.25);
- glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20);
- glDisable(GL_BLEND);
-
glColor3ub(255, 255, 255);
-
- // UI_DrawString(6, 6, str); // works ok but fixed width is nicer.
- BLF_size(blf_mono_font, 11, 72);
- BLF_position(blf_mono_font, 6, 6, 0);
- BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ if(channels == 1) {
+ if (fp) {
+ rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val);
+ rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v);
+ }
+ else if (cp) {
+ rgb_to_hsv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &hue, &sat, &val);
+ rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v);
+ }
+
+ sprintf(str, "V:%-.4f", val);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ sprintf(str, " L:%-.4f", lum);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
+ else if(channels >= 3) {
+ if (fp) {
+ rgb_to_hsv(fp[0], fp[1], fp[2], &hue, &sat, &val);
+ rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v);
+ }
+ else if (cp) {
+ rgb_to_hsv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &hue, &sat, &val);
+ rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v);
+ }
+
+ sprintf(str, "H:%-.4f", hue);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ sprintf(str, " S:%-.4f", sat);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ sprintf(str, " V:%-.4f", val);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+
+ sprintf(str, " L:%-.4f", lum);
+ BLF_position(blf_mono_font, dx, 6, 0);
+ BLF_draw_ascii(blf_mono_font, str, sizeof(str));
+ dx += BLF_width(blf_mono_font, str);
+ }
}
#if 0