📄 salphagraph.pas
字号:
unit sAlphaGraph;
{$I sDefs.inc}
interface
{ universal formula for blending // Peter
Result := Div256((Src1 - Src2) * PercentOfSrc1 + Src2 / 256);
}
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, sConst, ExtCtrls, Jpeg, math, sGraphUtils;
// Transparency - percent of the bmp visibility
procedure BlendColorRect(Bmp: TBitmap; R: TRect; Transparency: TPercent; Color: TColor);
procedure BmpDisabledKind(Bmp : TBitmap; DisabledKind : TsDisabledKind; Parent : TControl; CI : TCacheInfo; Offset : TPoint);
implementation
Uses sUtils;
procedure BmpDisabledKind(Bmp : TBitmap; DisabledKind : TsDisabledKind; Parent : TControl; CI : TCacheInfo; Offset : TPoint);
var
C : TsColor;
begin
if (dkGrayed in DisabledKind) then begin
GrayScale(Bmp);
end;
if (dkBlended in DisabledKind) then begin
if CI.Ready then begin
C.A := 255;
BlendTransRectangle(Bmp, 0, 0, CI.Bmp, Rect(CI.X + Offset.X, CI.Y + Offset.Y, CI.X + Offset.X + Bmp.Width, CI.Y + Offset.Y + Bmp.Height), 0.5, C);
end
else begin
C.C := ColorToRGB(TsHackedControl(Parent).Color);
FadeBmp(Bmp, Rect(0, 0, Bmp.Width, Bmp.Height), 50, C, 0, 0);
end;
end;
end;
procedure BlendColorRect(Bmp: TBitmap; R: TRect; Transparency: TPercent; Color: TColor);
var
BmpLine : PRGBArray;
BlendColor : TsColor;
x, y : integer;
rT, tR : real;
function Div256(X: word): byte; asm
MOV AX, X
MOV AL, AH
MOV AH, 0
end;
begin
if R.Left < 0 then R.Left := 0;
if R.Top < 0 then R.Top := 0;
if R.Right > Bmp.Width - 1 then R.Right := Bmp.Width - 1;
if R.Bottom > Bmp.Height - 1 then R.Bottom := Bmp.Height - 1;
BlendColor.C := ColorToRGB(Color);
rT := Transparency / 100;
tR := 1 - rT;
for y := R.Top to R.Bottom do begin
BmpLine := Bmp.ScanLine[y];
for x := R.Left to R.Right do begin
BmpLine[X].R := Round(BmpLine[X].R * rT + BlendColor.R * tR);
BmpLine[X].G := Round(BmpLine[X].G * rT + BlendColor.G * tR);
BmpLine[X].B := Round(BmpLine[X].B * rT + BlendColor.B * tR);
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -