delphi – 如何将图像边界更改为圆形

delphi – 如何将图像边界更改为圆形,第1张

概述我必须使用 Image作为通知.对于那个图像寄宿生应该是椭圆形的形状.任何人都可以帮我改变我的图像寄宿作为一个圆圈.  我已经提到了一个示例图像10应该是一个图像组件.我可以得到它的圆形. 提前致谢. 你的拉克什 const BORDER = 3;Var Bmp : TBitmap; w, h: Integer; x, y: Integer;begin Bmp:=TBitm 我必须使用 Image作为通知.对于那个图像寄宿生应该是椭圆形的形状.任何人都可以帮我改变我的图像寄宿作为一个圆圈.
 我已经提到了一个示例图像10应该是一个图像组件.我可以得到它的圆形.

提前致谢.
你的拉克什

解决方法
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,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,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;

根据您的需要调整不同的值…

从RRUZ更新了源代码

总结

以上是内存溢出为你收集整理的delphi – 如何将图像边界改为圆形全部内容,希望文章能够帮你解决delphi – 如何将图像边界更改为圆形所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1251451.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存