DrawingaFilledRectanglewithLowOpacity我在C#语言的WindowsForms应用程序中有一个带有图片的PictureBox。我想在图片框中的某处绘制一个FillRectangle。但是我还需要看图片框的图片。我可以绘制这个低不透明度矩形来查看图片框的图像吗?你的意思是:using(Graphicsg=Graphics.FromImage(pb.Image)){using(Brushbrush=newSolidBrush(your_color)){g.FillRectangle(brush,x,y,width,height);}}或者你可以使用Brushbrush=newSolidBrush(Color.FromArgb(alpha,red,green,blue))alpha从0到255,所以你的alpha值为128会给你50%的不切实际。您需要从PictureBox图像创建一个Graphics对象,并在其上绘制您想要的内容:Graphicsg=Graphics.FromImage(pictureBox1.Image);g.FillRectangle(Brushes.Red,newRectangle(10,10,200,200))pictureBox1.Refresh()或者按照@DavideParias的建议,您可以使用Paint事件处理程序:以上是C#的全部内容学习教程:绘制低不透明度的填充矩形,如果对大家有用,需要了解更多C#学习教程,希望大家多多关注—privatevoidpictureBox_Paint(objectsender,PaintEventArgse){e.Graphics.FillRectangle(Brushes.Red,newRectangle(10,10,200,200));}本文来自网络收藏,不代表立场,如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
