Fix crash in histogram in image window when image buffer contains

NaN values, now clamps integer instead of float to prevent this.
This commit is contained in:
Brecht Van Lommel 2010-01-21 13:06:44 +00:00
parent e9b0956b55
commit 48f48fa814

@ -882,11 +882,14 @@ void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size)
DO_INLINE int get_bin_float(float f)
{
CLAMP(f, 0.0, 1.0);
int bin= (int)(f*511);
/* note: clamp integer instead of float to avoid problems with NaN */
CLAMP(bin, 0, 511);
//return (int) (((f + 0.25) / 1.5) * 512);
return (int)(f * 511);
return bin;
}