VB.Net 背景渐变使用 LinearGradientBrush 和显示图像

标签 vb.net forms graphics

我试图实现用渐变背景色绘制表单并用透明度重叠图像。

这个有可能?

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

最佳答案

我做到了!,我想与您分享我的解决方案(这很容易):

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

相关文章:

r - 如何在绘制 partykit 的 ctree 输出时抖动节点分割字符串?

vb.net - VB语法和表达错误

python - 如何将 VBscript 转换为 Python 代码?

python - 在views.py django中检索多个单选按钮和表单字段的值

jquery - 使用 jquery 更改另一个字段时如何触发隐藏表单字段值的更改

c++ - 硬件加速 Unicode 文本渲染

java - JOptionPane 在 JPanel 中不能正常工作

vb.net - 升级 VB6 方法以将随机访问文件读取到 VB.net,无法读取超出流末尾的最后一条记录异常

vb.net - VB.NET 中高效的多变量声明和赋值

jquery - 如何让所有标签在左侧对齐?