일단 모듈이나 폼에 아래 프로시저를 선언합니다.
Private Sub Back_SlowHide(ByVal tObj As PictureBox, ByVal Images As Image, ByVal Opacity As Single)
Dim Img As Image = Images
tObj.Image = New Bitmap(Img.Width, Img.Height)
tObj.BackColor = Color.Transparent
Dim IA As New Imaging.ImageAttributes
Dim CM As New Imaging.ColorMatrix
CM.Matrix00 = 1 : CM.Matrix11 = 1 : CM.Matrix22 = 1 : CM.Matrix33 = Opacity : CM.Matrix44 = 1
IA.SetColorMatrix(CM)
With tObj
Using G As Graphics = Graphics.FromImage(tObj.Image)
G.DrawImage(Img, New Rectangle(0, 0, .Image.Width, .Image.Height), 0, 0, .Image.Width, .Image.Height, GraphicsUnit.Pixel, IA)
End Using
IA.Dispose()
End With
End Sub
다음 적용이 필요한 폼에서 다음과 같이 사용합니다.
'서서히 표시되게 하기
Dim tmpP As PictureBox
Dim i As Single
Dim Images As Image = My.Resources.darknight
tmpP = New PictureBox
With tmpP
.Size = New Size(Images.Width, Images.Height)
.Location = New Point((Me.ClientSize.Width - .Width) / 2, (Me.ClientSize.Height - .Height) / 2)
.Visible = True
End With
Me.Controls.Add(tmpP)
For i = 0 To 1 Step 0.01
Call Back_SlowHide(tmpP, Images, i)
Application.DoEvents()
Next
이렇게 사용하시면 되겠습니다.
서서히 사라지게 하는 방법은 코드에서 For 문 부분만 변경하시면 되니, 나름대로 응용해보세요!
좋은 하루 보내세요!