aboutsummaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-02-10 00:16:36 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-02-10 00:16:36 +0000
commit8474b7135054b8da29e8e95f6764fbcd53689e02 (patch)
tree3d70f8f89db576e7723931f3bfeed091b018a5fc /src/base
parentc027a665e0d63c8aaba2833b60ec7834987fa8f9 (diff)
downloadusdx-8474b7135054b8da29e8e95f6764fbcd53689e02.tar.gz
usdx-8474b7135054b8da29e8e95f6764fbcd53689e02.tar.xz
usdx-8474b7135054b8da29e8e95f6764fbcd53689e02.zip
types unified to longword, algo optimized, but no succes regarding endian related issue with icons
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1588 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--src/base/UImage.pas31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/base/UImage.pas b/src/base/UImage.pas
index 18b0035c..dfd47d12 100644
--- a/src/base/UImage.pas
+++ b/src/base/UImage.pas
@@ -892,17 +892,18 @@ begin
end;
*)
-procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: Cardinal);
+procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: cardinal);
- //returns hue within range [0.0-6.0)
- function col2hue(Color:Cardinal): double;
+ // returns hue within the range [0.0-6.0)
+ function col2hue(Color: longword): double;
var
clr: array[0..2] of double;
hue, max, delta: double;
begin
- clr[0] := ((Color and $ff0000) shr 16)/255; // R
- clr[1] := ((Color and $ff00) shr 8)/255; // G
- clr[2] := (Color and $ff) /255; // B
+ // division by 255 is omitted, since it is implicitly done when deviding by delta
+ clr[0] := ((Color and $ff0000) shr 16); // R
+ clr[1] := ((Color and $ff00) shr 8); // G
+ clr[2] := (Color and $ff) ; // B
max := maxvalue(clr);
delta := max - minvalue(clr);
// calc hue
@@ -916,16 +917,16 @@ procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: Cardinal);
end;
var
- DestinationHue: Double;
- PixelIndex: Cardinal;
+ DestinationHue: double;
+ PixelIndex: longword;
Pixel: PByte;
PixelColors: PByteArray;
- clr: array[0..2] of UInt32; // [0: R, 1: G, 2: B]
- hsv: array[0..2] of UInt32; // [0: H(ue), 1: S(aturation), 2: V(alue)]
- dhue: UInt32;
- h_int: Cardinal;
- delta, f, p, q, t: Longint;
- max: Uint32;
+ clr: array[0..2] of longword; // [0: R, 1: G, 2: B]
+ hsv: array[0..2] of longword; // [0: H(ue), 1: S(aturation), 2: V(alue)]
+ dhue: longword;
+ delta, max: longword;
+ h_int: longword;
+ f, p, q, t: longword;
begin
DestinationHue := col2hue(NewColor);
@@ -953,7 +954,7 @@ begin
if clr[2] < delta then delta := clr[2];
delta := max-delta;
hsv[0] := dhue; // shl 8
- hsv[2] := max; // shl 8
+ hsv[2] := max; // shl 8
if (max = 0) then
hsv[1] := 0
else