diff options
author | Matt Ebb <matt@mke3.net> | 2010-01-28 10:26:21 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-01-28 10:26:21 +0300 |
commit | 9d0dbd707e2ccac6b11a6be4c19b9413f96cc3c0 (patch) | |
tree | 5bfd0a03e4f608dbb355b24b8ca973d4414df76e /source/blender/blenkernel/intern/colortools.c | |
parent | b0989aac023b0c1b9cfc2e7cc1006c62e857275f (diff) |
Fix [#20754] Histogram Not Updating, Showing Incorrect Levels, Colour Management on/off leads to Crash
Various internal fixes, also additional feature - can drag on the histogram to change scale
(0 key to reset).
Also fix [#20844] Color balance node (lift freeze)
Diffstat (limited to 'source/blender/blenkernel/intern/colortools.c')
-rw-r--r-- | source/blender/blenkernel/intern/colortools.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 7bf147b4906..3c30332b18d 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -882,12 +882,12 @@ void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size) DO_INLINE int get_bin_float(float f) { - int bin= (int)(f*511); + int bin= (int)(f*255); /* note: clamp integer instead of float to avoid problems with NaN */ - CLAMP(bin, 0, 511); + CLAMP(bin, 0, 255); - //return (int) (((f + 0.25) / 1.5) * 512); + //return (int) (((f + 0.25) / 1.5) * 255); return bin; } @@ -903,17 +903,20 @@ void histogram_update(Histogram *hist, ImBuf *ibuf) if (hist->ok == 1 ) return; + if (hist->xmax == 0.f) hist->xmax = 1.f; + if (hist->ymax == 0.f) hist->ymax = 1.f; + /* hmmmm */ if (!(ELEM(ibuf->channels, 3, 4))) return; hist->channels = 3; - bin_r = MEM_callocN(512 * sizeof(unsigned int), "temp historgram bins"); - bin_g = MEM_callocN(512 * sizeof(unsigned int), "temp historgram bins"); - bin_b = MEM_callocN(512 * sizeof(unsigned int), "temp historgram bins"); + bin_r = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); + bin_g = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); + bin_b = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); if (ibuf->rect_float) { - hist->x_resolution = 512; + hist->x_resolution = 256; /* divide into bins */ rf = ibuf->rect_float; @@ -942,7 +945,7 @@ void histogram_update(Histogram *hist, ImBuf *ibuf) /* convert to float */ n=0; - for (x=0; x<512; x++) { + for (x=0; x<256; x++) { if (bin_r[x] > n) n = bin_r[x]; if (bin_g[x] > n) @@ -951,7 +954,7 @@ void histogram_update(Histogram *hist, ImBuf *ibuf) n = bin_b[x]; } div = 1.f/(double)n; - for (x=0; x<512; x++) { + for (x=0; x<256; x++) { hist->data_r[x] = bin_r[x] * div; hist->data_g[x] = bin_g[x] * div; hist->data_b[x] = bin_b[x] * div; |