From 38add90a8759e85d66f2dabecde2236b141d51d5 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Mon, 29 Jun 2009 22:05:47 +0000 Subject: 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 --- src/base/UImage.pas | 8 +++++--- 1 file 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; -- cgit v1.2.3