diff options
author | k-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-06-29 22:05:47 +0000 |
---|---|---|
committer | k-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-06-29 22:05:47 +0000 |
commit | 38add90a8759e85d66f2dabecde2236b141d51d5 (patch) | |
tree | ce44c48a1b0174e705feb6dccde068361a0edae3 /src/base | |
parent | 757ad7e4f0668334e33df82e0bb3bad6a8933bff (diff) | |
download | usdx-38add90a8759e85d66f2dabecde2236b141d51d5.tar.gz usdx-38add90a8759e85d66f2dabecde2236b141d51d5.tar.xz usdx-38add90a8759e85d66f2dabecde2236b141d51d5.zip |
resolve wrong colors with Delphi resulting from questionable use of longwords. Thanks to zup3rvock
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1842 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | src/base/UImage.pas | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/base/UImage.pas b/src/base/UImage.pas index 60b0a3a2..f8fd8a05 100644 --- a/src/base/UImage.pas +++ b/src/base/UImage.pas @@ -885,7 +885,7 @@ begin end; *) -procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: cardinal); +procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: longword); // First, the rgb colors are converted to hsv, second hue is replaced by // the NewColor, saturation and value remain unchanged, finally this @@ -904,8 +904,8 @@ procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: cardinal); function ColorToHue(const Color: longword): longword; // returns hue within the range [0.0-6.0] but shl 10, ie. times 1024 var - Red, Green, Blue: longword; - Min, Max, Delta: longword; + Red, Green, Blue: longint; + Min, Max, Delta: longint; Hue: double; begin // extract the colors @@ -933,6 +933,8 @@ procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: cardinal); // The division by Delta is done separately afterwards. // Necessary because Delphi did not do the type conversion from // longword to double as expected. + // After the change to longint, we may not need it, but left for now + // Something to check 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; |