如何快速更改淡入淡出效果的图像?

时间:2011-08-13 13:58:19

标签: vb.net image animation fade

我用过这个:

Dim i1 As Bitmap = owall.Clone
    Dim i2 As New Bitmap(ChangingWP)

    Dim g As Graphics = Graphics.FromImage(i1)

    Dim cm As New Imaging.ColorMatrix(New Single()() { _
                                                     New Single() {1, 0, 0, 0, 0}, _
                                                     New Single() {0, 1, 0, 0, 0}, _
                                                     New Single() {0, 0, 1, 0, 0}, _
                                                     New Single() {0, 0, 0, current_alpha, 0}, _
                                                     New Single() {0, 0, 0, 0, 1}})

    Dim ia As New Imaging.ImageAttributes
    ia.SetColorMatrix(cm, Imaging.ColorMatrixFlag.Default, Imaging.ColorAdjustType.Bitmap)

    g.DrawImage(i2, New Rectangle(0, 0, i2.Width, i2.Height), 0, 0, i2.Width, i2.Height, GraphicsUnit.Pixel, ia)
    g.Dispose()

    If increase Then
        current_alpha += Speed
    Else
        current_alpha -= Speed
    End If

    SetWallpaper(i1, Layout)
    If current_alpha >= 1 Then
        current_alpha = 1
        tmrBlend.Enabled = False
        SetWallpaper(ChangingWP, Layout)
    ElseIf current_alpha <= 0 Then
        current_alpha = 0
        tmrBlend.Enabled = False
    End If

但它并不快。你有什么想法吗? 实际上,我正试图用淡化效果来改变壁纸。

1 个答案:

答案 0 :(得分:-1)

如何更改显示图像的控件的Opacity属性,而不是更改图像本身?