效果圖 素材 代碼 原理: 1 縮放黑影大小,並繪製到和花圖一樣的圖片上 2 使用黑影圖作為花圖的透明度遮罩,有黑影的地方不透明,其他地方透明 3 將花圖繪製到灰白的花上 ...
效果圖
素材
代碼
Dim B0, B1, B3 As Bitmap Private B As Bitmap = Nothing Private Sub Loading_Load(sender As Object, e As EventArgs) Handles MyBase.Load B0 = My.Resources.P0.Clone B1 = My.Resources.P1.Clone B3 = My.Resources.P3.Clone Me.Show() End Sub Private Sub Play() For I As Single = 0.1 To 1.5 Step 0.02 If Me.Disposing Then Exit Sub MakeBg(I) Threading.Thread.Sleep(10) Application.DoEvents() Next MakeBg(1.5) Threading.Thread.Sleep(2000) For I As Single = 255 To 0 Step -1 If Me.Disposing Then Exit Sub DSAPI.控制項.Form窗體.透明窗體樣式顯示圖像(Me, B, I) Application.DoEvents() Next End Sub Private Sub MakeBg(Db As Single) Try If B IsNot Nothing Then B.Dispose() B = Nothing If Db < 1.5 Then B = B0.Clone Using G As Graphics = Graphics.FromImage(B) G.Clip = New Region(New Rectangle(0, 0, 625, 656)) Dim _B1 As Bitmap = New Bitmap(625, 656) Using G2 As Graphics = Graphics.FromImage(_B1) G2.Clip = New Region(New RectangleF(0, 0, 625, 656)) Dim W, H As Integer Dim _B As Bitmap = MakeImg(Db) W = (625 - _B.Width) / 2 H = (656 - _B.Height) / 2 G2.DrawImage(_B, New Rectangle(W, H, _B.Width, _B.Height), New Rectangle(0, 0, _B.Width, _B.Height), GraphicsUnit.Pixel) _B.Dispose() End Using Dim _B3 As Bitmap = B1.Clone DSAPI.圖形圖像.應用透明度遮罩(_B3, _B1) _B1.Dispose() G.DrawImage(_B3, New Rectangle(0, 0, 625, 656), New Rectangle(0, 0, 625, 656), GraphicsUnit.Pixel) End Using Else B = B1.Clone End If DSAPI.控制項.Form窗體.透明窗體樣式顯示圖像(Me, B, 255) Catch End Try End Sub Private Sub Loading_Shown(sender As Object, e As EventArgs) Handles Me.Shown For I As Single = 0 To 255 DSAPI.控制項.Form窗體.透明窗體樣式顯示圖像(Me, B0, I) Application.DoEvents() If Me.Opacity = 0 Then Me.Opacity = 1 Next Play() Me.Close() End Sub Private Function MakeImg(Db As Single) As Bitmap Try Dim W, H As Integer W = 410 * Db H = 431 * Db Dim BB As New Bitmap(W, H) Using G As Graphics = Graphics.FromImage(BB) G.Clip = New Region(New Rectangle(0, 0, W, H)) G.DrawImage(B3, New Rectangle(0, 0, W, H), New Rectangle(0, 0, 410, 431), GraphicsUnit.Pixel) End Using Return BB Catch Return Nothing End Try End Function
原理:
1 縮放黑影大小,並繪製到和花圖一樣的圖片上
2 使用黑影圖作為花圖的透明度遮罩,有黑影的地方不透明,其他地方透明
3 將花圖繪製到灰白的花上