RAD Studio 10.4 测试√
procedure TMainF.Button4Click(Sender: TObject);
var
Bmp: TBitmap;
Rhandle: HRGN;
// R: TRect;
begin
Image2.Picture.LoadFromFile('head.jpg'); // 加载图片
// Image2.AutoSize := true; // image大小自动调整
// R := Image2.ClientRect;
Bmp := TBitmap.Create; // 创建 Bmp
// bmp.LoadFromFile('1.bmp'); // 加载bmp图片
Bmp.Assign(Image2.Picture.Graphic);
// Rhandle:=CreateRoundRectRgn(100,0,200,100,100,100);
Rhandle := CreateRoundRectRgn(0, 0, Image2.Width, Image2.height, Image2.Width, Image2.height); // 创建圆角矩形Rgn
Image2.Picture.Assign(nil);
// Image2.AutoSize := false;
// Image2.Stretch := false;
// Image2.height := R.Bottom - R.Top;
// Image2.Width := R.Right - R.Left;
Image2.Canvas.Brush.Color := clRed;
Image2.Canvas.FillRect(Image2.ClientRect);
SelectClipRgn(Image2.Canvas.Handle, Rhandle); // 选择剪辑片段
Image2.Canvas.Draw(0, 0, Bmp);
// DeleteObject(Rhandle);
// Image2.Canvas.Brush.Style := bsClear;
Image2.Picture.Bitmap.TransparentColor := clRed;
// Image2.Picture.Bitmap.Transparent := true;
Image2.Transparent := true;
end;