'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'Author: Larry Nung
'Date: 2009/6/2
'File:
'Memo:
'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
''' <summary>
'''
''' </summary>
''' <remarks></remarks>
Public
Class Form1
'***************************************************************************
'Author: Larry Nung
'Date: 2009/6/2
'Purpose:
'Memo:
'***************************************************************************
''' <summary>
''' Handles the Click event of the btnLoad control.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
''' <remarks></remarks>
Private
Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.PictureBox1.Image = New Bitmap(OpenFileDialog1.FileName)
End
If
End
Sub
'***************************************************************************
'Author: Larry Nung
'Date: 2009/6/2
'Purpose:
'Memo:
'***************************************************************************
''' <summary>
''' Brights the bitmap.
''' </summary>
''' <param name="bmp">The BMP.</param>
''' <param name="brighValue">The brigh value.</param>
''' <remarks></remarks>
Private
Function BrightBitmap(ByVal bmp As Bitmap, ByVal brighValue As
Integer) As Bitmap
For x As
Integer = 0 To bmp.Width - 1
For y As
Integer = 0 To bmp.Height - 1
Dim color As Color = bmp.GetPixel(x, y)
Dim r As
Integer = If(color.R + brighValue > 255, 255, color.R + brighValue)
Dim g As
Integer = If(color.G + brighValue > 255, 255, color.G + brighValue)
Dim b As
Integer = If(color.B + brighValue > 255, 255, color.B + brighValue)
bmp.SetPixel(x, y, color.FromArgb(r, g, b))
Next
Next
Return bmp
End
Function
'***************************************************************************
'Author: Larry Nung
'Date: 2009/6/3
'Purpose:
'Memo:
'***************************************************************************
''' <summary>
''' Handles the Click event of the btnBright control.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
''' <remarks></remarks>
Private
Sub btnBright_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBright.Click
PictureBox1.Image = BrightBitmap(DirectCast(PictureBox1.Image, Bitmap), TrackBar1.Value)
End
Sub
End
Class
图片旋转
VB.Net图像文件旋转变换的实例 |
|
作者:Ilu 来源:乐博网整理 更新时间:2009-8-21 |
|
VB.Net图像文件旋转变换的代码 乐博网lob.cn提示:此代码运行环境为vb.net2008 Public Class Form1 '浏览图像文件 Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click Me.openFileDialog1.Filter = "图像文件(JPeg,Gif,Bmp,etc.)|*.jpg;*.jpeg;*.gif; *.bmp; *.tif; *.tiff; *.png| JPeg 文件 (*.jpg;*.jpeg)|*.jpg;*.jpeg |GIF 文件 (*.gif)|*.gif |BMP 文件 (*.bmp)|*.bmp|Tiff 文件 (*.tif;*.tiff)|*.tif;*.tiff|Png 文件 (*.png)| *.png |所有文件(*.*)|*.*" If (Me.openFileDialog1.ShowDialog() = DialogResult.OK) Then Me.textBox1.Text = Me.openFileDialog1.FileName Dim MyImage = Image.FromFile(Me.textBox1.Text) Me.pictureBox1.Image = MyImage End If End Sub '旋转变换 多更.net源代码 请关注lob.cn Private Sub button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button6.Click Dim MyImage = Image.FromFile(Me.textBox1.Text) Dim MyAttributes As New System.Drawing.Imaging.ImageAttributes() Dim MyWidth = MyImage.Width Dim MyHeight = MyImage.Height Dim degrees = 60.0F Dim r = degrees * System.Math.PI / 180 Dim MyElements As Single()() = {New Single() {CType(System.Math.Cos(r), Single), CType(System.Math.Sin(r), Single), 0, 0, 0}, New Single() {-System.Math.Sin(r), -System.Math.Cos(r), 0, 0, 0}, New Single() {0, 0, 2, 0, 0}, New Single() {0, 0, 0, 1, 0}, New Single() {0, 0, 0, 0, 1}} Dim MyMatrix As New System.Drawing.Imaging.ColorMatrix(MyElements) MyAttributes.SetColorMatrix(MyMatrix, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap) Me.pictureBox1.CreateGraphics().DrawImage(MyImage, New Rectangle(0, 0, MyWidth, MyHeight), 0, 0, MyWidth, MyHeight, GraphicsUnit.Pixel, MyAttributes) End Sub End Class |