Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form2
- Dim time As Single = 0
- Dim image1 As Image = Image.FromFile("red_impala.jpg")
- Dim destRect As New Rectangle(0, 0, SystemInformation.PrimaryMonitorSize.Width, SystemInformation.PrimaryMonitorSize.Height)
- Dim newim As Image
- Private Sub Form2_Activated(sender As Object, e As EventArgs) Handles MyBase.Activated
- Form1.WindowState = vbNormal
- Form1.Focus()
- End Sub
- Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- DoubleBuffered = True
- End Sub
- Private Sub Form2_Click(sender As Object, e As EventArgs) Handles MyBase.Click
- Form1.WindowState = vbNormal
- Form1.Focus()
- End Sub
- Private Sub Form2_DoubleClick(sender As Object, e As EventArgs) Handles MyBase.DoubleClick
- Form1.WindowState = vbNormal
- Form1.Focus()
- End Sub
- Private Sub Form2_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
- newim = ChangeOpacity(image1, time)
- e.Graphics.DrawImage(newim, destRect)
- End Sub
- Public Shared Function ChangeOpacity(ByVal img As Image, ByVal opacityvalue As Single) As Bitmap
- Dim bmp As New Bitmap(img.Width, img.Height)
- Dim graphics__1 As Graphics = Graphics.FromImage(bmp)
- Dim colormatrix As New System.Drawing.Imaging.ColorMatrix
- colormatrix.Matrix33 = opacityvalue
- Dim imgAttribute As New System.Drawing.Imaging.ImageAttributes
- imgAttribute.SetColorMatrix(colormatrix, System.Drawing.Imaging.ColorMatrixFlag.[Default], System.Drawing.Imaging.ColorAdjustType.Bitmap)
- graphics__1.DrawImage(img, New Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, img.Width, img.Height,
- GraphicsUnit.Pixel, imgAttribute)
- graphics__1.Dispose()
- Return bmp
- End Function
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- Timer2.Enabled = True
- Timer2.Interval = 10
- End Sub
- Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
- If time >= 0 And time <= 1 Then
- time = time + 0.01
- Me.Refresh()
- End If
- If time > 1 Then
- time = 0
- Timer2.Enabled = False
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement