gpt4 book ai didi

delphi - 如何将图片边框改为圆形

转载 作者:行者123 更新时间:2023-12-03 15:07:53 27 4
gpt4 key购买 nike

我必须使用图像作为通知。为此图像边框应为椭圆形。任何人都可以帮助我将图像边框更改为圆形。 我已经提到示例图像 10 应该是一个图像组件。我怎样才能获得它的圆形形状。

提前致谢。你的拉克什

enter image description here

最佳答案

const
BORDER = 3;
Var
Bmp : TBitmap;
w, h: Integer;
x, y: Integer;
begin
Bmp:=TBitmap.Create;
try
Bmp.PixelFormat:=pf24bit;
Bmp.Canvas.Font.Name :='Arial'; // set the font to use
Bmp.Canvas.Font.Size :=20; //set the size of the font
Bmp.Canvas.Font.Color := clWhite; //set the color of the text
w :=Bmp.Canvas.TextWidth(IntToStr(sped1.Value)); //calculate the width of the image
h :=Bmp.Canvas.TextHeight(IntToStr(sped1.Value)); //calculate the height of the image
Bmp.Width := Max(w, h) + BORDER * 2; // get a square
Bmp.Height := Max(w, h) + BORDER * 2; // get a square
x := (Bmp.Width - w) div 2; // center
y := (Bmp.Height - h) div 2; // center
Bmp.Canvas.Brush.Color := clBlue; //set the background
Bmp.Canvas.FillRect(Rect(0,0, Bmp.Width, Bmp.Height)); //paint the background which is transparent
Bmp.Canvas.Brush.Color := clRed; // circle in red
Bmp.Canvas.Pen.Color := clRed; // circle in red
Bmp.Canvas.Ellipse(0, 0, Bmp.Width, Bmp.Height); // draw the circle
Bmp.Canvas.TextOut(x, y, IntToStr(sped1.Value)); //draw the number
img1.Picture.Assign(bmp); // assign the bmp to the image ; image.transparent = true, .stretch = true;
finally
Bmp.Free;
end;

根据需要调整不同的值... enter image description here

<小时/>

更新源 RRUZ

关于delphi - 如何将图片边框改为圆形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7514256/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com