📄 salphagraph.pas
字号:
end;
end;
end;
end;
end;
procedure DrawSkinRect(Bmp : TBitmap; R : TRect; Filling : boolean; ci : TCacheInfo; MaskData : TsMaskData; State : integer; UpdateCorners : boolean; SkinManager : TObject = nil);
var
x, y : integer;
w, h : integer;
dw, dh : integer;
wl, wt, wr, wb : integer;
BmpSrc : TBitmap;
begin
if (WidthOf(R) < 2) or (HeightOf(R) < 2) or (MaskData.Manager = nil) then Exit;
wl := MaskData.WL; wt := MaskData.WT; wr := MaskData.WR; wb := MaskData.WB;
if wl + wr > WidthOf(R) then begin
x := ((wl + wr) - WidthOf(R)) div 2;
dec(wl, x); dec(wr, x); if WidthOf(R) mod 2 > 0 then dec(wr);
if wl < 0 then wl := 0;
if wr < 0 then wr := 0;
end;
if wt + wb > HeightOf(R) then begin
x := ((wt + wb) - HeightOf(R)) div 2;
dec(wt, x); dec(wb, x); if HeightOf(R) mod 2 > 0 then dec(wb);
if wt < 0 then wt := 0;
if wb < 0 then wb := 0;
end;
if State >= MaskData.ImageCount then State := MaskData.ImageCount - 1;
dw := WidthOf(MaskData.R) div MaskData.ImageCount; // Width of mask
dh := HeightOf(MaskData.R) div (1 + MaskData.MaskType); // Height of mask
w := dw - wl - wr; if w < 0 then w := 0; // Width of middle piece
h := dh - wt - wb; if h < 0 then h := 0; // Height of middle piece
dw := dw * State; // Offset of mask
if MaskData.Bmp <> nil then BmpSrc := MaskData.Bmp else BmpSrc := TsSkinManager(MaskData.Manager).MasterBitmap;
if MaskData.MaskType = 0 then begin // Copy without mask
// left - top
CopyTransRect(Bmp, BmpSrc, R.Left, R.Top,
Rect(MaskData.R.Left + dw,
MaskData.R.Top,
MaskData.R.Left + dw + wl - 1,
MaskData.R.Top + wt - 1),
clFuchsia, CI, UpdateCorners);
y := R.Top + wt;
// left - middle
if MaskData.DrawMode = 0 then begin
if h > 0 then while y < R.Bottom - h - wb do begin
BitBlt(Bmp.Canvas.Handle, R.Left, y, wl, h, BmpSrc.Canvas.Handle, MaskData.R.Left + dw, MaskData.R.Top + wt, SRCCOPY);
inc(y, h);
end;
if y < R.Bottom - wb then BitBlt(Bmp.Canvas.Handle, R.Left, y, wl, R.Bottom - wb - y, BmpSrc.Canvas.Handle, MaskData.R.Left + dw, MaskData.R.Top + wt, SRCCOPY);
end
else StretchBlt(Bmp.Canvas.Handle,
R.Left, y, wl, R.Bottom - wb - y,
BmpSrc.Canvas.Handle,
MaskData.R.Left + dw, MaskData.R.Top + wt, wl, h,
SRCCOPY); // v4.52
// top - middle
x := R.Left + wl;
if MaskData.DrawMode = 0 then begin
if w > 0 then while x < R.Right - w - wr do begin
BitBlt(Bmp.Canvas.Handle, x, R.Top, w, wt, BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Top, SRCCOPY);
inc(x, w);
end;
if x < R.Right - wr then BitBlt(Bmp.Canvas.Handle, x, R.Top, R.Right - wr - x, wt, BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Top, SRCCOPY);
end
else StretchBlt(Bmp.Canvas.Handle,
x, R.Top, R.Right - wr - x, wt,
BmpSrc.Canvas.Handle,
MaskData.R.Left + dw + wl, MaskData.R.Top, w, wt,
SRCCOPY); // v4.52
// left - bottom
CopyTransRect(Bmp, BmpSrc, R.Left, R.Bottom - wb,
Rect(MaskData.R.Left + dw,
MaskData.R.Bottom - wb,
MaskData.R.Left + dw + wl - 1,
MaskData.R.Bottom - 1),
clFuchsia, CI, UpdateCorners);
// bottom - middle
x := R.Left + wl;
if MaskData.DrawMode = 0 then begin
if w > 0 then while x < R.Right - w - wr do begin
BitBlt(Bmp.Canvas.Handle, x, R.Bottom - wb, w, wb,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Bottom - wb, SRCCOPY);
inc(x, w);
end;
if x < R.Right - wr then BitBlt(Bmp.Canvas.Handle, x, R.Bottom - wb, R.Right - wr - x, wb,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Bottom - wb, SRCCOPY);
end
else StretchBlt(Bmp.Canvas.Handle,
x, R.Bottom - wb, R.Right - wr - x, wb,
BmpSrc.Canvas.Handle,
MaskData.R.Left + dw + wl, MaskData.R.Bottom - wb, w, wb,
SRCCOPY); // v4.52
// right - bottom
CopyTransRect(Bmp, BmpSrc, R.Right - wr, R.Bottom - wb,
Rect(MaskData.R.Left + dw + w + wl,
MaskData.R.Bottom - wb,
MaskData.R.Left + dw + w + wl + wr - 1,
MaskData.R.Bottom - 1),
clFuchsia, CI, UpdateCorners);
// right - top
CopyTransRect(Bmp, BmpSrc, R.Right - wr, R.Top,
Rect(MaskData.R.Left + dw + w + wl,
MaskData.R.Top,
MaskData.R.Left + dw + w + wl + wr - 1,
MaskData.R.Top + wt - 1),
clFuchsia, CI, UpdateCorners);
y := R.Top + wt;
// right - middle
if MaskData.DrawMode = 0 then begin
if h > 0 then while y < R.Bottom - h - wb do begin
BitBlt(Bmp.Canvas.Handle, R.Right - wr, y, wr, h,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl + w, MaskData.R.Top + wt, SRCCOPY);
inc(y, h);
end;
if y < R.Bottom - wb then BitBlt(Bmp.Canvas.Handle, R.Right - wr, y, wr, R.Bottom - wb - y,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + w + wl, MaskData.R.Top + wt, SRCCOPY);
end
else StretchBlt(Bmp.Canvas.Handle,
R.Right - wr, y, wr, R.Bottom - wb - y,
BmpSrc.Canvas.Handle,
MaskData.R.Left + dw + wl + w, MaskData.R.Top + wt, wr, h,
SRCCOPY); // v4.52
// Fill
if Filling and (MaskData.BorderWidth = 0) then begin
if MaskData.DrawMode = 0 then begin
y := R.Top + wt;
if h > 0 then while y < R.Bottom - h - wb do begin
x := R.Left + wl;
if w > 0 then while x < R.Right - w - wr do begin
BitBlt(Bmp.Canvas.Handle, x, y, w, h{R.Bottom - wb - y}, BmpSrc.Canvas.Handle,
MaskData.R.Left + dw + wl, MaskData.R.Top + wt, SRCCOPY);
inc(x, w);
end;
if x < R.Right - wr then BitBlt(Bmp.Canvas.Handle, x, y, R.Right - wr - x, R.Bottom - wb - y,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Top + wt, SRCCOPY);
inc(y, h);
end;
x := R.Left + wl;
if y < R.Bottom - wb then begin
if w > 0 then while x < R.Right - w - wr do begin
BitBlt(Bmp.Canvas.Handle, x, y, w, R.Bottom - wb - y,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Top + wt, SRCCOPY);
inc(x, w);
end;
if x < R.Right - wr then BitBlt(Bmp.Canvas.Handle, x, y, R.Right - wr - x, R.Bottom - wb - y,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Top + wt, SRCCOPY);
end;
end
else begin
y := R.Top + wt;
x := R.Left + wl;
StretchBlt(Bmp.Canvas.Handle,
x, y, R.Right - wr - x, R.Bottom - wb - y,
BmpSrc.Canvas.Handle,
MaskData.R.Left + dw + wl, MaskData.R.Top + wt, w, h,
SRCCOPY); // v4.52
end;
end;
end
else begin
// left - top
CopyByMask(Rect(R.Left, R.Top, R.Left + wl, R.Top + wt),
Rect(MaskData.R.Left + dw, MaskData.R.Top, MaskData.R.Left + dw + wl, MaskData.R.Top + wt),
Bmp, BmpSrc, CI, True, MaskData);
y := R.Top + wt;
// left - middle
while y < R.Bottom - h - wb do begin
CopyByMask(Rect(R.Left, y, R.Left + wl, y + h),
Rect(MaskData.R.Left + dw, MaskData.R.Top + wt, MaskData.R.Left + dw + wl, MaskData.R.Top + h + wt),
Bmp, BmpSrc, EmptyCI, False, MaskData);
inc(y, h);
end;
if y < R.Bottom - wb then begin
CopyByMask(Rect(R.Left, y, R.Left + wl, R.Bottom - wb), Rect(MaskData.R.Left + dw, MaskData.R.Top + wt, MaskData.R.Left + dw + wl, MaskData.R.Top + wt + h), Bmp, BmpSrc, EmptyCI, False, MaskData);
end;
// top - middle
x := R.Left + wl;
while x < R.Right - w - wr do begin
CopyByMask(Rect(x, R.Top, x + w, R.Top + wt), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top, MaskData.R.Left + dw + w + wl, MaskData.R.Top + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
inc(x, w);
end;
if x < R.Right - wr then begin
CopyByMask(Rect(x, R.Top, R.Right - wr, R.Top + wt), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top, MaskData.R.Left + dw + w + wl, MaskData.R.Top + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
end;
// left - bottom
CopyByMask(Rect(R.Left, R.Bottom - wb, R.Left + wl, R.Bottom),
Rect(MaskData.R.Left + dw, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + wl, MaskData.R.Top + dh),
Bmp, BmpSrc, CI, True, MaskData);
// bottom - middle
x := R.Left + wl;
while x < R.Right - w - wr do begin
CopyByMask(Rect(x, R.Bottom - wb, x + w, R.Bottom), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + w + wl, MaskData.R.Top + dh), Bmp, bmpSrc, EmptyCI, False, MaskData);
inc(x, w);
end;
if x < R.Right - wr then begin
CopyByMask(Rect(x, R.Bottom - wb, R.Right - wr, R.Bottom), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + w + wl, MaskData.R.Top + dh), Bmp, BmpSrc, EmptyCI, False, MaskData);
end;
// right - bottom
CopyByMask(Rect(R.Right - wr, R.Bottom - wb, R.Right, R.Bottom), Rect(MaskData.R.Left + dw + w + wl, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + w + wl + wr, MaskData.R.Top + dh), Bmp, BmpSrc, CI, True, MaskData);
// right - top
CopyByMask(Rect(R.Right - wr, R.Top, R.Right, R.Top + wt), Rect(MaskData.R.Left + dw + w + wl, MaskData.R.Top, MaskData.R.Left + dw + w + wl + wr, MaskData.R.Top + wt), Bmp, BmpSrc, CI, True, MaskData);
// right - middle
y := R.Top + wt;
while y < R.Bottom - h - wb do begin
CopyByMask(Rect(R.Right - wr, y, R.Right, y + h), Rect(MaskData.R.Left + dw + w + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl + wr, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
inc(y, h);
end;
if y < R.Bottom - wb then begin
CopyByMask(Rect(R.Right - wr, y, R.Right, R.Bottom - wb), Rect(MaskData.R.Left + dw + w + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl + wr, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
end;
// Fill
if Filling then begin
y := R.Top + wt;
while y < R.Bottom - h - wb do begin
x := R.Left + wl;
while x < R.Right - w - wr do begin
CopyByMask(Rect(x, y, x + w, y + h), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
inc(x, w);
end;
if x < R.Right - wr then begin
CopyByMask(Rect(x, y, R.Right - wr, y + h), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
end;
inc(y, h);
end;
x := R.Left + wl;
if y < R.Bottom - wb then begin
while x < R.Right - w - wr do begin
CopyByMask(Rect(x, y, x + w, R.Bottom - wb), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
inc(x, w);
end;
if x < R.Right - wr then begin
CopyByMask(Rect(x, y, R.Right - wr, R.Bottom - wb), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
end
end;
end;
end;
end;
procedure CopyMasterRect(R1, R2 : TRect; Bmp : TBitmap; CI : TCacheInfo; MaskData : TsMaskData);
var
S1, S2, M : PRGBArray;
X, Y, h, w: Integer;
c : TsRGB;
col : TsColor;
begin
if MaskData.Manager = nil then Exit;
with TsSkinManager(MaskData.Manager) do begin
h := Min(HeightOf(R1), HeightOf(R2));
h := Min(h, Bmp.Height - R1.Top);
h := Min(h, TsSkinManager(MaskData.Manager).MasterBitmap.Height - R2.Top) - 1; //!!!
if h < 0 then Exit;
w := Min(WidthOf(R1), WidthOf(R2));
w := Min(w, Bmp.Width - R1.Left);
w := Min(w, MasterBitmap.Width - R2.Left) - 1; //!!!
if w < 0 then Exit;
if R1.Left < R2.Left then begin
if (R1.Left < 0) then begin
inc(R2.Left, - R1.Left);
dec(h, - R1.Left);
R1.Left := 0;
end;
end
else
if (R2.Left < 0) then begin
inc(R1.Left, - R2.Left);
dec(h, - R2.Left);
R2.Left := 0;
end;
if R1.Top < R2.Top then begin
if (R1.Top < 0) then begin
inc(R2.Top, - R1.Top);
dec(h, - R1.Top);
R1.Top := 0;
end;
end
else
if (R2.Top < 0) then begin
inc(R1.Top, - R2.Top);
dec(h, - R2.Top);
R2.Top := 0;
end;
c.R := 255; c.G := 0; c.B := 255; // clFuchsia
col.C := CtrlParentColor;
if not CI.Ready then begin
for Y := 0 to h do begin
S1 := Bmp.ScanLine[R1.Top + Y];
S2 := MasterBitmap.ScanLine[R2.Top + Y];
M := MasterBitmap.ScanLine[R2.Top + HeightOf(MaskData.R) div 2 + Y];
for X := 0 to w do begin
if (S2[R2.Left + X].R <> c.R) or (S2[R2.Left + X].G <> c.G) or (S2[R2.Left + X].B <> c.B) then begin // v4
// if (S2[R2.Left + X].R <> c.R) or (S2[R2.Left + X].G <> c.G) or (S2[R2.Left + X].B <> c.B) then begin // v4
S1[R1.Left + X].R := IntToByte(((S1[R1.Left + X].R - S2[R2.Left + X].R) * M[R2.Left + X].R + S2[R2.Left + X].R shl 8) shr 8);
S1[R1.Left + X].G := IntToByte(((S1[R1.Left + X].G - S2[R2.Left + X].G) * M[R2.Left + X].G + S2[R2.Left + X].G shl 8) shr 8);
S1[R1.Left + X].B := IntToByte(((S1[R1.Left + X].B - S2[R2.Left + X].B) * M[R2.Left + X].B + S2[R2.Left + X].B shl 8) shr 8);
end
else if CtrlParentColor <> clFuchsia then begin
S1[R1.Left + X].R := col.R;
S1[R1.Left + X].G := col.G;
S1[R1.Left + X].B := col.B;
end;
end;
end;
end
else begin
if Fast24Src.Attach(ci.Bmp) then for Y := 0 to h do begin
S1 := Bmp.ScanLine[R1.Top + Y];
S2 := MasterBitmap.ScanLine[R2.Top + Y];
M := MasterBitmap.ScanLine[R2.Top + HeightOf(MaskData.R) div 2 + Y];
for X := 0 to w do begin
if (S2[R2.Left + X].R <> c.R) or (S2[R2.Left + X].G <> c.G) or (S2[R2.Left + X].B <> c.B) then begin
S1[R1.Left + X].R := IntToByte(((S1[R1.Left + X].R - S2[R2.Left + X].R) * M[R2.Left + X].R + S2[R2.Left + X].R shl 8) shr 8);
S1[R1.Left + X].G := IntToByte(((S1[R1.Left + X].G - S2[R2.Left + X].G) * M[R2.Left + X].G + S2[R2.Left + X].G shl 8) shr 8);
S1[R1.Left + X].B := IntToByte(((S1[R1.Left + X].B - S2[R2.Left + X].B) * M[R2.Left + X].B + S2[R2.Left + X].B shl 8) shr 8);
end
else if CtrlParentColor <> clFuchsia then begin
S1[R1.Left + X].R := col.R;
S1[R1.Left + X].G := col.G;
S1[R1.Left + X].B := col.B;
end
else begin
if (CI.Bmp.Height <= R1.Top + ci.Y + Y) then Continue;
if (CI.Bmp.Width <= R1.Left + ci.X + X) then Break;
if R1.Top + ci.Y + Y < 0 then Continue;//Break;
if R1.Left + ci.X + X < 0 then Continue;
col := Fast24Src.Pixels[R1.Left + ci.X + X, R1.Top + ci.Y + Y];// GetPixel(ci.Bmp.Canvas.Handle, R1.Left + ci.X + X, R1.Top + ci.Y + Y);
S1[R1.Left + X].R := col.R;
S1[R1.Left + X].G := col.G;
S1[R1.Left + X].B := col.B;
end;
end;
end;
end;
end;
end;
procedure CopyMasterRectA(R1, R2 : TRect; Bmp : TBitmap; CI : TCacheInfo; MaskData : TsMaskData);
var
S1, S2, M : PRGBArray;
X, Y, h, w: Integer;
c : TsRGB;
col : TsColor;
begin
if MaskData.Manager = nil then Exit;
with TsSkinManager(MaskData.Manager) do begin
h := Min(HeightOf(R1), HeightOf(R2));
h := Min(h, Bmp.Height - R1.Top);
h := Min(h, MasterBitmap.Height - R2.Top) - 1; //!!!
if h < 0 then Exit;
w := Min(WidthOf(R1), WidthOf(R2));
w := Min(w, Bmp.Width - R1.Left);
w := Min(w, MasterBitmap.Width - R2.Left) - 1; //!!!
if w < 0 then Exit;
if R1.Left < R2.Left then begin
if (R1.Left < 0) then begin
inc(R2.Left, - R1.Left);
dec(h, - R1.Left);
R1.Left := 0;
end;
end
else
if (R2.Left < 0) then begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -