Public Class Piccl    Dim Bl As Single = 1    Dim Op As New OpenFileDialog    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click        Op.Filter = "图片(*.jpg)|*.jpg|图片(*.gif)|*.gif|图片(*.bmp)|*.bmp"
        If Op.ShowDialog <> Windows.Forms.DialogResult.OK Then Exit Sub        Dim Old_w As Integer = PictureBox1.Width
        Dim Old_h As Integer = PictureBox1.Height        PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
        PictureBox1.Image = System.Drawing.Image.FromStream(Op.OpenFile)
        Dim Pw, Ph As Integer        Bl = 1        Pw = PictureBox1.Width
        Ph = PictureBox1.Height        If Pw > Old_w Or Ph > Old_h Then
            PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
            If Pw > Ph Then
                Bl = Old_w / Pw
                PictureBox1.Width = Old_w
                PictureBox1.Height = Ph * Bl
            Else
                Bl = Old_h / Ph
                PictureBox1.Height = Old_h
                PictureBox1.Width = Pw * Bl
            End If
        End If    End Sub
    Private Sub Piccl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
    End Sub    Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
        Me.DialogResult = Windows.Forms.DialogResult.No
        Me.Close()
    End Sub
    Public Sub AdjustImage(ByVal e As PaintEventArgs)
        Try
            'Dim original As New Bitmap(PictureBox1.Image)
            Dim original As System.Drawing.Bitmap = System.Drawing.Image.FromStream(Op.OpenFile)
            Dim width As Integer = PictureBox1.Width
            Dim height As Integer = PictureBox1.Height
            Dim image As New Bitmap(original, New Size(width, height))
            Dim imageAttributes As New System.Drawing.Imaging.ImageAttributes()            Dim colorMatrixElements As Single()() = { _
               New Single() {CType(Me.nudB.Value / 100, Single), 0, 0, 0, 0}, _
               New Single() {0, CType(Me.nudR.Value / 100, Single), 0, 0, 0}, _
               New Single() {0, 0, CType(Me.nudG.Value / 100, Single), 0, 0}, _
               New Single() {0, 0, 0, CType(Me.nudalpha.Value / 100, Single), 0}, _
               New Single() {0, 0, 0, 0, 1}}            Dim colorMatrix As New System.Drawing.Imaging.ColorMatrix(colorMatrixElements)            imageAttributes.SetColorMatrix( _
               colorMatrix, _
               System.Drawing.Imaging.ColorMatrixFlag.Default, _
               System.Drawing.Imaging.ColorAdjustType.Bitmap)            imageAttributes.SetGamma(CType(Me.nudgamma.Value / 100, Single), System.Drawing.Imaging.ColorAdjustType.Bitmap)
            e.Graphics.DrawImage( _
               image, _
                New Rectangle(0, 0, width, height), _
               0, 0, _
               width, _
               height, _
               GraphicsUnit.Pixel, _
               imageAttributes)        Catch Ex As Exception
            'MsgBox(Ex.Message)
        End Try    End Sub    Private Sub nudB_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles nudB.ValueChanged
        PictureBox1.Invalidate()
    End Sub    Private Sub nudG_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles nudG.ValueChanged
        PictureBox1.Invalidate()
    End Sub    Private Sub nudR_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles nudR.ValueChanged
        PictureBox1.Invalidate()
    End Sub    Private Sub nudalpha_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles nudalpha.ValueChanged
        PictureBox1.Invalidate()
    End Sub    Private Sub nudgamma_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles nudgamma.ValueChanged
        PictureBox1.Invalidate()
    End Sub    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint        
        AdjustImage(e)
    End Sub    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        PictureBox1.Refresh()
        Try
            PictureBox1.Image.Save(Application.StartupPath() & "\temp_tz.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
'Picturebox1 正常显示调色后的效果,
'为什么Picturebox1总保存不了调色后的效果图版,
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End SubEnd Class