aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-03-03 12:42:46 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-03-03 12:42:46 +0000
commit7ff32f8fb43868b06805a6a83550d87b41a07b8d (patch)
tree2e84c27c2ebe0ad3fd6915805978db71441cdcc8
parent13c4e100a0faff5a7f78ea8bde5995e28852c377 (diff)
downloadusdx-7ff32f8fb43868b06805a6a83550d87b41a07b8d.tar.gz
usdx-7ff32f8fb43868b06805a6a83550d87b41a07b8d.tar.xz
usdx-7ff32f8fb43868b06805a6a83550d87b41a07b8d.zip
cosmetics and comments
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1617 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r--src/base/UImage.pas24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/base/UImage.pas b/src/base/UImage.pas
index 6bdad920..8dc38495 100644
--- a/src/base/UImage.pas
+++ b/src/base/UImage.pas
@@ -887,8 +887,14 @@ end;
procedure ColorizeImage(ImgSurface: PSDL_Surface; NewColor: cardinal);
- // for the conversion of colors from rgb to hsv space and back
- // simply check the wikipedia.
+ // First, the rgb colors are converted to hsv, second hue is replaced by
+ // the NewColor, saturation and value remain unchanged, finally this
+ // hsv color is converted back to rgb space.
+ // For the conversion algorithms of colors from rgb to hsv space
+ // and back simply check the wikipedia.
+ // In order to speed up starting time of USDX the division of reals is
+ // replaced by division of longwords, shifted by 10 bits to keep
+ // digits.
function ColorToHue(const Color: longword): longword;
// returns hue within the range [0.0-6.0] but shl 10, ie. times 1024
@@ -954,7 +960,7 @@ begin
+ IntToStr(ImgSurface^.format.BytesPerPixel));
Hue := ColorToHue(NewColor); // Hue is shl 10
- f := Hue and $3ff;
+ f := Hue and $3ff; // f is the dezimal part of hue
HueInteger := Hue shr 10;
for PixelIndex := 0 to (ImgSurface^.W * ImgSurface^.H)-1 do
@@ -1037,13 +1043,13 @@ begin
end;
{$IFDEF FPC_BIG_ENDIAN}
- PixelColors[3] := Red ;
- PixelColors[2] := Green ;
- PixelColors[1] := Blue ;
+ PixelColors[3] := Red;
+ PixelColors[2] := Green;
+ PixelColors[1] := Blue
{$ELSE}
- PixelColors[0] := Red ;
- PixelColors[1] := Green ;
- PixelColors[2] := Blue ;
+ PixelColors[0] := Red;
+ PixelColors[1] := Green;
+ PixelColors[2] := Blue;
{$ENDIF}
end;