我试图实现用渐变背景色绘制表单并用透明度重叠图像。
这个有可能?
我想使用具有透明背景的平铺背景图像并使用自定义线性渐变绘制背景。
最佳答案
我做到了!,我想与您分享我的解决方案(这很容易):
外部帮助:Tile a Shape with an Image
Private Sub BackgroundGradient(ByRef Control As Object, _
ByVal Color1 As Drawing.Color, _
ByVal Color2 As Drawing.Color)
Dim vLinearGradient As Drawing.Drawing2D.LinearGradientBrush = _
New Drawing.Drawing2D.LinearGradientBrush(New Drawing.Point(Control.Width, Control.Height), _
New Drawing.Point(Control.Width, 0), _
Color1, _
Color2)
Dim vGraphic As Drawing.Graphics = Control.CreateGraphics
' To tile the image background - Using the same image background of the image
Dim vTexture As New Drawing.TextureBrush(Control.BackgroundImage)
vGraphic.FillRectangle(vLinearGradient, Control.DisplayRectangle)
vGraphic.FillRectangle(vTexture, Control.DisplayRectangle)
vGraphic.Dispose() : vGraphic = Nothing : vTexture.Dispose() : vTexture = Nothing
End Sub
关于VB.Net 背景渐变使用 LinearGradientBrush 和显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10844183/