aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-03-03 10:42:28 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-03-03 10:42:28 +0000
commit13c4e100a0faff5a7f78ea8bde5995e28852c377 (patch)
tree3ee5def6e94ee4f326aebd001f7a7ccd25b51afe
parentb722e47aeaa7c2909540265556f25f0b8ed59f05 (diff)
downloadusdx-13c4e100a0faff5a7f78ea8bde5995e28852c377.tar.gz
usdx-13c4e100a0faff5a7f78ea8bde5995e28852c377.tar.xz
usdx-13c4e100a0faff5a7f78ea8bde5995e28852c377.zip
Color bug on Windows resolved. Type conversion problem
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1616 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r--src/base/UImage.pas10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/base/UImage.pas b/src/base/UImage.pas
index 93d84c54..6bdad920 100644
--- a/src/base/UImage.pas
+++ b/src/base/UImage.pas
@@ -918,9 +918,13 @@ procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: cardinal);
Result := 0
else
begin
- if (Max = Red ) then Hue := (Green - Blue )/Delta
- else if (Max = Green) then Hue := 2.0 + (Blue - Red )/Delta
- else if (Max = Blue ) then Hue := 4.0 + (Red - Green)/Delta;
+ // The division by Delta is done separately afterwards.
+ // Necessary because Delphi did not do the type conversion from
+ // longword to double as expected.
+ if (Max = Red ) then Hue := Green - Blue
+ else if (Max = Green) then Hue := 2.0*Delta + Blue - Red
+ else if (Max = Blue ) then Hue := 4.0*Delta + Red - Green;
+ Hue := Hue / Delta;
if (Hue < 0.0) then
Hue := Hue + 6.0;
Result := trunc(Hue*1024); // '*1024' is shl 10