Fix for histogram Luma mode not working when waveform is in RGB mode.
authorXavier Thomas <xavier.thomas.1980@gmail.com>
Mon, 10 May 2010 03:42:22 +0000 (03:42 +0000)
committerXavier Thomas <xavier.thomas.1980@gmail.com>
Mon, 10 May 2010 03:42:22 +0000 (03:42 +0000)
Also unified the scope vocabulary.

source/blender/blenkernel/intern/colortools.c
source/blender/editors/interface/interface_draw.c
source/blender/makesdna/DNA_color_types.h
source/blender/makesrna/intern/rna_color.c

index 2856a333a5f2f6d157994eb0c229e984c35584a8..c8a01b1c12f658d1195d28412fcabe2f4a0e4e53 100644 (file)
@@ -918,7 +918,7 @@ DO_INLINE void save_sample_line(Scopes *scopes, const int idx, const float fx, f
                        scopes->waveform_3[idx + 0] = fx;
                        scopes->waveform_3[idx + 1] = rgb[2];
                        break;
-               case SCOPES_WAVEFRM_LUM:
+               case SCOPES_WAVEFRM_LUMA:
                        scopes->waveform_1[idx + 0] = fx;
                        scopes->waveform_1[idx + 1] = ycc[0];
                        break;
@@ -943,7 +943,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
        unsigned char *rc=NULL;
        unsigned int *bin_r, *bin_g, *bin_b, *bin_lum;
        int savedlines, saveline;
-       float rgb[3], ycc[3];
+       float rgb[3], ycc[3], luma;
        int ycc_mode=-1;
 
        if (scopes->ok == 1 ) return;
@@ -959,7 +959,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
                case SCOPES_WAVEFRM_RGB:
                        ycc_mode = -1;
                        break;
-               case SCOPES_WAVEFRM_LUM:
+               case SCOPES_WAVEFRM_LUMA:
                case SCOPES_WAVEFRM_YCC_JPEG:
                        ycc_mode = BLI_YCC_JFIF_0_255;
                        break;
@@ -1027,6 +1027,10 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
                                for (c=0; c<3; c++)
                                        rgb[c] = rc[c] * INV_255;
                        }
+
+                       /* we still need luma for histogram */
+                       luma = 0.299*rgb[0] + 0.587*rgb[1] + 0.114 * rgb[2];
+
                        /* check for min max */
                        if(ycc_mode == -1 ) {
                                for (c=0; c<3; c++) {
@@ -1046,7 +1050,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
                        bin_r[ get_bin_float(rgb[0]) ] += 1;
                        bin_g[ get_bin_float(rgb[1]) ] += 1;
                        bin_b[ get_bin_float(rgb[2]) ] += 1;
-                       bin_lum[ get_bin_float(ycc[0]) ] += 1;
+                       bin_lum[ get_bin_float(luma) ] += 1;
 
                        /* save sample if needed */
                        if(saveline) {
index 20359b2c3a4d556249d511006f48c9909acf6198..0dd333dc3875666ba02f613a6b9ed1767896aa24 100644 (file)
@@ -861,7 +861,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *r
                glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
        }
        /* 3 vertical separation */
-       if (scopes->wavefrm_mode!= SCOPES_WAVEFRM_LUM) {
+       if (scopes->wavefrm_mode!= SCOPES_WAVEFRM_LUMA) {
                for (i=1; i<3; i++) {
                        fdrawline(rect.xmin+i*w3, rect.ymin, rect.xmin+i*w3, rect.ymax);
                }
@@ -878,7 +878,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *r
                fdrawline(rect.xmin+w3, yofs+h*240.0f/255.0f, rect.xmax+1, yofs+h*240.0f/255.0f);
        }
        /* 7.5 IRE black point level for NTSC */
-       if (scopes->wavefrm_mode== SCOPES_WAVEFRM_LUM)
+       if (scopes->wavefrm_mode== SCOPES_WAVEFRM_LUMA)
                fdrawline(rect.xmin, yofs+h*0.075f, rect.xmax+1, yofs+h*0.075f);
 
        if (scopes->ok && scopes->waveform_1 != NULL) {
@@ -886,7 +886,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *r
                /* LUMA (1 channel) */
                glBlendFunc(GL_ONE,GL_ONE);
                glColor3f(alpha, alpha, alpha);
-               if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUM){
+               if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA){
 
                        glBlendFunc(GL_ONE,GL_ONE);
                        
index 2881ec127c8a1d28d7e468ecd5bd351117465c14..bc35d37933478202b8a31f3e713e9eb7a4e9f778 100644 (file)
@@ -133,7 +133,7 @@ typedef struct Scopes {
 } Scopes;
 
 /* scopes->wavefrm_mode */
-#define SCOPES_WAVEFRM_LUM             0
+#define SCOPES_WAVEFRM_LUMA            0
 #define SCOPES_WAVEFRM_RGB             1
 #define SCOPES_WAVEFRM_YCC_601 2
 #define SCOPES_WAVEFRM_YCC_709 3
index 754f0270210a7e9873df610007f75a2ba7ec25e0..218ca55e72d6919c239f4003217e7e9f4b0180c7 100644 (file)
@@ -453,10 +453,10 @@ static void rna_def_histogram(BlenderRNA *brna)
        
        static EnumPropertyItem prop_mode_items[] = {
                {HISTO_MODE_LUMA, "Luma", ICON_COLOR, "Luma", ""},
-               {HISTO_MODE_RGB, "RGB", ICON_COLOR, "RGB", ""},
-               {HISTO_MODE_R, "R", ICON_COLOR, "R", ""},
-               {HISTO_MODE_G, "G", ICON_COLOR, "G", ""},
-               {HISTO_MODE_B, "B", ICON_COLOR, "B", ""},
+               {HISTO_MODE_RGB, "RGB", ICON_COLOR, "Red Green Blue", ""},
+               {HISTO_MODE_R, "R", ICON_COLOR, "Red", ""},
+               {HISTO_MODE_G, "G", ICON_COLOR, "Green", ""},
+               {HISTO_MODE_B, "B", ICON_COLOR, "Blue", ""},
                {0, NULL, 0, NULL, NULL}};
                
        srna= RNA_def_struct(brna, "Histogram", NULL);
@@ -475,7 +475,7 @@ static void rna_def_scopes(BlenderRNA *brna)
        PropertyRNA *prop;
 
        static EnumPropertyItem prop_wavefrm_mode_items[] = {
-               {SCOPES_WAVEFRM_LUM, "LUMINANCE", ICON_COLOR, "Luminance", ""},
+               {SCOPES_WAVEFRM_LUMA, "LUMA", ICON_COLOR, "Luma", ""},
                {SCOPES_WAVEFRM_RGB, "RGB", ICON_COLOR, "Red Green Blue", ""},
                {SCOPES_WAVEFRM_YCC_601, "YCBCR601", ICON_COLOR, "YCbCr (ITU 601)", ""},
                {SCOPES_WAVEFRM_YCC_709, "YCBCR709", ICON_COLOR, "YCbCr (ITU 709)", ""},