P
PascalBoy
Unregistered / Unconfirmed
GUEST, unregistred user!
这个分我拿啦,98下面只有这个方法最好啦。这个是我做的贺卡中模拟半透明的代码。原理很简单,先复制屏幕,然后在image中画一个矩形,并设置颜色,合并两个图像。image的颜色越淡透明度越高。
procedure TForm1.FormCreate(Sender: TObject);
var
Desktop:TCanvas;
begin
with Selfdo
begin
Width:=500;
Height:=350;
Left:=Round(Screen.Width/2-Width/2);
Top:=Round(Screen.Height/2-Height/2);
end;
with Image1do
begin
Left:=0;
Top:=0;
Width:=Self.Width;
Height:=Self.Height;
end;
Image1.Canvas.Brush.Color:=RGB(0,205,255);
Image1.Canvas.Rectangle(0,0,Self.Width,Self.Height);
Desktop:=TCanvas.Create;
Desktop.Handle:=GetDC(0);
Image1.Canvas.CopyMode:=SRCAND;
Image1.Canvas.CopyRect(Rect(0,0,Screen.Width,Screen.Height),Desktop,
Rect(Round(Screen.Width/2-Width/2),Round(Screen.Height/2-Height/2),
Screen.Width,Screen.Height));
Desktop.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Desktop:TCanvas;
begin
with Selfdo
begin
Width:=500;
Height:=350;
Left:=Round(Screen.Width/2-Width/2);
Top:=Round(Screen.Height/2-Height/2);
end;
with Image1do
begin
Left:=0;
Top:=0;
Width:=Self.Width;
Height:=Self.Height;
end;
Image1.Canvas.Brush.Color:=RGB(0,205,255);
Image1.Canvas.Rectangle(0,0,Self.Width,Self.Height);
Desktop:=TCanvas.Create;
Desktop.Handle:=GetDC(0);
Image1.Canvas.CopyMode:=SRCAND;
Image1.Canvas.CopyRect(Rect(0,0,Screen.Width,Screen.Height),Desktop,
Rect(Round(Screen.Width/2-Width/2),Round(Screen.Height/2-Height/2),
Screen.Width,Screen.Height));
Desktop.Free;
end;