function GetBlendColor(Basecolor: TColor; Blendcolor: TColor; BlendIntensity: Byte=127): TColor;
function GetValueButMax(AValue: Real; Max: Byte): Byte;
begin
if AValue > max
then result := max
else result := trunc(AValue);
end;
type
TMyColor =
record
red: Byte;
green: Byte;
blue: Byte;
end;
var LF1, LF2: TMyColor;
begin
LF1.red := GetRValue(Basecolor);
LF1.green := GetGValue(Basecolor);
LF1.blue := GetBValue(Basecolor);
LF2.red := (LF1.red * (255-BlendIntensity) + GetRValue(Blendcolor) * BlendIntensity)
div 255;
LF2.green := (LF1.green * (255-BlendIntensity) + GetGValue(Blendcolor) * BlendIntensity)
div 255;
LF2.blue := (LF1.blue * (255-BlendIntensity) + GetBValue(Blendcolor) * BlendIntensity)
div 255; result :=
rgb(LF2.red, LF2.green, LF2.blue);
end;
procedure FillWithColor(ABitmap: TBitmap; ABaseColor: TColor; ADestColor1: TColor = clWhite; ADestColor2: TColor = clBlack);
var LCountX, LCountY: Integer;
LFactorX, LFactorY: Extended;
LTmpColor1, LTmpColor2: TColor;
begin
LFactorX := 255 / ABitmap.Width;
LFactorY := 255 / ABitmap.Height;
for LCountX := 0
to ABitmap.Width - 1
do
begin
LTmpColor1 := GetBlendColor(ADestColor1, ABaseColor, Trunc(LCountX * LFactorX));
for LCountY := 0
to ABitmap.Height
do
begin
LTmpColor2 := GetBlendColor(LTmpColor1, ADestColor2, Trunc(LCountY * LFactorY));
ABitmap.Canvas.Pixels[LCountX, LCountY] := LTmpColor2;
end;
end;
end;