[#22830] Hex colour number (COLOUR BALANCE) is out the range in video strip
authorCampbell Barton <ideasman42@gmail.com>
Wed, 14 Jul 2010 08:39:59 +0000 (08:39 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 14 Jul 2010 08:39:59 +0000 (08:39 +0000)
- use FTOCHAR macro which clamps values above 1.0 (rather then wrapping)
- also fixes a problem rounding down where white would display as FEFEFE rather then FFFFFF

the report also mentions how editing colors above 255 is broken but think this isnt worth trying to support.

source/blender/editors/interface/interface_regions.c

index a2a7f4bf77a11677f0e3488a4d037151cfc20fda..f17a3371df1552bc614f77e4c7e6697ea895ae98 100644 (file)
@@ -1600,7 +1600,7 @@ void ui_update_block_buts_rgb(uiBlock *block, float *rgb, float *rhsv)
                        if (rgb_gamma[1] > 1.0f) rgb_gamma[1] = modf(rgb_gamma[1], &intpart);
                        if (rgb_gamma[2] > 1.0f) rgb_gamma[2] = modf(rgb_gamma[2], &intpart);
 
-                       sprintf(col, "%02X%02X%02X", (unsigned int)(rgb_gamma[0]*255.0), (unsigned int)(rgb_gamma[1]*255.0), (unsigned int)(rgb_gamma[2]*255.0));
+                       sprintf(col, "%02X%02X%02X", FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2]));
                        
                        strcpy(bt->poin, col);
                }
@@ -1861,8 +1861,8 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR
        }
 
        rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
-       
-       sprintf(hexcol, "%02X%02X%02X", (unsigned int)(rgb_gamma[0]*255.0), (unsigned int)(rgb_gamma[1]*255.0), (unsigned int)(rgb_gamma[2]*255.0));    
+
+       sprintf(hexcol, "%02X%02X%02X", FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2]));
 
        bt= uiDefBut(block, TEX, 0, "Hex: ", 0, -60, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, "Hex triplet for color (#RRGGBB)");
        uiButSetFunc(bt, do_hex_rna_cb, bt, hexcol);