Rotate an Image : Image Operation « 2D Graphics « VB.Net Tutorial

VB.Net Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statements
5. Date Time
6. Class Module
7. Development
8. Collections
9. Generics
10. Attributes
11. Event
12. Stream File
13. GUI
14. GUI Applications
15. 2D Graphics
16. I18N Internationlization
17. Reflection
18. Regular Expressions
19. Security
20. Socket Network
21. Thread
22. Windows
23. XML
24. Database ADO.net
25. Design Patterns
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial » 2D Graphics » Image Operation 
15. 49. 1. Rotate an Image
 


Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

public class RotateImage
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1
    Inherits System.Windows.Forms.Form

    Public Sub New()
        MyBase.New()
        InitializeComponent()

    End Sub

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is NothingThen
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    Private components As System.ComponentModel.IContainer

    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Button4 As System.Windows.Forms.Button
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents Panel2 As System.Windows.Forms.Panel
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button4 = New System.Windows.Forms.Button
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.Panel2 = New System.Windows.Forms.Panel
        Me.SuspendLayout()
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(88232)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(6424)
        Me.Button2.TabIndex = 3
        Me.Button2.Text = "Rotate"
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(328232)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(5624)
        Me.Button4.TabIndex = 5
        Me.Button4.Text = "Exit"
        '
        'Panel1
        '
        Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Panel1.Location = New System.Drawing.Point(2416)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(200184)
        Me.Panel1.TabIndex = 10
        '
        'Panel2
        '
        Me.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Panel2.Location = New System.Drawing.Point(24816)
        Me.Panel2.Name = "Panel2"
        Me.Panel2.Size = New System.Drawing.Size(208184)
        Me.Panel2.TabIndex = 11
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(464286)
        Me.Controls.Add(Me.Panel2)
        Me.Controls.Add(Me.Panel1)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.ResumeLayout(False)

    End Sub

    Dim pic1, pic2 As Bitmap


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles Button2.Click
        Panel2.Invalidate()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles Button4.Click
        End
    End Sub

    Private Sub Panel1_Paint1(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgsHandles Panel1.Paint
        Dim As Graphics = e.Graphics
        g.DrawImage(pic1, 00)
    End Sub

    Private Sub Panel2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgsHandles Panel2.Paint
        Dim As Graphics = e.Graphics
        Dim As Integer = Panel2.Width
        Dim col As Color = New Color
        
        Dim pic3 As Bitmap
        pic3 = New Bitmap(x, x)
        Dim i, j As Integer
        For i = To x - 1
            For j = To x - 1
                col = pic2.GetPixel(i, j)
                pic3.SetPixel(i, x - - j, col)
            Next
        Next
        g.DrawImage(pic3, 00)
        pic2 = New Bitmap(pic3)
    End Sub


    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgsHandles MyBase.Load
        Panel1.Height = Panel1.Width
        Panel2.Width = Panel1.Width
        Panel2.Height = Panel2.Width
        Dim pic As Image = Image.FromFile("YourFile.bmp")
        pic1 = New Bitmap(pic, Panel1.Width, Panel1.Height)
        pic2 = New Bitmap(pic1)
    End Sub

End Class

        
15. 49. Image Operation
15. 49. 1. Rotate an Image
15. 49. 2. Mirror an Image
15. 49. 3. Move an image and paintMove an image and paint
15. 49. 4. Scale an imageScale an image
15. 49. 5. Scale image with different Graphics UnitsScale image with different Graphics Units
15. 49. 6. Skew imageSkew image
15. 49. 7. Make an image transparentMake an image transparent
15. 49. 8. Invert an ImageInvert an Image
15. 49. 9. Invert an Image unsafeInvert an Image unsafe
15. 49. 10. Zoom ImageZoom Image
15. 49. 11. Zoom and Skew an ImageZoom and Skew an Image
15. 49. 12. Skew an ImageSkew an Image
w__w___w.j_a_v__a__2s_.___c__o___m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.