mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 15:31:14 +00:00
Try to address real problem of unknown crash
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/branches/gnustep_testplant_branch@39771 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6ab033ef7d
commit
a33848a321
1 changed files with 29 additions and 26 deletions
|
@ -280,35 +280,38 @@ gsColorToHSB(device_color_t *color)
|
|||
Temp = (r < g ? r : g);
|
||||
Temp = (b < Temp ? b : Temp);
|
||||
diff = V - Temp;
|
||||
if (V == r)
|
||||
{
|
||||
if (diff == 0.0)
|
||||
{
|
||||
// Invoke same code as r=g=b above...
|
||||
H = 0;
|
||||
// diff == 0 so diff/V == 0
|
||||
// V already == r
|
||||
}
|
||||
else
|
||||
|
||||
// TESTPLANT-MAL-05162016: customer getting crashes in this
|
||||
// code somehwere - only case I can find that could cause one
|
||||
// is V == 0...
|
||||
if (V == 0.0)
|
||||
{
|
||||
_hue_component = 0;
|
||||
_saturation_component = 0;
|
||||
_brightness_component = r;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (V == r)
|
||||
{
|
||||
H = (g - b)/diff;
|
||||
}
|
||||
}
|
||||
else if (V == g)
|
||||
{
|
||||
H = (b - r)/diff + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
H = (r - g)/diff + 4;
|
||||
}
|
||||
if (H < 0)
|
||||
{
|
||||
H += 6;
|
||||
}
|
||||
_hue_component = H/6;
|
||||
_saturation_component = diff/V;
|
||||
_brightness_component = V;
|
||||
else if (V == g)
|
||||
{
|
||||
H = (b - r)/diff + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
H = (r - g)/diff + 4;
|
||||
}
|
||||
if (H < 0)
|
||||
{
|
||||
H += 6;
|
||||
}
|
||||
_hue_component = H/6;
|
||||
_saturation_component = diff/V;
|
||||
_brightness_component = V;
|
||||
}
|
||||
}
|
||||
color->field[0] = _hue_component;
|
||||
color->field[1] = _saturation_component;
|
||||
|
|
Loading…
Reference in a new issue