From 13c4e100a0faff5a7f78ea8bde5995e28852c377 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Tue, 3 Mar 2009 10:42:28 +0000 Subject: 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 --- src/base/UImage.pas | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/base') 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 -- cgit v1.2.3