BrushCopy才素王道```
楼主看我怎么样把白色和蓝色作为背景色去掉```
procedure TForm1.Button5Click(Sender: TObject);
var
b: TBitmap;
c: TBitmap;
begin
b := TBitmap.Create;
c := TBitmap.Create;
try
b.Width := 100;
b.Height := 100;
c.Width := 100;
c.Height := 100;
b.Canvas.Brush.Color := clWhite;
b.Canvas.FillRect(Rect(0, 0, 100, 100));
b.Canvas.Brush.Color := clRed;
b.Canvas.FillRect(Rect(0, 0, 20, 20));
b.Canvas.Brush.Color := clBlue;
b.Canvas.FillRect(Rect(20, 20, 40, 40));
b.Canvas.Brush.Color := clGreen;
b.Canvas.FillRect(Rect(40, 40, 60, 60));
// 生成一张背景色为白色、蓝色,前景为红色,绿色色块的Bitmap,并在Canvas上
// 画出示例
Canvas.Draw(0, 0, b);
// 在中介c上把白色替换成中介透明色——紫色
c.Canvas.Brush.Color := clFuchsia;
c.Canvas.BrushCopy(Rect(0, 0, 100, 100), b, Rect(0, 0, 100, 100), clWhite);
// 画回到b上
b.Canvas.Draw(0, 0, c);
// 在中介c上把蓝色替换成中介透明色——紫色
c.Canvas.BrushCopy(Rect(0, 0, 100, 100), b, Rect(0, 0, 100, 100), clBlue);
// 在Canvas上画出c示例,此时将中介透明色——紫色,替换为“透明”
Canvas.Brush.Style := bsClear;
Canvas.BrushCopy(Rect(100, 0, 200, 100), c, Rect(0, 0, 100, 100), clFuchsia);
finally
b.Free;
c.Free;
end;
end;