delphi 圆形头像

procedure TfraItem.circleImage;
var
  Bmp: TBitmap;
  Rhandle: HRGN;
  filename:string;
begin

  Bmp := TBitmap.Create;

  Bmp.Assign(Image1.Picture.Graphic);

  Rhandle := CreateRoundRectRgn(0, 0, Image1.Width, Image1.height, Image1.Width, Image1.height);        // 创建圆角矩形Rgn
  Image1.Picture.Assign(nil);

  Image1.Canvas.Brush.Color := clRed;
  Image1.Canvas.FillRect(Image1.ClientRect);
  SelectClipRgn(Image1.Canvas.Handle, Rhandle);                               // 选择剪辑片段
  Image1.Canvas.Draw(0, 0, Bmp);

  Image1.Picture.Bitmap.TransparentColor := clRed;
  Image1.Transparent := true;
end;
posted @ 2022-05-19 10:34  朱颂东  阅读(158)  评论(0编辑  收藏  举报