MiB*_*Bol 4 vb.net forms graphics
我尝试使用渐变背景颜色绘制一个表单,并将图像与透明度重叠.
这个有可能?
我想使用具有透明背景的平铺背景图像,并使用自定义线性渐变绘制背景.
我做到了!,我希望与你分享我的解决方案(这很简单):
外部帮助:使用图像平铺形状
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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14866 次 |
最近记录: |