//颜色透明度var
g: TGPGraphics;
sb: TGPSolidBrush;
begin
g := TGPGraphics.Create(Canvas.Handle);
sb := TGPSolidBrush.Create(MakeColor(128,255,0,0)); {128表示半透明}
g.FillRectangle(sb,10,10,100,100);
sb.Free;
g.Free;
end;
//使用 GDI+ 的颜色类型var
g: TGPGraphics;
sb: TGPSolidBrush;
color: TGPColor; {其实颜色是 DWORD 类型的}
begin
g := TGPGraphics.Create(Canvas.Handle);
color := aclRed;
sb := TGPSolidBrush.Create(color);
g.FillRectangle(sb,10,10,100,100);
sb.Free;
g.Free;
end;
//颜色混合模式var
g: TGPGraphics;
p: TGPPen;
begin
g := TGPGraphics.Create(Canvas.Handle);
p := TGPPen.Create(MakeColor(128,255,0,0),20);
g.SetCompositingMode(CompositingModeSourceCopy); {改写背景色}
g.DrawLine(p,11,11,111,111);
g.SetCompositingMode(CompositingModeSourceOver); {混合背景色, 默认值}
g.DrawLine(p,66,11,222,128);
p.Free;
g.Free;
end;
颜色混合模式:
Delphi | 微软 | 说明 |
CompositingModeSourceCopy | SourceCopy | 指定在呈现颜色时,它改写背景色。 |
CompositingModeSourceOver | SourceOver | 指定在呈现颜色时,它与背景色混合。该混合由所呈现的颜色的 alpha 成分确定。 |