ImageBitmap = New Bitmap(PictureBox1.ImageLocation)'提示参数无效,求教为何,谢谢!!!
Public Class Form2
Dim ImageBitmap As Bitmap
Dim gra As Graphics
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TrackBar1.Maximum = 100
TrackBar1.Value = 100
TrackBar1.TickFrequency = 10
PictureBox1.ImageLocation = "C:\Documents and Settings\YangJun\My Documents\My Pictures\白羊座.jpeg"
ImageBitmap = New Bitmap(PictureBox1.ImageLocation)'提示参数无效,求教为何,谢谢!!!
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
PictureBox1.Refresh()
End Sub
Private Sub PictureBox1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
gra = e.Graphics
gra.Clear(Color.White)
Dim cm As System.Drawing.Imaging.ColorMatrix = New System.Drawing.Imaging.ColorMatrix()
cm.Matrix00 = 1
cm.Matrix11 = 1
cm.Matrix22 = 1
cm.Matrix44 = 1
cm.Matrix33 = CType(TrackBar1.Value / 100, Single) ' 調 alpha 值
Dim ia As System.Drawing.Imaging.ImageAttributes = New System.Drawing.Imaging.ImageAttributes()
ia.SetColorMatrix(cm)
gra.DrawImage(ImageBitmap, New Rectangle(0, 0, ImageBitmap.Width, ImageBitmap.Height), 0, 0, ImageBitmap.Width, ImageBitmap.Height, GraphicsUnit.Pixel, ia)
End Sub
End Class