VB.Net背景渐变使用LinearGradientBrush并显示Image

我尝试使用渐变背景颜色绘制一个表单,并将图像与透明度重叠.

这个有可能?

我想使用具有透明背景的平铺背景图像,并使用自定义线性渐变绘制背景.

解决方法

我做到了!,我希望与你分享我的解决方案(这很简单):

外部帮助: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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐