如何更改图像边框 [英] How to change image boarder to circle
本文介绍了如何更改图像边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须使用图像作为通知。为此,图像寄宿生应为椭圆形。有人可以帮我将图像寄宿生更改为圆形吗?
我已经提到了示例图像10应该是图像组件。如何获得圆形。
I have to use Image as Notification.For that Image boarder should be in elliptical shape.can any one help me to change my image boarder as a circle. I have mentioned an sample image 10 should be an image component.how can i get circle shape for it.
在此先感谢您。
您的 Rakesh
推荐答案
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;
根据您的需要调整不同的值...
Adjust the different values to what you need...
来自 RRUZ 的更新源
这篇关于如何更改图像边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文