Advertisement
Guest User

Untitled

a guest
Aug 16th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form2
  2.     Dim time As Single = 0
  3.     Dim image1 As Image = Image.FromFile("red_impala.jpg")
  4.     Dim destRect As New Rectangle(0, 0, SystemInformation.PrimaryMonitorSize.Width, SystemInformation.PrimaryMonitorSize.Height)
  5.     Dim newim As Image
  6.     Private Sub Form2_Activated(sender As Object, e As EventArgs) Handles MyBase.Activated
  7.         Form1.WindowState = vbNormal
  8.         Form1.Focus()
  9.     End Sub
  10.  
  11.     Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  12.         DoubleBuffered = True
  13.     End Sub
  14.  
  15.     Private Sub Form2_Click(sender As Object, e As EventArgs) Handles MyBase.Click
  16.         Form1.WindowState = vbNormal
  17.         Form1.Focus()
  18.     End Sub
  19.  
  20.     Private Sub Form2_DoubleClick(sender As Object, e As EventArgs) Handles MyBase.DoubleClick
  21.         Form1.WindowState = vbNormal
  22.         Form1.Focus()
  23.     End Sub
  24.  
  25.     Private Sub Form2_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
  26.         newim = ChangeOpacity(image1, time)
  27.         e.Graphics.DrawImage(newim, destRect)
  28.     End Sub
  29.  
  30.     Public Shared Function ChangeOpacity(ByVal img As Image, ByVal opacityvalue As Single) As Bitmap
  31.         Dim bmp As New Bitmap(img.Width, img.Height)
  32.         Dim graphics__1 As Graphics = Graphics.FromImage(bmp)
  33.         Dim colormatrix As New System.Drawing.Imaging.ColorMatrix
  34.         colormatrix.Matrix33 = opacityvalue
  35.         Dim imgAttribute As New System.Drawing.Imaging.ImageAttributes
  36.         imgAttribute.SetColorMatrix(colormatrix, System.Drawing.Imaging.ColorMatrixFlag.[Default], System.Drawing.Imaging.ColorAdjustType.Bitmap)
  37.         graphics__1.DrawImage(img, New Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, img.Width, img.Height,
  38.          GraphicsUnit.Pixel, imgAttribute)
  39.         graphics__1.Dispose()
  40.         Return bmp
  41.     End Function
  42.  
  43.     Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  44.         Timer2.Enabled = True
  45.         Timer2.Interval = 10
  46.     End Sub
  47.  
  48.     Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
  49.         If time >= 0 And time <= 1 Then
  50.  
  51.             time = time + 0.01
  52.             Me.Refresh()
  53.         End If
  54.         If time > 1 Then
  55.             time = 0
  56.             Timer2.Enabled = False
  57.         End If
  58.     End Sub
  59.  
  60. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement